This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Re: C variables in sections
- To: will <will_lentz at Trimble dot COM>
- Subject: Re: [ECOS] C variables in sections
- From: Robin Kirkham <Robin dot Kirkham at cmst dot csiro dot au>
- Date: Thu, 20 Jan 2000 11:05:48 +1100
- Cc: ecos-discuss at sourceware dot cygnus dot com
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