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] |
On Tue, 18 Jan 2000, Scott A Sumner wrote: > Date: Tue, 18 Jan 2000 18:44:33 -0500 > From: Scott A Sumner <sasumner@juno.com> > To: crossgcc@sourceware.cygnus.com, ColdFire@WildRice.com > Subject: possible to have some C variables uninitiialized? > > 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. > One way that I can think of is to put those variables in a separate section, say ".uninit", and then put the '(NOLOAD)' option for this section in your linker script. By doing this, the linker will compute the correct relocation address without loading the section into the battery-backed RAM. The following template of linker script may help you: ... MEMORY { NormalRAM: ORIGIN = ....., LENGTH = .... BattRAM : ORIGIN = ....., LENGTH = .... } SECTIONS { ... other sections [.text, .data. ,bss, ....] here .uninit (NOLOAD) : { ...... } >BattRAM } .... > 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 > -- Hans Dulimarta, Ph.D. dulimart@[egr.msu.edu, computer.org] http://www.egr.msu.edu/~dulimart Visiting Research Associate, Electrical & Computer Engineering Michigan State University, East Lansing, MI 48824, (517) 432-7589 ------ 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] |