This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: .bss section and uninitialised variables
- From: Ian Lance Taylor <ian at airs dot com>
- To: Gisle Grimen <grimen at idi dot ntnu dot no>
- Cc: gcc at gcc dot gnu dot org
- Date: 22 Dec 2004 10:53:39 -0500
- Subject: Re: .bss section and uninitialised variables
- References: <Pine.GSO.4.60.0412221343280.16660@selje.idi.ntnu.no>
Gisle Grimen <grimen@idi.ntnu.no> writes:
> I am not an expert on linux or gcc, but i was wondering about one
> thing with variables and .bss section.
This question is more appropriate for gcc-help, I think.
> You have an relocatable elf file(.o) generated with gcc (3.3.5). My
> question is why the variable defined myvar (se simple src below) is
> not included in the .bss section so that it will be initialized to 0;
In C, an uninitialized symbol will normally be marked as a common
symbol. If no other definition is seen for the symbol, the linker
will put it in the .bss section of the executable. See the
-fno-common gcc option or the --warn-common linker option. The latter
has a complete description of common symbols.
Ian