When is /usr/lib/ldscripts/* used?
Ian Lance Taylor
Thu Apr 24 00:39:00 GMT 2008
Goswin von Brederlow <email@example.com> writes:
> under Debian the binutils package contains linker scripts like
> mrvn@frosties:~% cat /usr/lib/ldscripts/elf_i386.x
> /* Default linker script, for normal executables */
> OUTPUT_FORMAT("elf32-i386", "elf32-i386",
> SEARCH_DIR("/usr/i386-linux-gnu/lib32"); SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32"); SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i386-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
> but when I strace a gcc or ld run the most I see is a
> stat("/usr/lib/ldscripts"). ld never opens any of those linker
> How do these scripts work if nothing ever uses them? I know they do
> get generated during build but what for?
At this point they are essentially documentation, a convenient source
for you to modify when writing your own linker script. At one time
they were read from the file system, but to speed up linking the
default scripts are now part of the linker (you can see the built-in
linker script with the --verbose option). In cases where the linker
supports multiple emulations, it will still read linker scripts for
the non-default emulation from that directory.
More information about the Binutils