possible to have some C variables uninitiialized?

Palmer.Chris PalmerC@intgame.com
Sat Apr 1 00:00:00 GMT 2000


Paul,
	The manual appears to be misleading. I have found that it works with
uninitialised variables as well.  However, if you mix uninitialised and
initialised in the same section, you end up with zero initialisers for the
uninitialised variables. This is the same as for normal unitiliased
variables that go in the .bss section, but that section is normal not loaded
into PROM, it is just cleared.

Chris

> -----Original Message-----
> From:	Paul Andrews [SMTP:paul.andrews@smartmove.co.nz]
> Sent:	Wednesday, January 19, 2000 2:16 AM
> To:	crossgcc@sourceware.cygnus.com
> Subject:	RE: possible to have some C variables uninitiialized?
> 
> Does anyone know why the section attribute only works on initialised
> variables? The manual says it's because of the way the linker works but
> the
> explanation is a bit lost on me...
> 
> -----Original Message-----
> From: Jeff Mock [ mailto:jeff@mock.com ]
> Sent: Wednesday, 19 January 2000 2:48 PM
> To: Scott A Sumner; crossgcc@sourceware.cygnus.com;
> ColdFire@WildRice.com
> Subject: 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
> 
> ------
> 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



More information about the crossgcc mailing list