04ebc307f9
We use its PLT entry to initialize function pointer at run-time. If there is no other usage for the PLT entry, we can generate run-time function pointer relocations in read-write section, which can be resolved by dynamic linker, to initialize function pointers. It avoids the extra indirect branch overhead in PLT. bfd/ PR ld/18900 * elf32-i386.c (elf_i386_link_hash_entry): Add func_pointer_refcount. (elf_i386_link_hash_newfunc): Clear func_pointer_refcount. (elf_i386_get_local_sym_hash): Likewise. (elf_i386_copy_indirect_symbol): Also copy func_pointer_refcount. (elf_i386_check_relocs): Increment func_pointer_refcount. (elf_i386_gc_sweep_hook): Decrement func_pointer_refcount. (elf_i386_allocate_dynrelocs): Don't create the PLT entry if there are only function pointer relocations which can be resolved at run-time. Keep dynanamic relocations for run-time function pointer initialization. (elf_i386_relocate_section): Copy dynamic function pointer relocations. * elf64-x86-64.c (elf_x86_64_link_hash_entry): Add func_pointer_refcount. (elf_x86_64_link_hash_newfunc): Clear func_pointer_refcount. (elf_x86_64_get_local_sym_hash): Likewise. (elf_x86_64_copy_indirect_symbol): Also copy func_pointer_refcount. (elf_x86_64_check_relocs): Increment func_pointer_refcount. (elf_x86_64_gc_sweep_hook): Decrement func_pointer_refcount. (elf_x86_64_allocate_dynrelocs): Don't create the PLT entry if there are only function pointer relocations which can be resolved at run-time. Keep dynanamic relocations for run-time function pointer initialization. (elf_x86_64_relocate_section): Copy dynamic function pointer relocations. ld/testsuite/ PR ld/18900 * ld-i386/i386.exp: Run tests for PR ld/18900. * ld-x86-64/x86-64.exp: Likewise. * ld-i386/pr18900.out: New file. * ld-i386/pr18900a.c: Likewise. * ld-i386/pr18900a.c: Likewise. * ld-i386/pr18900a.rd: Likewise. * ld-i386/pr18900b.c: Likewise. * ld-i386/pr18900b.rd: Likewise. * ld-i386/pr18900c.c: Likewise. * ld-x86-64/pr18900.out: Likewise. * ld-x86-64/pr18900a.c: Likewise. * ld-x86-64/pr18900a.rd: Likewise. * ld-x86-64/pr18900b.c: Likewise. * ld-x86-64/pr18900b.rd: Likewise. * ld-x86-64/pr18900c.c: Likewise. * ld-x86-64/mpx3.dd: Updated.
28 lines
1.1 KiB
Text
28 lines
1.1 KiB
Text
.*: +file format .*
|
|
|
|
|
|
Disassembly of section .plt:
|
|
|
|
0+[a-f0-9]+ <.plt>:
|
|
[ ]*[a-f0-9]+: ff ([0-9a-f]{2} ){5} pushq 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8>
|
|
[ ]*[a-f0-9]+: f2 ff ([0-9a-f]{2} ){5} bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10>
|
|
[ ]*[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
|
|
[ ]*[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
|
|
[ ]*[a-f0-9]+: f2 e9 ([0-9a-f]{2} ){4} bnd jmpq [a-f0-9]+ <call1@plt-0x20>
|
|
[ ]*[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
|
|
|
|
Disassembly of section .plt.bnd:
|
|
|
|
0+[a-f0-9]+ <call1@plt>:
|
|
[ ]*[a-f0-9]+: f2 ff ([0-9a-f]{2} ){5} bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x18>
|
|
[ ]*[a-f0-9]+: 90 nop
|
|
|
|
Disassembly of section .text:
|
|
|
|
0+[a-f0-9]+ <_start>:
|
|
[ ]*[a-f0-9]+: bf ([0-9a-f]{2} ){4} mov \$0x[a-f0-9]+,%edi
|
|
[ ]*[a-f0-9]+: f2 ff d7 bnd callq \*%rdi
|
|
[ ]*[a-f0-9]+: 48 8b ([0-9a-f]{2} ){5} mov 0x[a-f0-9]+\(%rip\),%rdi # [a-f0-9]+ <func>
|
|
[ ]*[a-f0-9]+: f2 ff d7 bnd callq \*%rdi
|
|
[ ]*[a-f0-9]+: c3 retq
|
|
#pass
|