This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: When is /usr/lib/ldscripts/* used?


Goswin von Brederlow <goswin-v-b@web.de> 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",
>               "elf32-i386")
> OUTPUT_ARCH(i386)
> ENTRY(_start)
> 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");
> SECTIONS
> {
> ...
>
>
> 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
> scripts.
>
> 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.

Ian


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