Community
Participate
Working Groups
defines and exports a global variable in one shared library. then a executive accesses this global variable that exported by the previous shared library. when we debug the executive file through TCF, the global variable will be displayed correctly if in function that defines in executive itself; But the value of the global variable always displays the initialized value if in function that defines in shared library itself. for examples: --------------------------- sharedlib.c, this is the shared library source file: int slvar = 10; void fun_sl() { // ERROR: here the value of slvar variable is 10, it should be 100; slvar = 200; } --------------------------- executive.c, this is a sample executive file extern int slvar; extern void fun_sl(); int main() { slvar = 100; fun_sl(); // ERROR: here the value of slvar variable is 100, it should be 200; return 0; }
this issue only happens on ppc 32, and compilers/gnu-8.3.0.1/x86_64-linux2/bin/ccppcspe
the global variable that exported in a shared library will be allocated space both in .bss section in executive file and .data section in shared library. when the executive starts up, the initialized value will be copied to .bss section in executive file from the .data section in shared library. then all of access to the global variable should referenced to .bss section in executive. I think this issue happened is because the TCF reference the global variable to the .data section when debug into the function that defined in shared library. thanks Wenyan
BTW: when we are debugging the executive, we can see that the address of the global variable is in shared library address range in debugger.
This is caused by "copy relocations" - relatively obscure under-documented aspect of shared libraries implementation. GCC debug info for copy relocations is just plain wrong - the info should point to GOT instead of .data section. So, technically, it is a compiler bug. I have committed a workaround. Fixed. Thanks!