This is the mail archive of the
mailing list for the binutils project.
extern declared variable present in bss section of dynamic executable
- From: kamlesh kumar <kamleshbhalui at gmail dot com>
- To: binutils at sourceware dot org, amodra at gmail dot com
- Date: Fri, 26 Jul 2019 18:57:48 +0530
- Subject: extern declared variable present in bss section of dynamic executable
consider below test case,
$gcc -shared -fpic shared.c -o libshared.so
extern int var;
$gcc test.c -L. -lshared -Wl,-rpath=`pwd`
It prints correct ouput.
But below observation looks littile strange,Digging into linker but like to
know your thought as well.
$ nm ./a.out | grep var
0000000000402030 B var
$ nm libshared.so | grep var
0000000000002018 D var
Global variable var is present in data section that is ok.
why global variable var is present in bss section of dynamic
executable,while it should be undefined?