ld version 2.18 introduced --print-gc-sections, and it seems
to have problem coexisting with --verbose.
This is what I see in the build log when I redirect both stdout and stderr to a
attempt to openx86_64-pc-linux-gnu-ld: Removing unused section
'.bss.Version_132631' in file 'init/built-in.o'
x86_64-pc-linux-gnu-ld: Removing unused section '.text.bad_intr' in file
x86_64-pc-linux-gnu-ld: Removing unused section '.text.do_device_not_available'
in file 'arch/x86_64/kernel/built-in.o'
x86_64-pc-linux-gnu-ld: Removing unused section '.text.check_tsc_unstable' in
x86_64-pc-linux-gnu-ld: Removing unused section '.bss.tr_table' in file
x86_64-pc-linux-gnu-ld: Removing unused section '.eh_frame' in file
attempt to open arch/x86_64/lib/built-in.o succeeded
"attempt to open lib/built-in.o succeeded" was printed to stdout,
and due to stdout being fully-buffered when redirected to a file,
it got split in mid-line by output to stderr here:
if (info->print_gc_sections && o->size != 0)
_bfd_error_handler (_("Removing unused section '%s' in file '%B'"),
The fix is to either make _bfd_error_handler() always do
fflush(stdout) internally before printing to stderr,
or to do setlinebuf(stdout) at the very beginning of ld's main().
Created attachment 1986 [details]
Flush stdout before emitting an error message
Flushing stdout before emitting the error/information message seems to be the
right thing to do. Please could you try out the uploaded patch and let me know
if it works for you.
Tested, works for me. Thanks!