This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Re: possible to have some C variables uninitiialized?


Ooo, I know this one.

There's a GCC extension to place data items in sections other than data and 
bss.
You can declare a data item like this:

    int foo __attribute__ ((section ("BATTERY"))) = 23;

The section BATTERY needs to be put someplace at link time so you write your
own ld script, which isn't hard, I learned how to do it last week.  A couple of
hours of fiddling after reading 'info ld' and you'll know the whole deal.
Depending on how the battery backed up memory gets initialized the first time
you might need to use the "AT" command in the ld script to store the 
initialized
data in ROM but locate the addresses in the special memory.

jeff




At 03:44 PM 1/18/00 , Scott A Sumner wrote:
>I'm using gcc on a 68000-based embedded system that has some normal RAM
>and some battery-backed RAM.  I'd like to know if there is a way to have
>the gcc compiler/linker not initialize certain C variables that will be
>located in the battery-backed RAM area.
>
>I'd like these global variables to be declared normally, for example,
>
>int IAmANonVolatileInt = 3;
>
>but I don't want them lumped in with the normal global variables that
>will get initialized to either 0 or to a certain value on powerup of the
>embedded system.
>
>I could cheat and do the following:
>
>#define BATTERY_BACKED_RAM_ADDRESS (0x800000)
>#define IAmANonVolatileInt (*(int *)BATTERY_BACKED_RAM_ADDRESS)
>
>but I'd rather not.
>
>
>Any ideas on how to accomplish this?  An example would be great, too!
>
>------
>Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
>Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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