replacing the default linker script

Trevor Woerner
Wed Mar 6 18:52:00 GMT 2013


According to the ld documentation

"The linker always uses a linker script. If you do not supply one
yourself, the linker will use a default script that is compiled into
the linker executable."

If I am doing development with a device that is not running Linux (or
any other supported OS) (e.g. the ST Discovery board, or (I think) an
AVR32 device) then I find myself in a situation where I always have to
supply the linker script using the "-T" option whenever I am
performing the final link.

While I can find lots of people asking:
1. how to get ld to print the script it is using?
2. how do I provide my own script?
3. does -T replace or supplant the default script?

I can't seem to find any information on how feasible it would be to
provide my script to ld while it is being built so that it'll use my
script as the default so I don't have to provide it with the -T option
on every invocation.

Let's say I am putting together my own cross-development tools to
target a specific device, it would be nice if I could provide my
linker script in some way so that it could become the default script
that is used by my cross-ld tool.

When my cross-development tools are installed, I did notice that
there's a TARGET/sysroot/lib/ldscripts directory that gets created. In
my case it contains:


I was hoping that if I replaced one of them with my script that the
new script would get used by default. But that doesn't seem to be the

Any thoughts or advice?

Thanks and best regards,

More information about the Binutils mailing list