[ECOS] C variables in sections
Robin Kirkham
Robin.Kirkham@cmst.csiro.au
Wed Jan 19 16:06:00 GMT 2000
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
More information about the Ecos-discuss
mailing list