Here is how to reproduce. Using ld with binutils 2.19. $ cat hello.cc #include <stdio.h> int main() { printf("Hello World\n"); } $ gcc-4.4.0 hello.cc -static -Wl,--gc-sections $./a.out > hello.out $ wc hello.out 0 0 0 hello.out
Using, --print-gc-sections shows that : ld: removing unused section from '__libc_atexit' in file 'libc.a(genops.o)' ld: removing unused section from '__libc_freeres_fn' in file 'libc.a(register-atfork.o)' ld: removing unused section from '__libc_subfreeres' in file 'libc.a(register-atfork.o)' ld: removing unused section from '__libc_freeres_fn' in file 'libc.a(dcigettext.o)' ... Removing __libc_atexit was responsible for this behaviour. -- Summary: Static linking with gc-sections deletes __libc_atexit causing problems with stdio buffer flush to file. Product: binutils Version: 2.19 Status: NEW Severity: normal Priority: P2 Component: binutils AssignedTo: unassigned at sources dot redhat dot com ReportedBy: tmsriram at google dot com CC: bug-binutils at gnu dot org GCC build triplet: x86_64 GCC host triplet: x86_64 GCC target triplet: x86_64 http://sourceware.org/bugzilla/show_bug.cgi?id=11133 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils