This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

How should the GNU linker treat weak references?


[ CC'ed to the gcc list, since I think the GCC people should know that
  executables might pick up a dependency on the shared libgcc where
  they didn't intend that to happen.  ]

On ELF systems, the GNU linker (GNU ld), includes DSO's that are
mentioned in DT_NEEDED entries of DSO's passed to the linker in the
final link.  If necessary, that is when a symbol in one of those
libraries is referenced by a regular object passed to the linker, it
adds a DT_NEEEDED entry for those DSO's to the final executable.

This has an undesirable effect in combination with GCC 3.0's shared
libgcc.  Every DSO created with the new GCC is (by default) linked
against this shared libgcc, and will therefore have a DT_NEEDED entry
for libgcc.so.1.  Now since crtbegin.o contains a weak reference to
__register_frame_info_bases, which has a definition in the shared
libgcc, the linker will add a DT_NEEDED entry for libgcc.so.1 to every
executable linked against a DSO created with GCC 3.0.

Note that the Solaris linker doesn't suffer from this problem since it
doesn't automagically add DT_NEEDED entries, and only includes DSO
that are explicitly mentioned on the linker command line.

Personally I think the Solaris behaviour is much saner, and I think
that's what the GNU linker should do, at least by default.  But that
still leaves open the question how the linker should treat weak
references.  Should the linker try to resolve those to definitions in
DSO's brought in via DT_NEEDED entries of other DSO's?  Should the
linker try to resolve those at all?  And should we add version
information for those symbols?

I think that before we try to fix the problem I described above, we
should answer those questions first.

Mark


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