[ECOS] compile error when using newer version ecos configuration tool

J. J. Farrell jjf@abaqos.com
Wed Nov 7 06:31:00 GMT 2001


On Tue, Nov 13, 2001 at 07:46:38PM -0700, Trenton D. Adams wrote:
>
> So, what you're saying is that BSS is infact for uninitialized
> variables?  Because of the fact that the BSS section is initialized to
> 0, the uninitialized variables become initialized?

One thing to get clear is that there is no such thing as an
uninitialized global variable in C. If the code does not
explicitly initialize a global variable, C guarantees that
it will be initialized as if there were an explicit '= 0'
initialization. For most objects in most C implementations
this means that the memory for the object should be zeroed.
How this is achieved is up to the compiler.

All object file formats I know of have a way of specifying
that an object should have memory allocated for it without
including data in the file to initialize that object. This
is an optimization to reduce the size of the object file.
The section containing these objects is often called BSS.

The ELF and PE specifications say that the memory for this
section will always be zeroed as the program is loaded.
These formats don't support the idea of uninitialized data
in the program memory image.

When targeting ELF or PE (or similar formats) a compiler
can minimize the size of the object file by placing all
writable static and global variables whose memory needs
to be zeroed into a BSS segment. It doesn't matter if
these variables are explicitly initialized in the code,
or implicitly initialized by the language definition.

If an object file format has uninitialized data and doesn't
automatically zero it when loading, a C compiler can still
use BSS in the same way if it links in some startup code
which zeroes the BSS segment after the program has been
loaded but before the compiled code is entered.

In summary:
- C doesn't have uninitialized global variables;
- the BSS section does not include initialization data
  in the object file;
- the BSS section is often used by C compilers to hold
  global and static variables whose memory must be
  initialized to zero when the program is loaded. It can
  either rely on the loader to zero the BSS memory, or
  can link in a piece of startup code to do it.



More information about the Ecos-discuss mailing list