This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: KEEP sections without writing a complete linker script?
- From: Tristan Gingold <gingold at adacore dot com>
- To: Lars Noschinski <lars at public dot noschinski dot de>
- Cc: binutils at sourceware dot org
- Date: Thu, 17 Jun 2010 15:28:56 +0200
- Subject: Re: KEEP sections without writing a complete linker script?
- References: <20100617131504.GA14837@lars.home.noschinski.de>
On Jun 17, 2010, at 3:15 PM, Lars Noschinski wrote:
> Hi,
>
> is there a way to explicitely KEEP a section without needing to write a
> whole new linker file?
>
> It seemed to me that using a script which is appended to the default
> script is a way to go, so I wrote the following script:
>
> | SECTIONS
> | {
> | .bootcall_trampoline :
> | {
> | *(.bootcall_trampoline)
> | KEEP(*(.bootcall_trampoline))
> | }
> | }
>
> This seems to work, but gives me the annoying warning
>
> | /usr/lib/gcc/avr/4.3.4/../../../avr/bin/ld: warning: keep_bootcall.x contains output sections; did you forget -T?
>
> So I have got two questions:
>
> - Is my approach correct?
> - If yes, can this warning be suppressed?
Let me try to answer:
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
Your script looks strange: you shouldn't repeat the input section. I think that written as is the second line has no effect.
You should use something like:
SECTIONS
{
.bootcall_trampoline :
{
KEEP(*(.bootcall_trampoline))
}
}
Tristan.