Bug#345378: glibc: __libc_atexit section disappears with --gc-sections, breaking exit-flushing
Package: glibc
Severity: normal
Hi,
when a program is linked with the --gc-sections linker option,
the __libc_atexit section in the final binary disappears. As a
consequence the flushing on exit does not work.
$ cat x.c
#include <stdlib.h>
#include <stdio.h>
int main(void) { printf("blah\n"); exit(0); }
$ gcc -static -W -Wall -o x x.c
$ objdump -h x | grep __libc_atexit
6 __libc_atexit 00000004 080add30 080add30 00065d30 2**2
$ ./x | cat
blah
$ gcc -Wl,--gc-sections -static -W -Wall -o x x.c
$ objdump -h x | grep __libc_atexit
$ ./x | cat
$
The __libc_atexit section contains a reference to the _IO_cleanup
function in glibc which flushes all streams.
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Adam
--
Adam adam@os.inf.tu-dresden.de
Lackorzynski http://os.inf.tu-dresden.de/~adam/
Reply to: