This patch http://sourceware.org/ml/binutils/2006-05/msg00458.html removes unused section symbols from symbol table. Shouldn't ld try not to put them in symbol table in the first place?
Created attachment 1061 [details] A testcase I got [hjl@gnu-13 symtab-1]$ make as -o foo.o foo.s ./ld -o foo foo.o ./objcopy foo bar readelf -Ss foo > foo.l readelf -Ss bar > bar.l diff -up foo.l bar.l --- foo.l 2006-06-01 09:50:12.000000000 -0700 +++ bar.l 2006-06-01 09:50:12.000000000 -0700 @@ -12,26 +12,23 @@ Section Headers: [ 3] .shstrtab STRTAB 0000000000000000 000000b5 0000000000000027 0000000000000000 0 0 1 [ 4] .symtab SYMTAB 0000000000000000 00000260 - 0000000000000138 0000000000000018 5 6 8 - [ 5] .strtab STRTAB 0000000000000000 00000398 + 00000000000000f0 0000000000000018 5 3 8 + [ 5] .strtab STRTAB 0000000000000000 00000350 0000000000000033 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) -Symbol table '.symtab' contains 13 entries: +Symbol table '.symtab' contains 10 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000004000b0 0 SECTION LOCAL DEFAULT 1 2: 00000000006000b4 0 SECTION LOCAL DEFAULT 2 - 3: 0000000000000000 0 SECTION LOCAL DEFAULT 3 - 4: 0000000000000000 0 SECTION LOCAL DEFAULT 4 - 5: 0000000000000000 0 SECTION LOCAL DEFAULT 5 - 6: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 __start - 7: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 _start - 8: 00000000006000b5 0 NOTYPE GLOBAL DEFAULT ABS __bss_start - 9: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 main - 10: 00000000006000b5 0 NOTYPE GLOBAL DEFAULT ABS _edata - 11: 00000000006000b8 0 NOTYPE GLOBAL DEFAULT ABS _end - 12: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 start + 3: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 __start + 4: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 _start + 5: 00000000006000b5 0 NOTYPE GLOBAL DEFAULT ABS __bss_start + 6: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 main + 7: 00000000006000b5 0 NOTYPE GLOBAL DEFAULT ABS _edata + 8: 00000000006000b8 0 NOTYPE GLOBAL DEFAULT ABS _end + 9: 00000000004000b0 0 NOTYPE GLOBAL DEFAULT 1 start make: *** [all] Error 1 [hjl@gnu-13 symtab-1]$
http://sources.redhat.com/ml/binutils-cvs/2006-06/msg00009.html