[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/3315] New: ld --gc-sections *.o produces big(ger than poss
From: |
vda dot linux at googlemail dot com |
Subject: |
[Bug binutils/3315] New: ld --gc-sections *.o produces big(ger than possible) executables |
Date: |
6 Oct 2006 15:47:15 -0000 |
Basically, I compile an executable from same set of source files.
First I compile .c modules into .o with -ffunction-sections
-fdata-sections, and then I can do something a-la
"gcc -o executable -Wl,--gc-sections *.o"
or I can bundle almost all .o files into lib.a using ar and do
"gcc -o executable -Wl,--gc-sections main.o lib.a"
The second method gives much better results:
# size */busybox
text data bss dec hex filename
14186 868 24 15078 3ae6 busybox.1.t/busybox
2682 304 24 3010 bc2 busybox.2.t/busybox
However, there is no reason to believe that all is good now.
I tent to fear than suboptimal link-time dead code elimination
is still happening, only on lesser scale (within each individual .o file
pulled from lib.a, not over whole set of .o files).
Extended explanation is at http://busybox.net/~vda/Kbuild_new_2006/
I will attach objdump -xsdr of both executables.
comparing those, I see:
* extra EH_FRAME section
* sections .hash, .dynstr, .dynsym,.... are much longer
Unstripped executables also available for comparison at the above URL.
One thing has been tracked down to this test case:
/* Compile:
** gcc -ffunction-sections -fdata-sections -c -o test.o test.c
** gcc -o test -Wl,--gc-sections test.o
**
** First call to notexist() is optimized away by linker because
** function eliminated() is, er, eliminated by section GC.
**
** But second call to notexist() is not optimized away,
** despite the fact that getpwnam_r() is not called from anywhere.
** Then linking fails because notexist() isn't exist.
**
** Renaming getpwnam_r to any other name "fixes" this! */
void notexist(void);
int main(void) { return 0; }
void eliminated(void) { notexist(); }
void getpwnam_r(void) { notexist(); } // HERE
Rest are not researched in depth.
--
Summary: ld --gc-sections *.o produces big(ger than possible)
executables
Product: binutils
Version: 2.17
Status: NEW
Severity: normal
Priority: P2
Component: binutils
AssignedTo: unassigned at sources dot redhat dot com
ReportedBy: vda dot linux at googlemail dot com
CC: bug-binutils at gnu dot org
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=3315
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
- [Bug binutils/3315] New: ld --gc-sections *.o produces big(ger than possible) executables,
vda dot linux at googlemail dot com <=