KEEP sections without writing a complete linker script?

Tristan Gingold gingold@adacore.com
Fri Jun 18 07:56:00 GMT 2010


On Jun 17, 2010, at 7:54 PM, Lars Noschinski wrote:

> * Tristan Gingold <gingold@adacore.com> [10-06-17 18:12]:
>>>>> | /usr/lib/gcc/avr/4.3.4/../../../avr/bin/ld: warning: keep_bootcall.x contains output sections; did you forget -T?
>>> [...]
>>>> How did you invoke gcc or ld ?  It seems, according to the error message, that you forget the -T switch.  Ie, you
>>>> should use something like -Wl,-T,myscript.ld
>>> 
>>> Using -T would give me not the effect I wanted, as this would replace
>>> the default linker script.
>> 
>> Ok, you can use -Wl,-dT,-T,myscript.ld to also read the default linker script.
> 
> This won't work either, as -dT also expects a file name as parameter.

Yes, sorry.

> But after re-reading the documentation, if found that the INSERT command
> does exactly what I want:
> 
> Using the script
> 
> | SECTIONS
> | {
> |   .bootcall_trampoline :
> |   {
> |     KEEP(*(.bootcall_trampoline))
> |   }
> | }
> | INSERT AFTER .text
> 
> I may call the linker with "-T myscript.ld" and everything works as
> expected.

Right, this seems indeed to be the best method.

Tristan.



More information about the Binutils mailing list