I would like to report a probable gcc compiler bug that is to present on AIX 5.3, but not on x86 linux. The problem is that Totalview and gdb fail to see a static value 'stupify' when the program is compiled and linked using gcc 4.1.1.
If I cross link and compile (e.g. compile using gcc and link using xlc 8.0.0.0), things do not work if the compilation is done using gcc. Things do work if I compile using xlc and then link using gcc (or use xlc for both). This makes us suspect that this is a compiler problem specific to AIX OS: the gcc compiler apparently creates an .o file that is not anymore understandable to the linker (more details below). Compiler + Linker gcc + gcc FAIL gcc + xlc FAIL xlc + xlc OK xlc + gcc OK Below please find the dump info related to two pure cases: gcc+gcc and xlc+xlc, compilation and linking respectively. It seems to me that in the gcc case, the final executable (see gcc_gcc_dump) has incorrect/undefined type declaration (unamex), whereas the xlc version has the type of stupify as 'stsym' which sounds right to me? Our internal code for this bug is #10494. More details below: XXXXXXXXXXXXXXXXXXXXXXXXXXX # AIX 5.3 # compilation /home/compilers/gnu/gcc/4.1.1/rs6000_5.3/bin/gcc -g -c -o file_static.o file_static.c # linking /home/compilers/gnu/gcc/4.1.1/rs6000_5.3/bin/gcc -g -o file_static file_static.o #-> 5.3, and gcc 4.1.1 does NOT WORK objdump --syms ./file_static.o | grep stupify dump -tv ./file_static | grep stupify # AIX 5.3 # compilation /home/compilers/ibm/c++/8.0.0.0/rs6000_5.3/usr/vac/bin/xlc -g -c -o file_static.o file_static.c # linking /home/compilers/ibm/c++/8.0.0.0/rs6000_5.3/usr/vac/bin/xlc -g -o file_static file_static.o #-> 5.3, and xlc 8.0.0.0 works objdump --syms ./file_static.o | grep stupify dump -tv ./file_static | grep stupify In the latter case both Totalview and gdb see the variable 'stupify', whereas with gcc compilation and linking, the symbol is not available to the debuggers. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX On older versions of gcc, we see the following: On AIX 5.1, gcc 3.2.3 works, but 3.3.3 does not: gcc V3.2.3 compiles file_static.c into an object file containing both: 1. A hidden external CSECT definition for ``stupify'' in the TOC, pointing to 4 anonymous bytes in BSS. -and- 2. An initialized per-module static variable debug symbol for ``stupify''. gcc V3.3 generates the same two symbols (although it denotes the COMMON block containing ``stupify''s actual storage in a subtly different fashion). However, when the V3.2.3 object file is linked, the a.out file preserves both ``stupify''s CSECT definition, *and* its debug symbol, while when the V3.3 object file is linked, the a.out file does not contain ``stupify''s debug symbol. This is true whether the object files in question are linked via by the compiler driver gcc (3.2.3, 3.3 or 4.1.1), or IBM xlc. The difference in symbols between the two executables may stem from linker handling of the COMMON storage for ``stupify''. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file_static.c: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> static unsigned long int stupify = 0; void a(void) { if (!stupify) { unsigned long int t = 0; stupify = 256 * 1024 * 1024; t = stupify; printf("s = %lu, t = %lu\n",stupify,t); } } main() { a(); printf("hello, world\n"); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The key segments of the symbol info look like as follows gcc compilation and linking:: chrome:/home/seppo/Bugs/Bug_10494 > grep -A 3 -B 3 stupify gcc_gcc_objdump.txt [259](sec 1)(fl 0x00)(ty 0)(scl 101) (nx 1) 0x00000138 .ef AUX lnno 19 size 0x0 tagndx 0 [261](sec 1)(fl 0x00)(ty 0)(scl 143) (nx 0) 0x0000010a .bs [262](sec -2)(fl 0x00)(ty 0)(scl 133) (nx 0) 0x00000000 stupify:S-10 [263](sec 1)(fl 0x00)(ty 0)(scl 144) (nx 0) 0x00000000 .es [264](sec 1)(fl 0x00)(ty 0)(scl 107) (nx 1) 0x00000150 _filestatic.rw_ AUX val 33 prmhsh 0 snhsh 0 typ 1 algn 3 clss 1 stb 0 snstb 0 -- AUX val 4 prmhsh 0 snhsh 0 typ 1 algn 3 clss 5 stb 0 snstb 0 [280](sec 2)(fl 0x00)(ty 0)(scl 107) (nx 1) 0x000001a4 TOC AUX val 0 prmhsh 0 snhsh 0 typ 1 algn 2 clss 15 stb 0 snstb 0 [282](sec 2)(fl 0x00)(ty 0)(scl 107) (nx 1) 0x000001a4 stupify AUX val 4 prmhsh 0 snhsh 0 typ 1 algn 2 clss 3 stb 0 snstb 0 [284](sec 2)(fl 0x00)(ty 0)(scl 107) (nx 1) 0x000001a8 LC..1 AUX val 4 prmhsh 0 snhsh 0 typ 1 algn 2 clss 3 stb 0 snstb 0 chrome:/home/seppo/Bugs/Bug_10494 > grep -A 3 -B 3 stupify gcc_gcc_dump.txt [49] a4 0x00000004 0 0 SD TC 0 0 [50] m 0x20000e04 .data 1 unamex __strtollmax [51] a4 0x00000004 0 0 SD TC 0 0 [52] m 0x20000e08 .data 1 unamex stupify [53] a4 0x00000004 0 0 SD TC 0 0 [54] m 0x20000e0c .data 1 unamex LC..1 [55] a4 0x00000004 0 0 SD TC 0 0 xlc compilation and linking:: chrome:/home/seppo/Bugs/Bug_10494 > grep -A 3 -B 3 stupify xlc_xlc_objdump.txt [ 66](sec 2)(fl 0x00)(ty 0)(scl 107) (nx 1) 0x00000108 _$STATIC AUX val 4 prmhsh 0 snhsh 0 typ 1 algn 2 clss 5 stb 0 snstb 0 [ 68](sec -2)(fl 0x00)(ty 0)(scl 143) (nx 0) 0x00000042 .bs [ 69](sec -2)(fl 0x00)(ty 0)(scl 133) (nx 0) 0x00000000 stupify:V-10 [ 70](sec -2)(fl 0x00)(ty 0)(scl 144) (nx 0) 0x00000000 .es [ 71](sec 2)(fl 0x00)(ty 0)(scl 107) (nx 1) 0x000000e4 _$STATIC AUX val 4 prmhsh 0 snhsh 0 typ 1 algn 2 clss 3 stb 0 snstb 0 chrome:/home/seppo/Bugs/Bug_10494 > grep -A 3 -B 3 stupify xlc_xlc_dump.txt [140] m 0x20000580 .data 1 unamex _$STATIC [141] a4 0x00000004 0 0 SD RW 0 0 [142] m 0x0000008c debug 0 bstat .bs [143] m 0x00000000 debug 0 stsym stupify:V-10 [144] m 0x00000000 debug 0 estat .es [145] m 0x000000a2 debug 0 FILE ASM:COM dbxxx.s [146] m 0x10000488 .text 1 extern .__dbsubc chrome:/home/seppo/Bugs/Bug_10494 > XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -- Summary: gcc 4.1.1 on AIX - gdb and TV fail to see static value due to likely gcc compiler bug Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: debug AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: seppo at totalviewtech dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33740