This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: Symbol binding in shared libraries...


>    bp = ((char*)map->l_info[DT_STRTAB]->d_un.d_ptr) + sym->st_name;
> to
>    bp = ((char*)map->l_info[DT_STRTAB]->d_un.d_ptr) + refsym->st_name;

The former is incorrect.  SYM is a symbol from another object (you don't
know which at this point in the code), and you are using its string-table
offset with the string table from the MAP object.  REFSYM is a symbol in
the MAP object that has the name you want, so the latter is correct.  This
sort of oversight suggests to me you might not have read all the code you
are working with as closely as you could have.

> The dynamic loader seems to be binding to the PLT entry in the main
> executable for fflush, rather than the address of fflush in libc.so.

It is clearly stated in the spec (I don't have a citation off hand) that
this is the specified behavior for references that aren't from a PLT.
Consider `return &foo;' in a shared object and `if (ptr == &foo)' in the
main executable, where `&foo' in non-PIC code will have been fixed at link
time to the address of the executable's PLT entry for `foo'.

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