When building a library in IMA mode, several used functions are optimized away:
gcc-4.1-HEAD -W -Wall -pedantic -funit-at-a-time -DPIC -fPIC -o liblib.o -c lib.c lib1.c lib2.c strip -x -R .note -R .comment liblib.o ar cr liblib.a liblib.o ld -shared --warn-common --warn-once -z combreloc -z defs -s -rpath . \ -soname=liblib.so -o liblib.so --whole-archive liblib.a --no-whole-archive -lc Do we have all of libmain, __func1, __func2 ? nm -D --defined-only liblib.so 00001260 A __bss_start 000011e4 A _DYNAMIC 00001260 A _edata 00001260 A _end 000001bc T __func2 gcc-4.1-HEAD -W -Wall -pedantic -I. test.c -o libtest -L. -llib /tmp/ccsGhigf.o: In function `main': test.c:(.text+0x43): undefined reference to `libmain' collect2: ld returned 1 exit status make: *** [libtest] Error 1 This would be the expected result: nm -D --defined-only liblib.so 0000138c A __bss_start 000012e8 A _DYNAMIC 0000138c A _edata 0000138c A _end 00000234 T __func1 0000025b T __func2 00000282 T libmain -- Summary: -funit-at-a-time drops used functions (IMA mode) Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: critical Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rep dot nop at aon dot at GCC build triplet: i686-linux-gnu GCC host triplet: i686-linux-gnu GCC target triplet: i686-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24395