.bss section and uninitialised variables
Ian Lance Taylor
ian@airs.com
Wed Dec 22 15:55:00 GMT 2004
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
More information about the Gcc
mailing list