X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:date:message-id:subject:from:to
	:content-type; q=dns; s=default; b=MUY+cOQQHqHEOFI8AdAzvZa3Pqv5q
	X/xW5kIFHKeFaKPErVa/ey9nRHYujuAP2S1qgZ/leYuyoD51/ceM1aTmmXiF4khs
	r0b07eb94JiTwcbDgzJdNBbvnqFZL/8jYdhmfP8hSc/rSbAa+EuYRWt6MMzzQ/OO
	OZZZfF5DwVgIKM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:date:message-id:subject:from:to
	:content-type; s=default; bh=gkkai2huEt+HcbksdcVG1d+/f30=; b=UqS
	oB4hepSXVyMlet6Rl6k02odbI14OtoXFUkYNcyXwPMYZkh77IB9+hlLoDQ9YAuJE
	qUbTZjrsudomc691YpbKW0AxyBcS9vEP9BLpaxQUMnC1aqKFtjgOf4Bf7GEqtwwI
	RUG7seWPmUTsKUz+HaRIQsuaR63HMehTiIvaI3iE=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-pa0-f51.google.com
MIME-Version: 1.0
X-Received: by 10.67.5.40 with SMTP id cj8mr1834273pad.137.1411497814906; Tue, 23 Sep 2014 11:43:34 -0700 (PDT)
Date: Tue, 23 Sep 2014 15:43:34 -0300
Message-ID: <CAHAq8pFUmaSaiRc4LiLK+ieAqB_sPF8iaHFZQ=fzoM-3d+V5PQ@mail.gmail.com>
Subject: problem with dlsym to fetch address of some functions
From: =?UTF-8?Q?Paulo_C=C3=A9sar_Pereira_de_Andrade?= <paulo.cesar.pereira.de.andrade@gmail.com>
To: cygwin@cygwin.com
Content-Type: text/plain; charset=UTF-8
X-IsSubscribed: yes

  Hi,

  Forgive me if this is expected. I am probably abusing dlsym
behavior on other systems.

(gdb) p sprintf
$1 = {<text variable, no debug info>} 0x10044b300 <sprintf>
(gdb) p (void*)dlsym(NULL, "sprintf")
$2 = (void *) 0x7708a738 <sprintf>

  The test driver I use for http://www.gnu.org/software/lightning
calls dlsym in its pseudo assembler to resolve address of
functions.

  If using dlsym in the above example, it will return the address
of some function that does not handle float arguments, and
%f format will just print "f".

(gdb) x/i sprintf
   0x10044b300 <sprintf>:
    jmpq   *0x16026(%rip)        # 0x10046132c <__imp_sprintf>
(gdb) x/i 0x7708a738
   0x7708a738 <sprintf>:        mov    %rsp,%rax

  Since dlsym is only used to write test cases, at first I should
use a pseudo patch like this:

---%<---
#if __CYGWIN__
        /* FIXME kludge to pass varargs test case, otherwise,
         * will not print/scan float values */
        if (strcmp(parser.string + 1, "sprintf") == 0)
            value = sprintf;
        else if (strcmp(parser.string + 1, "sscanf") == 0)
            value = sscanf;
        else
#endif
        {
            value = dlsym(DL_HANDLE, parser.string + 1);
            if ((string = dlerror()))
                error("%s", string);
        }
---%<---

Thanks,
Paulo

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

