public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] stacks as globel char[]
@ 1999-05-07  0:02 Andrew Lunn
  1999-05-07  4:11 ` [ECOS] " Bart Veer
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Lunn @ 1999-05-07  0:02 UTC (permalink / raw)
  To: ecos-discuss

This question comes out of ignorance as to how the compiler/loader works.

In the example code you have the stacks as a global char
stack[x][y]. Is this a good idea for real applications? The same
applies to memory for memory pools etc.

Im thinking about code that is for a ROM, or downloading over a serial
line. If i looked at this code would i find lots of zeros which are
the stack and memory for the pool, or are these variables created
during run time startup? 

	Thanks
		Andrew

----------------------------------------------------------------------
Dr Andrew Lunn		Phone: +41 62 889 5297
ASCOM Systec AG		Fax:   +41 62 889 5290
Gewerberpark		Email: Andrew.Lunn@ascom.ch
CH-5506 Magenwil
Switzerland
----------------------------------------------------------------------

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

* [ECOS] Re: stacks as globel char[]
  1999-05-07  0:02 [ECOS] stacks as globel char[] Andrew Lunn
@ 1999-05-07  4:11 ` Bart Veer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Veer @ 1999-05-07  4:11 UTC (permalink / raw)
  To: lunn; +Cc: ecos-discuss

>>>>> "Andrew" == Andrew Lunn <lunn@ma.tech.ascom.ch> writes:

    Andrew> This question comes out of ignorance as to how the
    Andrew> compiler/loader works. In the example code you have the
    Andrew> stacks as a global char stack[x][y]. Is this a good idea
    Andrew> for real applications? The same applies to memory for
    Andrew> memory pools etc.

    Andrew> Im thinking about code that is for a ROM, or downloading
    Andrew> over a serial line. If i looked at this code would i find
    Andrew> lots of zeros which are the stack and memory for the pool,
    Andrew> or are these variables created during run time startup?

Uninitialized data like

  char stacks[x][y];

ends up in the bss segment rather than the data segment. During
startup the system will automatically zero the entire bss segment.
There is no need to transfer lots of zeroes down the serial line or to
store them anywhere in the executable image.

If the code were changed to something like:

  char stacks[x][y] = { '1' };

then the entire array would end up in the data segment and would
appear in the executable. In case of doubt it is fairly easy to be
sure: simply compile a code snippet to a .o file and either just look
at the size of the output file or use powerpc-eabi-objdump -d for a
disassembly.

Bart Veer // eCos net maintainer

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

end of thread, other threads:[~1999-05-07  4:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-07  0:02 [ECOS] stacks as globel char[] Andrew Lunn
1999-05-07  4:11 ` [ECOS] " Bart Veer

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).