[Gold] Can't we specify input files & libraries in linker scripts ?
Cary Coutant
ccoutant@google.com
Tue Aug 13 16:34:00 GMT 2013
> 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.)
-cary
More information about the Binutils
mailing list