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


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

Re: Bug in dlsym() (scope problem(?) & RTLD_NEXT problem)


In dist.glibc, article <907813153.32169@noris.de>,
  drepper@cygnus.com (Ulrich Drepper) writes:
> 
> I have to investigate how the dlopen() method finds the local
> definition but I guess you are right it's because of write being weak
> in libc.  The question is: is this the right way?  I would say yes
> (i.e., no error), since dlsym should work the same way as an implicit
> lookup through PLT would do it.
> 
I disagree. If I use RTLD_NEXT, I want the definition used by "the next
library", i.e. as if that library was the only one loaded (with the libs it
depends on, of course).

In other words, assume that a call to dlsym(RTLD_NEXT,"write") is in
libfoo.so and it is linked with ... "-lbar -lfoo -lc".

Then the result of the lookup should not change: It must NOT matter what
kind of symbol "write" is in libc, only that it is externally visible.
It must also not matter which symbols are in libfoo.so or in libbar.so or
in the main program. Specifically, if "write" is a weak symbol which points
to "__write", then the above call must NOT return a "write" or "__write"
symbol in libfoo.so.
The same applies, of course, when you explicitly open a library and lookup
a symbol from it.

Without these constraints, writing a preload library is really difficult.
I had to play around quite a bit to get mine to work, and they tend to
break when somebody changes symbols in libc.

I really should write a couple of tests for all of this.  :-/

Does anybody know how other OSes, esp. Slowaris, handle this?

-- 
Matthias Urlichs  |  noris network GmbH   |   smurf@noris.de  |  ICQ: 20193661
The quote was selected randomly. Really.    |      http://www.noris.de/~smurf/
-- 
There is no greater sign of a general decay of virtue in a nation, than
a want of zeal in its inhabitants for the good of their country.
                                -- Joseph Addison


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