This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: static link with gold + gc-sections does not flush stdout buffer to file.
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 5 Jan 2010 07:49:43 -0800
- Subject: Re: static link with gold + gc-sections does not flush stdout buffer to file.
- References: <863b0cbf1001041702w23a587cdubf8e6d7fecfcb20b@mail.gmail.com>
On Mon, Jan 4, 2010 at 5:02 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> Hi,
>
> Here is how to reproduce the bug :
>
> $ cat hello.cc
> #include <stdio.h>
> int main()
> {
> ?printf("Hello World\n");
> }
>
> $ gcc hello.cc -static -Wl,--gc-sections
> $ ./a.out > tt.out
> $ wc tt.out
> 0 0 0 tt.out
>
>
> Also, this bug is present in GNU ld. Will file a bug for this.
>
> Looking at the sections discarded shows the following :
>
> ld: removing unused section from '__libc_atexit' in file
> '/usr/grte/v1/lib/../lib64/libc.a(genops.o)'
> ld: removing unused section from '__libc_freeres_fn' in file
> '/usr/grte/v1/lib/../lib64/libc.a(register-atfork.o)'
> ld: removing unused section from '__libc_subfreeres' in file
> '/usr/grte/v1/lib/../lib64/libc.a(register-atfork.o)'
> ld: removing unused section from '__libc_freeres_fn' in file
> '/usr/grte/v1/lib/../lib64/libc.a(dcigettext.o)'
>
> Out of these, removing __libc_atexit is responsible for this behaviour
> as it registers __IO_cleanup which flushes the buffer. Also, to me, it
> looks like the other symbols with __libc prefix are also important.
>
> Here is a patch to make gc-sections not delete sections prefixed with
> __libc and this fixes the problem.
>
>
> 2010-01-04 ?Sriraman Tallam ?<tmsriram@google.com>
>
> ? ? ? ?* object.cc (Relobj::is_section_name_included): Keep sections whose
> ? ? ? ?names begin with "__libc" from being discarded by gc-sections.
>
The fix is wrong. Please see my comments at
http://sourceware.org/bugzilla/show_bug.cgi?id=11133
--
H.J.