This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: compile error when using newer version ecos configuration tool

[Get raw message]
On Tue, Nov 13, 2001 at 09:28:07AM +0100, Andrew Lunn wrote:
> On Mon, Nov 12, 2001 at 02:46:38PM -0700, Trenton D. Adams wrote:
> > 
> > Here's a quote from a Technical Article from MSDN ...
> > 
> > The size of the sections that the loader commits space for in the
> > virtual address space, but that don't take up any space in the disk
> > file. These sections don't need to have specific values at program
> > startup, hence the term uninitialized data. Uninitialized data usually
> > goes into a section called .bss.
> 
> It seems the ELF spec specifies the .bss section is initialized to
> zero. Where as what you say about PE is that the contents are not
> initialized. Something to remember when writing portable code!

This seems to be popping up on a few lists of late ...

The quoted article is misleading, and wrong for C. In C,
all global variables which are not explicitly initialized
are initialized by the system as if the definition included
a zero initializer '=0'. For most objects in most
implementations, this means the memory is set to binary
zero. These objects commonly go in the .bss section and
don't need any initialization information in the object
file. However, they must (and do) have the specific value
of binary 0 at program startup - the loader zeroes the
.bss segment. Other articles in the MSDN explicitly state
that .bss gets initialized to 0 before the program starts
executing.

It is entirely portable to assume that uninitialized global
C variables will be initialized to zero.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]