> In your test case as written there should not be any such section in > file.s. file.h only includes header.h, and does not actually define > any variables at all. > > The section group symbol looks right to me--the guard variable should > be associated with the variable it is guarding, it shouldn't be in its > own group. > This is the content of file.s .file "file.cpp" .weak _ZGVZN1A4InitEvE1i .section .bss._ZGVZN1A4InitEvE1i,"awG",@nobits,_ZZN1A4InitEvE1i,comdat .align 8 .type _ZGVZN1A4InitEvE1i, @object .size _ZGVZN1A4InitEvE1i, 8 _ZGVZN1A4InitEvE1i: .zero 8 .ident "GCC: (GNU) 4.5.0 20091006 (experimental)" .section .note.GNU-stack,"",@progbits when compiled with older gcc, the only (apart from .ident) line changed is .section .bss._ZGVZN1A4InitEvE1i,"awG",@nobits,_ZGVZN1A4InitEvE1i,comdat so I thought _ZGVZN1A4InitEvE1i is correct there. > If that is writing to NULL, it suggests that _ZZN1A4InitEvE1i > (A::Init()::i) was somehow never defined. What do you see for that > symbol using readelf -s on the executable and on the input object > files? When compiled with gcc-4.5, command line "g++ file.o main.o -o a.out" $ readelf -s file.o | grep ZZN1A4InitEvE1i $ readelf -s main.o | grep ZZN1A4InitEvE1i 25: 0000000000000000 8 OBJECT WEAK DEFAULT 16 _ZZN1A4InitEvE1i $ readelf -s a.out | grep ZZN1A4InitEvE1i 62: 0000000000000000 0 OBJECT WEAK DEFAULT UND _ZZN1A4InitEvE1i (this one crashes) gcc-4.5, command line "g++ main.o -o a.out" or "g++ main.o file.o -o a.out" $ readelf -s a.out | grep ZZN1A4InitEvE1i 49: 0000000000601068 8 OBJECT WEAK DEFAULT 26 _ZZN1A4InitEvE1i When compiled with gcc-4.3: $ readelf -s file.o | grep ZZN1A4InitEvE1i $ readelf -s main.o | grep ZZN1A4InitEvE1i 27: 0000000000000000 8 OBJECT WEAK DEFAULT 17 _ZZN1A4InitEvE1i $ readelf -s a.out | grep ZZN1A4InitEvE1i 49: 0000000000601068 8 OBJECT WEAK DEFAULT 26 _ZZN1A4InitEvE1i Zdenek