From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9648 invoked by alias); 23 Sep 2014 18:43:38 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 9639 invoked by uid 89); 23 Sep 2014 18:43:38 -0000 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 Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 23 Sep 2014 18:43:36 +0000 Received: by mail-pa0-f51.google.com with SMTP id eu11so5395361pac.38 for ; Tue, 23 Sep 2014 11:43:35 -0700 (PDT) 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) Received: by 10.70.35.8 with HTTP; Tue, 23 Sep 2014 11:43:34 -0700 (PDT) Date: Tue, 23 Sep 2014 19:37:00 -0000 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@cygwin.com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00357.txt.bz2 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