X-Recipient: archive-cygwin AT delorie DOT 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 AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT 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: Subject: problem with dlsym to fetch address of some functions From: =?UTF-8?Q?Paulo_C=C3=A9sar_Pereira_de_Andrade?= To: cygwin AT cygwin DOT 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 = {} 0x10044b300 (gdb) p (void*)dlsym(NULL, "sprintf") $2 = (void *) 0x7708a738 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 : jmpq *0x16026(%rip) # 0x10046132c <__imp_sprintf> (gdb) x/i 0x7708a738 0x7708a738 : 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