[PATCH] D37333: [ELF, draft] - Combine GOTPLT and GOT slots.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 05:41:48 PDT 2017
>> Patch do next things:
>>
>> 1. It introduces `.plt.got` section. Name is consistent with bfd.
>>
>
>I agree that the is not enough evidence that the optimization is common
>enough to be useful, but the idea of a smaller non-lazy plt entry might
>be independently useful for when '-z now' is used. Does bfd do that?
>
>Cheers,
>Rafael
As far I understand for doing that we must ensure that poiner equality is maintained,
if not we can not use GOT relocations instead PLT ones:
https://gcc.gnu.org/ml/gcc/2015-05/msg00264.html
I checked bfd behavior using sample app:
.globl _start
_start:
movq foo at GOTPCREL(%rip), %rax
callq foo at PLT
callq bar at PLT
1) BFD 2.26.1 uses small non-lazy plt for both symbol 'bar' and 'foo':
llvm-mc -filetype=obj -triple=x86_64-pc-linux test.s -o test.o
ld.bfd -v
GNU ld (GNU Binutils for Ubuntu) 2.26.1
ld.bfd test.o -shared -o test.so -z now
objdump -D test.so
0000000000000250 <.plt.got>:
250: ff 25 32 01 20 00 jmpq *0x200132(%rip) # 200388 <_DYNAMIC+0x110>
256: 66 90 xchg %ax,%ax
258: ff 25 32 01 20 00 jmpq *0x200132(%rip) # 200390 <_DYNAMIC+0x118>
25e: 66 90 xchg %ax,%ax
0000000000000260 <_start>:
260: 48 8b 05 21 01 20 00 mov 0x200121(%rip),%rax # 200388 <_DYNAMIC+0x110>
267: e8 e4 ff ff ff callq 250 <_start-0x10>
26c: e8 e7 ff ff ff callq 258 <_start-0x8>
2) BFD of version GNU ld (GNU Binutils) 2.28.51.20170605 and freshest GNU ld (GNU Binutils) 2.29.51.20171006
Does not use small non-lazy plt entry for 'bar' (not sure why, looks like a bug for me):
Disassembly of section .plt:
0000000000000250 <bar at plt-0x10>:
250: ff 35 8a 0d 20 00 pushq 0x200d8a(%rip) # 200fe0 <_GLOBAL_OFFSET_TABLE_+0x8>
256: ff 25 8c 0d 20 00 jmpq *0x200d8c(%rip) # 200fe8 <_GLOBAL_OFFSET_TABLE_+0x10>
25c: 0f 1f 40 00 nopl 0x0(%rax)
0000000000000260 <bar at plt>:
260: ff 25 8a 0d 20 00 jmpq *0x200d8a(%rip) # 200ff0 <_GLOBAL_OFFSET_TABLE_+0x18>
266: 68 00 00 00 00 pushq $0x0
26b: e9 e0 ff ff ff jmpq 250 <bar at plt-0x10>
Disassembly of section .plt.got:
0000000000000270 <.plt.got>:
270: ff 25 82 0d 20 00 jmpq *0x200d82(%rip) # 200ff8 <_GLOBAL_OFFSET_TABLE_+0x20>
276: 66 90 xchg %ax,%ax
00000000000002b8 <_start>:
2b8: 48 8b 05 39 0d 20 00 mov 0x200d39(%rip),%rax # 200ff8 <_DYNAMIC+0x130>
2bf: e8 ec ff ff ff callq 2b0 <bar at plt+0x10>
2c4: e8 d7 ff ff ff callq 2a0 <bar at plt>
George.
More information about the llvm-commits
mailing list