This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Bug in dynamic linker
On Thu, Jul 20, 2000 at 07:10:48PM +0200, Mark Kettenis wrote:
> Date: Thu, 20 Jul 2000 09:04:11 -0700
> From: "H . J . Lu" <hjl@lucon.org>
>
> On Thu, Jul 20, 2000 at 03:06:29PM +0200, Mark Kettenis wrote:
> >
> > IMHO, this patch needs some more discussion. This isn't a simple
> > bugfix. It changes the way the linker behaves from the user
> > standpoint considerably, since it will now silently add DT_NEEDED
> > entries for libraries that are not explicitly mentioned on the
> > command-line. I also wonder if this patch could change the order of
> > the DT_NEEDED entries, e.g. can a DT_NEEDED generated by HJ's patch
> > come before a DT_NEEDED for a library mentioned on the command line?
> >
> > Suppose I have an implementation of libfoo.so.1 that depends on
> > libbar.so. I know link a program with libfoo.so.1. Before HJ's patch
> > it would only get a DT_NEEDED entry for libfoo.so.1. Now it will also
> > get one for libbar.so.
>
> Are you just guessing or do you have a testcase? If you have a
> testcase, please send it to me. I have verified your case won't
> happen unless your program uses libbar.so. Try it yourself. If ld
> adds libbar.so to DT_NEEDED, it is a bug and you should report
> it to me.
>
> Admittedly the problem scenario is a little more complicated than
> what I wrote before, and perhaps Linux-specific, but here it is:
>
> Suppose you have a libfoo that is linked agains libpthread. Suppose
> you have a program foo that references close, and is linked with
> libfoo. Remember that close is a weak symbol in libc and a normal
Thanks for bringing this up.
> symbol in libpthread. That means that by walking the DT_NEEDED chain,
> ld will prefer the definition in libpthread. I believe that with your
> patch foo will get a DT_NEEDED for libpthread. The reason I believe
> this is true, is that right now ld records the version information for
> close in libpthread. This was the exact scenario causing the
> origional "bug".
>
> So you see that there are cases where a program doesn't explicitly
> reference a symbol in a particular library, it will nevertheless get
> a DT_NEEDED for that library.
Could you please spend a few minutes creating a testcase and sending
to me? Call me dumb. I need to see it to really believe it. I really
appreciate it.
Thanks.
H.J.