This is the mail archive of the binutils@sourceware.cygnus.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]

Re: GNU-ld behaviour does not match native linker behaviour


   Date: Fri, 3 Dec 1999 11:25:06 GMT
   From: Nick Clifton <nickc@cygnus.com>

   Presumably what should happen is that AR should only put a common
   symbol into its archive symbol table if the symbol is the definition
   of a common and not just another reference to it.  The the linker
   would know to link in that element.

That doesn't really make sense.  Common symbols are neither
definitions nor references.  They are a form of quasi definition which
becomes a reference if a real definition is seen, but get merged into
a real definition otherwise.

It seems as though to make your test case work we would have to make
two changes: 1) if a common symbol matches a symbol in the archive
symbol map, include the element in the link; 2) do not put common
symbols in the archive symbol map (see compute_and_write_armap in
archive.c).

Change 2 seems correct at first glance.  If a library includes
multiple objects which include a common symbol, we should not put that
common symbol into the archive symbol map multiple times.  That
doesn't make sense.

Given change 2, then change 1 makes some sense.  We will only see a
symbol in the archive map if it is a definition.  If we have a common
symbol, we want to bring in a definition.

I don't have the ELF spec handy.  I don't suppose it says anything
about this issue?  I also think we must test other ELF systems before
we should make either change.

Note that change 2 must not be made for the a.out object file format.
a.out defines a different, and rather odd, procedure for linking
against common symbols in archives.  See aout_link_check_ar_symbols in
aoutx.h.

Ian

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