binutils-gdb/ld/testsuite/ld-x86-64/pr20830b.d

61 lines
1.9 KiB
D
Raw Normal View History

i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
#name: PR ld/20830 (.plt.got)
#source: pr20830.s
#as: --x32
x86-64: Add -z max-page-size=0x200000 -z noseparate-code to linker tests Add -z max-page-size=0x200000 -z noseparate-code since these tests check for exact addresses. * testsuite/ld-x86-64/bnd-branch-1-now.d: Add -z max-page-size=0x200000 -z noseparate-code. * testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise. * testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-plt-1.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3b-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d.d: Likewise. * testsuite/ld-x86-64/load1a.d: Likewise. * testsuite/ld-x86-64/load1b.d: Likewise. * testsuite/ld-x86-64/load1c.d: Likewise. * testsuite/ld-x86-64/load1d.d: Likewise. * testsuite/ld-x86-64/pie3.d: Likewise. * testsuite/ld-x86-64/pr14207.d: Likewise. * testsuite/ld-x86-64/pr17618.d: Likewise. * testsuite/ld-x86-64/pr19162.d: Likewise. * testsuite/ld-x86-64/pr19636-2d.d: Likewise. * testsuite/ld-x86-64/pr19636-2l.d: Likewise. * testsuite/ld-x86-64/pr20253-1b.d: Likewise. * testsuite/ld-x86-64/pr20253-1d.d: Likewise. * testsuite/ld-x86-64/pr20253-1f.d: Likewise. * testsuite/ld-x86-64/pr20253-1h.d: Likewise. * testsuite/ld-x86-64/pr20253-1j.d: Likewise. * testsuite/ld-x86-64/pr20253-1l.d: Likewise. * testsuite/ld-x86-64/pr20830a-now.d: Likewise. * testsuite/ld-x86-64/pr20830a.d: Likewise. * testsuite/ld-x86-64/pr20830b-now.d: Likewise. * testsuite/ld-x86-64/pr20830b.d: Likewise. * testsuite/ld-x86-64/pr21038a-now.d: Likewise. * testsuite/ld-x86-64/pr21038a.d: Likewise. * testsuite/ld-x86-64/pr21038b-now.d: Likewise. * testsuite/ld-x86-64/pr21038b.d: Likewise. * testsuite/ld-x86-64/pr21038c-now.d: Likewise. * testsuite/ld-x86-64/pr21038c.d: Likewise.
2018-02-16 19:02:00 +01:00
#ld: -melf32_x86_64 -shared -z relro --ld-generated-unwind-info --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
#objdump: -dw -Wf
.*: +file format .*
Contents of the .eh_frame section:
0+ 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 \(rsp\) ofs 8
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
0+18 0000000000000010 0000001c FDE cie=00000000 pc=0000000000000188..0000000000000194
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0+2c 0000000000000020 00000030 FDE cie=00000000 pc=0000000000000170..0000000000000180
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 0000000000000176
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 0000000000000180
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit11; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\)
0+50 0000000000000010 00000054 FDE cie=00000000 pc=0000000000000180..0000000000000188
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
Disassembly of section .plt:
0+170 <.plt>:
+[a-f0-9]+: ff 35 92 0e 20 00 pushq 0x200e92\(%rip\) # 201008 <_GLOBAL_OFFSET_TABLE_\+0x8>
+[a-f0-9]+: ff 25 94 0e 20 00 jmpq \*0x200e94\(%rip\) # 201010 <_GLOBAL_OFFSET_TABLE_\+0x10>
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
+[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
Disassembly of section .plt.got:
x86-64: Improve PLT generation and synthetic PLT symbols On x86-64, the procedure linkage table (PLT) is used to 1. Call external function. 2. Call internal IFUNC function. The best implementation is selected for the target processor at run-time. 3. Act as the canonical function address. 4. Support LD_AUDIT to audit external function calls. 5. Support LD_PROFILE to profile external function calls. PLT looks like: PLT0: push GOT[1] jmp *GOT[2] nop PLT1: jmp *GOT[name1_index] push name1_reloc_index jmp PLT0 GOT is an array of addresses. Initially the GOT entry of name1 is filled with the address of the "push name1_reloc_index" instruction. The function, name1, is called via "jmp *GOT[name1]" in the PLT entry. Even when lazy binding is disabled by "-z now", the PLT0 entry may still be used with LD_AUDIT or LD_PROFILE if PLT entry is used for canonical function address. When linker is invoked with "-z bndplt", a different PLT layout in .plt is used: PLT0: push GOT[1] bnd jmp *GOT[2] nop PLT1: push name1_reloc_index bnd jmp PLT0 nop together with a second PLT section, .pl.bnd: PLT1: bnd jmp *GOT[name1_index] nop where the GOT entry of name1 is filled with the address of the push instruction of the corresponding entry in .plt. 1. With lazy binding, when the external function, name1, is called the first time, dynamic linker is called via PLT0 to update GOT[name1_index] with the actual address of name1 and transfers control to name1 afterwards. 2. PLT is also used to call a local IFUNC function, name1, run-time loader updates GOT[name1_index] when loading the module. This patch 1. Remove PLT layout configurations from x86-64 backend_data. 2. Add generic, lay and non-lazy PLT layout configurations to x86-64 link_hash_table. Generic PLT layout includes the PLT entry templates, information how to update the first instruction in PLT and PLT eh_frame informaton, which are initialized in x86-64 setup_gnu_properties, based on "-z bndplt" and target selection. PLT section alignment is also set to PLT entry size for non-NaCl target. 3. Remove elf_x86_64_create_dynamic_sections. create_dynamic_sections isn't always called, but GOT relocations need GOT relocations. Instead, create all x86-64 specific dynamic sections with alignment to their entry size in x86-64 setup_gnu_properties, which initializes elf.dynobj, so that x86-64 check_relocs can be simplified. 4. Rewrite elf_x86_64_get_synthetic_symtab to check PLT sections against all dynamic relocations to support both lazy and non-lazy PLTs. There is no change in PLT. The only externally visible change is the improvement of synthetic PLT symbols for .plt.got. bfd/ * elf64-x86-64.c (PLT_ENTRY_SIZE): Renamed to ... (LAZY_PLT_ENTRY_SIZE): This. (NON_LAZY_PLT_ENTRY_SIZE): New. (elf_x86_64_plt0_entry): Renamed to ... (elf_x86_64_lazy_plt0_entry): This. (elf_x86_64_plt_entry): Renamed to ... (elf_x86_64_lazy_plt_entry): This. (elf_x86_64_bnd_plt0_entry): Renamed to ... (elf_x86_64_lazy_bnd_plt0_entry): This. (elf_x86_64_legacy_plt_entry): Removed. (elf_x86_64_bnd_plt_entry): Renamed to ... (elf_x86_64_lazy_bnd_plt_entry): This. (elf_x86_64_legacy_plt2_entry): Renamed to ... (elf_x86_64_non_lazy_plt_entry): This. (elf_x86_64_bnd_plt2_entry): Renamed to ... (elf_x86_64_non_lazy_bnd_plt_entry): This. (elf_x86_64_eh_frame_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_plt): This. (elf_x86_64_eh_frame_bnd_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_bnd_plt): This. (elf_x86_64_eh_frame_plt_got): Renamed to ... (elf_x86_64_eh_frame_non_lazy_plt): This. (elf_x86_64_lazy_plt_layout): New. (elf_x86_64_non_lazy_plt_layout): Likewise. (elf_x86_64_plt_layout): Likewise. (elf_x86_64_backend_data): Remove PLT layout information. Add os for target system. (GET_PLT_ENTRY_SIZE): Removed. (elf_x86_64_lazy_plt): New. (elf_x86_64_non_lazy_plt): Likewise. (elf_x86_64_lazy_bnd_plt): Likewise. (elf_x86_64_non_lazy_bnd_plt): Likewise. (elf_x86-64_arch_bed): Updated. (elf_x86_64_link_hash_table): Add plt, lazy_plt and non_lazy_plt. (elf_x86_64_create_dynamic_sections): Removed. (elf_x86_64_check_relocs): Don't check elf.dynobj. Don't call _bfd_elf_create_ifunc_sections nor _bfd_elf_create_got_section. (elf_x86-64_adjust_dynamic_symbol): Updated. (elf_x86_64_allocate_dynrelocs): Updated. Pass 0 as PLT header size to _bfd_elf_allocate_ifunc_dyn_relocs and don't allocate size for PLT0 if there is no PLT0. Get plt_entry_size from non_lazy_plt for non-lazy PLT entries. (elf_x86_64_size_dynamic_sections): Updated. Get plt_entry_size from non_lazy_plt for non-lazy PLT entries. (elf_x86-64_relocate_section): Updated. Properly get PLT index if there is no PLT0. (elf_x86_64_finish_dynamic_symbol): Updated. Fill the first slot in the PLT entry with generic PLT layout. Fill the non-lazy PLT entries with non-lazy PLT layout. Don't fill the second and third slots in the PLT entry if there is no PLT0. (elf_x86_64_finish_dynamic_sections): Updated. Don't fill PLT0 if there is no PLT0. Set sh_entsize on the .plt.got section. (compare_relocs): New. (elf_x86_64_plt_type): Likewise. (elf_x86_64_plt): Likewise. (elf_x86_64_nacl_plt): New. Forward declaration. (elf_x86_64_get_plt_sym_val): Removed. (elf_x86_64_get_synthetic_symtab): Rewrite to check PLT sections against all dynamic relocations. (elf_x86_64_link_setup_gnu_properties): New function. (elf_backend_create_dynamic_sections): Updated. (elf_backend_setup_gnu_properties): New. (elf_x86_64_nacl_plt): New. (elf_x86_64_nacl_arch_bed): Updated. ld/ * testsuite/ld-ifunc/ifunc-16-x86-64-now.d: New file. * testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise. * testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise. * testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise. * testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise. * testsuite/ld-x86-64/mpx3n.dd: Likewise. * testsuite/ld-x86-64/mpx4n.dd: Likewise. * testsuite/ld-x86-64/plt-main-bnd-now.rd: Likewise. * testsuite/ld-x86-64/plt2.dd: Likewise. * testsuite/ld-x86-64/plt2.rd: Likewise. * testsuite/ld-x86-64/plt2.s: Likewise. * testsuite/ld-x86-64/pr20830a-now.d: Likewise. * testsuite/ld-x86-64/pr20830b-now.d: Likewise. * testsuite/ld-x86-64/pr21038a-now.d: Likewise. * testsuite/ld-x86-64/pr21038b-now.d: Likewise. * testsuite/ld-x86-64/pr21038c-now.d: Likewise. * testsuite/ld-x86-64/load1b-nacl.d: Updated. * testsuite/ld-x86-64/load1b.d: Likewise. * testsuite/ld-x86-64/plt-main-bnd.dd: Likewise. * testsuite/ld-x86-64/pr20253-1h.d: Likewise. * testsuite/ld-x86-64/pr20830a.d: Update the .plt.got section with func@plt. * testsuite/ld-x86-64/pr20830b.d: Likewise. * testsuite/ld-x86-64/pr21038a.d: Likewise. * testsuite/ld-x86-64/pr21038c.d: Likewise. * testsuite/ld-x86-64/mpx.exp: Add some -z now tests. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2017-05-08 21:24:11 +02:00
0+180 <func@plt>:
+[a-f0-9]+: ff 25 72 0e 20 00 jmpq \*0x200e72\(%rip\) # 200ff8 <func>
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
+[a-f0-9]+: 66 90 xchg %ax,%ax
Disassembly of section .text:
0+188 <foo>:
x86-64: Improve PLT generation and synthetic PLT symbols On x86-64, the procedure linkage table (PLT) is used to 1. Call external function. 2. Call internal IFUNC function. The best implementation is selected for the target processor at run-time. 3. Act as the canonical function address. 4. Support LD_AUDIT to audit external function calls. 5. Support LD_PROFILE to profile external function calls. PLT looks like: PLT0: push GOT[1] jmp *GOT[2] nop PLT1: jmp *GOT[name1_index] push name1_reloc_index jmp PLT0 GOT is an array of addresses. Initially the GOT entry of name1 is filled with the address of the "push name1_reloc_index" instruction. The function, name1, is called via "jmp *GOT[name1]" in the PLT entry. Even when lazy binding is disabled by "-z now", the PLT0 entry may still be used with LD_AUDIT or LD_PROFILE if PLT entry is used for canonical function address. When linker is invoked with "-z bndplt", a different PLT layout in .plt is used: PLT0: push GOT[1] bnd jmp *GOT[2] nop PLT1: push name1_reloc_index bnd jmp PLT0 nop together with a second PLT section, .pl.bnd: PLT1: bnd jmp *GOT[name1_index] nop where the GOT entry of name1 is filled with the address of the push instruction of the corresponding entry in .plt. 1. With lazy binding, when the external function, name1, is called the first time, dynamic linker is called via PLT0 to update GOT[name1_index] with the actual address of name1 and transfers control to name1 afterwards. 2. PLT is also used to call a local IFUNC function, name1, run-time loader updates GOT[name1_index] when loading the module. This patch 1. Remove PLT layout configurations from x86-64 backend_data. 2. Add generic, lay and non-lazy PLT layout configurations to x86-64 link_hash_table. Generic PLT layout includes the PLT entry templates, information how to update the first instruction in PLT and PLT eh_frame informaton, which are initialized in x86-64 setup_gnu_properties, based on "-z bndplt" and target selection. PLT section alignment is also set to PLT entry size for non-NaCl target. 3. Remove elf_x86_64_create_dynamic_sections. create_dynamic_sections isn't always called, but GOT relocations need GOT relocations. Instead, create all x86-64 specific dynamic sections with alignment to their entry size in x86-64 setup_gnu_properties, which initializes elf.dynobj, so that x86-64 check_relocs can be simplified. 4. Rewrite elf_x86_64_get_synthetic_symtab to check PLT sections against all dynamic relocations to support both lazy and non-lazy PLTs. There is no change in PLT. The only externally visible change is the improvement of synthetic PLT symbols for .plt.got. bfd/ * elf64-x86-64.c (PLT_ENTRY_SIZE): Renamed to ... (LAZY_PLT_ENTRY_SIZE): This. (NON_LAZY_PLT_ENTRY_SIZE): New. (elf_x86_64_plt0_entry): Renamed to ... (elf_x86_64_lazy_plt0_entry): This. (elf_x86_64_plt_entry): Renamed to ... (elf_x86_64_lazy_plt_entry): This. (elf_x86_64_bnd_plt0_entry): Renamed to ... (elf_x86_64_lazy_bnd_plt0_entry): This. (elf_x86_64_legacy_plt_entry): Removed. (elf_x86_64_bnd_plt_entry): Renamed to ... (elf_x86_64_lazy_bnd_plt_entry): This. (elf_x86_64_legacy_plt2_entry): Renamed to ... (elf_x86_64_non_lazy_plt_entry): This. (elf_x86_64_bnd_plt2_entry): Renamed to ... (elf_x86_64_non_lazy_bnd_plt_entry): This. (elf_x86_64_eh_frame_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_plt): This. (elf_x86_64_eh_frame_bnd_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_bnd_plt): This. (elf_x86_64_eh_frame_plt_got): Renamed to ... (elf_x86_64_eh_frame_non_lazy_plt): This. (elf_x86_64_lazy_plt_layout): New. (elf_x86_64_non_lazy_plt_layout): Likewise. (elf_x86_64_plt_layout): Likewise. (elf_x86_64_backend_data): Remove PLT layout information. Add os for target system. (GET_PLT_ENTRY_SIZE): Removed. (elf_x86_64_lazy_plt): New. (elf_x86_64_non_lazy_plt): Likewise. (elf_x86_64_lazy_bnd_plt): Likewise. (elf_x86_64_non_lazy_bnd_plt): Likewise. (elf_x86-64_arch_bed): Updated. (elf_x86_64_link_hash_table): Add plt, lazy_plt and non_lazy_plt. (elf_x86_64_create_dynamic_sections): Removed. (elf_x86_64_check_relocs): Don't check elf.dynobj. Don't call _bfd_elf_create_ifunc_sections nor _bfd_elf_create_got_section. (elf_x86-64_adjust_dynamic_symbol): Updated. (elf_x86_64_allocate_dynrelocs): Updated. Pass 0 as PLT header size to _bfd_elf_allocate_ifunc_dyn_relocs and don't allocate size for PLT0 if there is no PLT0. Get plt_entry_size from non_lazy_plt for non-lazy PLT entries. (elf_x86_64_size_dynamic_sections): Updated. Get plt_entry_size from non_lazy_plt for non-lazy PLT entries. (elf_x86-64_relocate_section): Updated. Properly get PLT index if there is no PLT0. (elf_x86_64_finish_dynamic_symbol): Updated. Fill the first slot in the PLT entry with generic PLT layout. Fill the non-lazy PLT entries with non-lazy PLT layout. Don't fill the second and third slots in the PLT entry if there is no PLT0. (elf_x86_64_finish_dynamic_sections): Updated. Don't fill PLT0 if there is no PLT0. Set sh_entsize on the .plt.got section. (compare_relocs): New. (elf_x86_64_plt_type): Likewise. (elf_x86_64_plt): Likewise. (elf_x86_64_nacl_plt): New. Forward declaration. (elf_x86_64_get_plt_sym_val): Removed. (elf_x86_64_get_synthetic_symtab): Rewrite to check PLT sections against all dynamic relocations. (elf_x86_64_link_setup_gnu_properties): New function. (elf_backend_create_dynamic_sections): Updated. (elf_backend_setup_gnu_properties): New. (elf_x86_64_nacl_plt): New. (elf_x86_64_nacl_arch_bed): Updated. ld/ * testsuite/ld-ifunc/ifunc-16-x86-64-now.d: New file. * testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise. * testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise. * testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise. * testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise. * testsuite/ld-x86-64/mpx3n.dd: Likewise. * testsuite/ld-x86-64/mpx4n.dd: Likewise. * testsuite/ld-x86-64/plt-main-bnd-now.rd: Likewise. * testsuite/ld-x86-64/plt2.dd: Likewise. * testsuite/ld-x86-64/plt2.rd: Likewise. * testsuite/ld-x86-64/plt2.s: Likewise. * testsuite/ld-x86-64/pr20830a-now.d: Likewise. * testsuite/ld-x86-64/pr20830b-now.d: Likewise. * testsuite/ld-x86-64/pr21038a-now.d: Likewise. * testsuite/ld-x86-64/pr21038b-now.d: Likewise. * testsuite/ld-x86-64/pr21038c-now.d: Likewise. * testsuite/ld-x86-64/load1b-nacl.d: Updated. * testsuite/ld-x86-64/load1b.d: Likewise. * testsuite/ld-x86-64/plt-main-bnd.dd: Likewise. * testsuite/ld-x86-64/pr20253-1h.d: Likewise. * testsuite/ld-x86-64/pr20830a.d: Update the .plt.got section with func@plt. * testsuite/ld-x86-64/pr20830b.d: Likewise. * testsuite/ld-x86-64/pr21038a.d: Likewise. * testsuite/ld-x86-64/pr21038c.d: Likewise. * testsuite/ld-x86-64/mpx.exp: Add some -z now tests. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2017-05-08 21:24:11 +02:00
+[a-f0-9]+: e8 f3 ff ff ff callq 180 <func@plt>
+[a-f0-9]+: 48 8b 05 64 0e 20 00 mov 0x200e64\(%rip\),%rax # 200ff8 <func>
i386/x86-64: Add unwind info for .plt.got section When there are both PLT and GOT references to the same function symbol, linker combines GOTPLT and GOT slots into a single GOT slot and create an entry in .plt.got section for PLT access via the GOT slot. This patch adds unwind info for .plt.got section. bfd/ PR ld/20830 * elf32-i386.c (elf_i386_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_i386_plt_layout): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_i386_plt): Updated. (elf_i386_link_hash_table): Add plt_got_eh_frame. (elf_i386_check_relocs): Create .eh_frame section for .plt.got. (elf_i386_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_i386_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. (elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. * elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New. (PLT_GOT_FDE_LENGTH): Likewise. (elf_x86_64_backend_data): Add eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_arch_bed): Updated. (elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and eh_frame_plt_got_size. (elf_x86_64_nacl_arch_bed): Likewise. (elf_x86_64_link_hash_table): Add plt_got_eh_frame. (elf_x86_64_check_relocs): Create .eh_frame section for .plt.got. (elf_x86_64_size_dynamic_sections): Allocate and initialize .eh_frame section for .plt.got. (elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section for .plt.got. ld/ PR ld/20830 * testsuite/ld-i386/i386.exp: Run pr20830. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr20830.d: New file. * testsuite/ld-i386/pr20830.s: Likewise. * testsuite/ld-x86-64/pr20830.d: Likewise. * testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 22:31:59 +01:00
#pass