This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: Specifiying alternatives to .data .bss in C source files


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


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