This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Specifiying alternatives to .data .bss in C source files
- From: Ian Lance Taylor <iant at google dot com>
- To: Jeff Lasslett <jeff dot lasslett at datataker dot com dot au>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 31 Aug 2006 08:57:07 -0700
- Subject: Re: Specifiying alternatives to .data .bss in C source files
- References: <44F68A2C.5020907@datataker.com.au>
Jeff Lasslett <jeff.lasslett@datataker.com.au> writes:
> The old diab compiler that I am in the process of replacing with GCC supports
> the following ...
>
> // preserve variables across wakeup
> #pragma section DATA ".dataW" ".bssW" far-absolute
> #pragma section SDATA ".sdataW" ".sbssW" far-absolute
>
> ... which causes the compiler to put stuff normally destined for .data, .bss,
> .sdata and .sbss into different input sections (.dataW, .sdataW, .bassW,
> .sbssW).
>
> We do this because our hardware can start cold, or warm, or 'wake from sleep'
> and we don't always want to initialise variables.
>
> Could someone please advise me as to how I can get GCC to do the same thing?
gcc does not provide a mechanism for changing the default for all
variables in a compilation. You can use __attribute__ ((section
(NAME))) for specific variables. See the gcc documentation for
details.
You can use a linker script to move variable sections around on an
object file by object file basis. See the linker documentation for
details.
Ian