This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
.bss section and uninitialised variables
- From: Gisle Grimen <grimen at idi dot ntnu dot no>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 22 Dec 2004 14:01:55 +0100 (MET)
- Subject: .bss section and uninitialised variables
hello,
I am not an expert on linux or gcc, but i was wondering about one thing
with variables and .bss section.
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;
What happens is that i find a relocation entry and a symboltable entry for
the variable, but it is not defined a section to which it belongs. If you
initialize the variable with 0 (int myvar=0;) then everything is ok and it
get put in the .bss section.
As i said i am not an expert in gcc and c, but does c allow such
"undefined" variables? Java which i have much more experience with i know
would initialise myvar with a 0 for me.
#src
# include <stdio.h>
int myvar;
int main(void){
printf("hello");
}
-Gisle