This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: HELP with linker script!!!
- From: Nick Clifton <nickc at redhat dot com>
- To: Vincent Rubiolo <vincent dot rubiolo at windriver dot com>
- Cc: Pieter Arnout <pieter at powerescape dot com>, grigory dot zagorodnev at intel dot com, binutils at sources dot redhat dot com
- Date: Fri, 01 Apr 2005 15:02:07 +0100
- Subject: Re: HELP with linker script!!!
- References: <13ab0c503312082c7af572c83f523f4f@powerescape.com> <424BE5A7.5060902@redhat.com> <29c1ff0410ff9cc2b88a3ad82d1938aa@powerescape.com> <424D2F42.5070508@redhat.com> <424D4412.4020700@windriver.com>
Hi Vincent,
Thanks for this informative reply. There is something I am wondering
about using the gcc attributes to put variables or functions : how to
control the section flags of these new sections?
One way is by pre-declaring the section's name and attributes before
using it. Like this:
asm (".section .cached_bss, \"w\",@nobits");
int foo __attribute__((section (".cached_bss")));
The problem with this approach is that (with GCC 4.1 at least) you will
get warning messages from the assembler:
Warning: ignoring changed section type for .cached_bss
Warning: ignoring changed section attributes for .cached_bss
This is because GCC does not know that the asm() statement has already
defined the .cached_bss section and so it issues its own .section
directive. If you can live with the assembler warning that this method
will work.
The other way is hackier, but it avoids the warnings:
int foo __attribute__((section (".cached_bss,\"w\",@nobits#")));
This assumes that the hash character (#) is the start-of-line-comment
character for the particular instruction set you are using. If you have
a look at the assembler emitted by GCC you can see why:
.section .cached_bss,"w",@nobits#,"aw",@progbits
The hash stops GAS from interpreting the
,"aw",@probits
which gcc has appended to the name of the section...
Cheers
Nick