This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problem with dlsym to fetch address of some functions


  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
calls dlsym in its pseudo assembler to resolve address of

  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;
            value = dlsym(DL_HANDLE, parser.string + 1);
            if ((string = dlerror()))
                error("%s", string);


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]