From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Veer To: lunn@ma.tech.ascom.ch Cc: ecos-discuss@sourceware.cygnus.com Subject: [ECOS] Re: stacks as globel char[] Date: Fri, 07 May 1999 04:11:00 -0000 Message-id: <199905071110.MAA10183@sheesh.cygnus.co.uk> References: <199905070702.JAA09921@biferten.ma.tech.ascom.ch> <199905070702.JAA09921@biferten.ma.tech.ascom.ch> X-SW-Source: 1999-05/msg00027.html >>>>> "Andrew" == Andrew Lunn 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