This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: .bss section and uninitialised variables


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


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