In this testcase, .got.plt section isn't needed: [...@gnu-6 gotplt-1]$ cat foo.c static int bar () { return 0x1234; }
void * foo () { return &bar; } [...@gnu-6 gotplt-1]$ cat main.c extern void * foo (); extern void abort (); int main () { int (*bar) () = foo (); if (bar () != 0x1234) abort (); return 0; } [...@gnu-6 gotplt-1]$ make LD=ld gcc -m32 -O2 -fPIC -c -o foo.o foo.c ld -shared -m elf_i386 -o foo.so foo.o gcc -m32 -O2 -c -o main.o main.c gcc -m32 -o foo foo.so main.o -Wl,-rpath,. ./foo [...@gnu-6 gotplt-1]$ readelf -r foo.o Relocation section '.rel.text' at offset 0x3f4 contains 3 entries: Offset Info Type Sym.Value Sym. Name 00000011 00000b02 R_386_PC32 00000000 __i686.get_pc_thunk.cx 00000017 00000c0a R_386_GOTPC 00000000 _GLOBAL_OFFSET_TABLE_ 00000021 00000209 R_386_GOTOFF 00000000 .text [...@gnu-6 gotplt-1]$ readelf -S foo.so There are 11 section headers, starting at offset 0x260: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .hash HASH 000000b4 0000b4 000028 04 A 2 0 4 [ 2] .dynsym DYNSYM 000000dc 0000dc 000050 10 A 3 1 4 [ 3] .dynstr STRTAB 0000012c 00012c 00001d 00 A 0 0 1 [ 4] .text PROGBITS 00000150 000150 00002a 00 AX 0 0 16 [ 5] .dynamic DYNAMIC 0000117c 00017c 000058 08 WA 3 0 4 [ 6] .got.plt PROGBITS 000011d4 0001d4 00000c 04 WA 0 0 4 [ 7] .comment PROGBITS 00000000 0001e0 00002d 01 MS 0 0 1 [ 8] .shstrtab STRTAB 00000000 00020d 000052 00 0 0 1 [ 9] .symtab SYMTAB 00000000 000418 000110 10 10 13 4 [10] .strtab STRTAB 00000000 000528 00005d 00 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) [...@gnu-6 gotplt-1]$ -- Summary: Unused .got.plt section generated by linker Product: binutils Version: 2.21 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: hjl dot tools at gmail dot com CC: bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=11812 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils