I'm trying to understand more about the "common" section of an executable and I noticed that when doing an objdump
on compiled code, I can see variables placed in the common code only on object files (*.o
) not on executables.
Why is that?
//test.c
int i[1000];
int main(){return 0;}
build command:
> gcc -g0 -fcommon -c test.c
> gcc -g0 -fcommon test.c
objdump
shows i
in the common section in the symbol table:
> objdump -x test.o
...
SYMBOL TABLE:
...
00000fa0 O *COM* 00000020 i
Unless I run it on the executable:
> objdump -x a.out
...
SYMBOL TABLE:
...
0804a040 g O .bss 00000fa0 i
If I rebuild the object file with the -fno-common
flag instead it shows up in the .bss
segment just like it does on the executable. Does the final executable not have this "COMMON" section?