This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How does ld link against library archives?
- From: "David Carter-Hitchin" <david at carter-hitchin dot clara dot co dot uk>
- To: <gcc-help at gcc dot gnu dot org>
- Cc: "Ian Lance Taylor" <ian at airs dot com>, "Erik Leunissen" <e dot leunissen at hccnet dot nl>
- Date: Mon, 12 Dec 2005 09:27:57 -0000
- Subject: Re: How does ld link against library archives?
- References: <439C4BB3.7090903@hccnet.nl> <m3wtib2d4h.fsf@gossamer.airs.com>
If compiling with GCC on another platform, say Solaris or HP-UX, can
anyone say if it is better, worse or no different if the native linker is
used
instead of GNU ld?
Thanks,
David.
----- Original Message -----
From: "Ian Lance Taylor" <ian@airs.com>
To: "Erik Leunissen" <e.leunissen@hccnet.nl>
Cc: <gcc-help@gcc.gnu.org>
Sent: Monday, December 12, 2005 3:44 AM
Subject: Re: How does ld link against library archives?
> Erik Leunissen <e.leunissen@hccnet.nl> writes:
>
> > Regarding the "-l" command line option for the GNU linker, the manual
> > page says:
>
> The GNU linker is part of the binutils, and questions about it are
> appropriately directed to binutils@sourceware.org. See
> http://sourceware.org/binutils/
>
> > "If the archive defines a symbol which was undefined in some object
> > which appeared before the archive on the command line, the linker will
> > include the appropriate file(s) from the archive."
> >
> > I was wondering what "include the appropriate file(s)" exactly means
> > in this context. Specifically, I would like to know which code from
> > the archive is being *added* to the output file [*].
> >
> > - code for all symbols in the archive;
> > - code for those object members in the archive which hold symbols that
> > are still unresolved;
> > - code for only those specific symbols that are still unresolved;
> > - ... something else ?
>
> For each symbol which is undefined when the linker sees the archive,
> for which a definition is provided by the archive, the linker will
> include the complete object file which defines the symbol. If
> including an object file causes the linker to see new undefined
> symbols, the linker will check to see whether those symbols are
> defined in the archive, and for each such symbol will include the
> object file which defines it. This process is repeated until there
> are no new undefined symbols which can be satisfied by the archive.
>
> Ian
>
>