Is there any reason why when partial linking with ld -r that local symbols cannot be completely resolved and therefore removed from the symbol table?
It seems that a link with ld -r still requires the local symbols to be kept; only on the final link to produce a static executable are the local symbols finally resolved. For example, following the symbol p1 through the process below. Thanks for any insight! Ian % cc -c -o a.o a.c % nm a.o 00000044 T global 00000000 T main 0000002c T p1 U p2 U printf % # p1 is global, but not really need beyond this [group of] file[s]. % # Make p1 local % objcopy -L p1 a.o % # Partial link % ld -r -o a1.o a.o % # Have a look at the symbol table; p1 is local. % nm a1.o 00000044 T global 00000000 T main 0000002c t p1 U p2 U printf % # But the code still requires the symbol, see address 0x20: objdump -d a1.o a1.o: file format elf32-i386 Disassembly of section .text: 00000000 <main>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 08 sub $0x8,%esp 6: 83 e4 f0 and $0xfffffff0,%esp 9: b8 00 00 00 00 mov $0x0,%eax e: 29 c4 sub %eax,%esp 10: 83 ec 0c sub $0xc,%esp 13: 68 00 00 00 00 push $0x0 18: e8 fc ff ff ff call 19 <main+0x19> 1d: 83 c4 10 add $0x10,%esp 20: e8 fc ff ff ff call 21 <main+0x21> 25: e8 fc ff ff ff call 26 <main+0x26> 2a: c9 leave 2b: c3 ret 0000002c <p1>: 2c: 55 push %ebp 2d: 89 e5 mov %esp,%ebp 2f: 83 ec 08 sub $0x8,%esp 32: 83 ec 0c sub $0xc,%esp 35: 68 06 00 00 00 push $0x6 3a: e8 fc ff ff ff call 3b <p1+0xf> 3f: 83 c4 10 add $0x10,%esp 42: c9 leave 43: c3 ret 00000044 <global>: 44: 55 push %ebp 45: 89 e5 mov %esp,%ebp 47: 83 ec 08 sub $0x8,%esp 4a: 83 ec 0c sub $0xc,%esp 4d: 68 0a 00 00 00 push $0xa 52: e8 fc ff ff ff call 53 <global+0xf> 57: 83 c4 10 add $0x10,%esp 5a: c9 leave 5b: c3 ret % Indeed, we cannot remove it. % objcopy -N p1 a1.o big.o BFD: big.o: symbol `p1' required but not present objcopy: big.o: No symbols _______________________________________________ help-gnu-utils mailing list help-gnu-utils@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-utils