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: KEEP sections without writing a complete linker script?


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.


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