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]

.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



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