This is the mail archive of the
mailing list for the binutils project.
Re: [Gold] Can't we specify input files & libraries in linker scripts ?
- From: Cary Coutant <ccoutant at google dot com>
- To: Shawn <shaolin dot xie at ia dot ac dot cn>
- Cc: Ian Lance Taylor <iant at google dot com>, Triple Yang <triple dot yang at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Tue, 13 Aug 2013 09:34:17 -0700
- Subject: Re: [Gold] Can't we specify input files & libraries in linker scripts ?
- References: <52085333 dot 4090909 at ia dot ac dot cn> <CAHACq4qvEsi1Lc4+jT9SGJCV6duX=KJFF7YLr3HP5vyV1_Qs8A at mail dot gmail dot com> <52098505 dot 6070309 at ia dot ac dot cn>
> Thanks, cary, It's ok to put the input files & libraries on the command
> line, but it's inconvenient to the end user, such as :
> ld.gold crt0 -lm -lc -lgloss_mspu -lcompiler_rt inputfile.o
These extra files are usually provided by the compiler driver (e.g.,
gcc). It's uncommon to run the linker directly except when building
kernels and other embedded applications.
Libraries should typically follow the application's object files. For
archive libraries in particular, they must follow any objects that
reference them, or the linker will pull nothing out of them. In
general, the link command line should be ordered so that if A has a
reference to a symbol in B, A precedes B on the command line. If the
compiler driver provide the standard libraries, it can put them in the
correct order relative to the application's object files.
> If we can specify the default files & libraries(such as crt0, -lc,
> -lgloss_mspu -lcompiler_rt) in a linker script, say script.ld, it will be
> more concise:
> ld.gold -T script.ld inputfile.o
Gold, unlike Gnu ld, was designed to avoid the need for any linker
script for normal applications. I wouldn't recommend this approach.
But as I said, if you just leave off the -T option and put your script
as a regular input file, it should work. (On Linux, for example,
libc.so isn't actually a library -- it's a script file that points to
a group of separate object files.)