public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] C variables in sections
@ 2000-01-19 15:49 will
  2000-01-19 16:06 ` Robin Kirkham
  0 siblings, 1 reply; 2+ messages in thread
From: will @ 2000-01-19 15:49 UTC (permalink / raw)
  To: ecos-discuss

   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.

Thanks,
Will

PS- I'm new to the GCC cross-compiler (so hopefully this mail
 is to the right place..).

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] C variables in sections
  2000-01-19 15:49 [ECOS] C variables in sections will
@ 2000-01-19 16:06 ` Robin Kirkham
  0 siblings, 0 replies; 2+ messages in thread
From: Robin Kirkham @ 2000-01-19 16:06 UTC (permalink / raw)
  To: will; +Cc: ecos-discuss

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-01-19 16:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-19 15:49 [ECOS] C variables in sections will
2000-01-19 16:06 ` Robin Kirkham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).