From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Kirkham To: will Cc: ecos-discuss@sourceware.cygnus.com Subject: Re: [ECOS] C variables in sections Date: Wed, 19 Jan 2000 16:06:00 -0000 Message-id: <20000120000548.15664.qmail@ragnarok.preston.cmst.csiro.au> References: <38864D7F.D4B91B62@trimble.com> X-SW-Source: 2000-01/msg00052.html On Wednesday, 19 January 2000, will wrote: > > Is there any way to put a C variable in a specific section > without having to initialize it? I found the following example > for initialed variables: > char stack[10000] __attribute__ ((section ("STACK"))) = { 0 }; > > When I leave off the initialization to 0, the variable no longer > appears in the appropriate section. I have some battery-backed > RAM that should not be cleared on startup. You need the initialisation because gcc/gld will only assign *initialised* data to a specfic section. However, this data will only be written when the program is *loaded* into the computer, as opposed to when it is first *run*. This is same as with the normal initialised data segement (usually called .data). So you can avoid overwriting data in your battery-backed RAM by instructing your program loader *not* to load section STACK (or whatever you called it). Hope this helps, Robin Kirkham CSIRO Manufacturing Science and Technology Project Engineer Locked Bag 9, Preston 3072, Australia robin.kirkham@cmst.csiro.au Phone: +61 3 9662-7756 Fax: +61 3 9662-7853