mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 14:39:09 +08:00
x86-64: Add ENDBR64 to the TLSDESC PLT entry
The TLSDESC entry in a lazy procedure linkage table is called indirectly with "callq *(%rax)". This patch adds an ENDBR64 to support indirect branch tracking in Intel CET. The TLSDESC PLT entry now looks like: 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */ 0xff, 0x35, 8, 0, 0, 0, /* pushq GOT+8(%rip) */ 0xff, 0x25, 16, 0, 0, 0 /* jmpq *GOT+TDG(%rip) */ The BND prefix isn't needed since MPX isn't used for TLSDESC. bfd/ PR ld/23000 * elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Add ENDBR64 to the TLSDESC PLT entry. ld/ PR ld/23000 * testsuite/ld-x86-64/tlsdesc.pd: Updated.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2018-03-25 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/23000
|
||||||
|
* elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Add
|
||||||
|
ENDBR64 to the TLSDESC PLT entry.
|
||||||
|
|
||||||
2018-03-21 Alan Modra <amodra@gmail.com>
|
2018-03-21 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Trim uninteresting
|
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Trim uninteresting
|
||||||
|
@ -4411,15 +4411,23 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
|
|||||||
|
|
||||||
if (htab->tlsdesc_plt)
|
if (htab->tlsdesc_plt)
|
||||||
{
|
{
|
||||||
|
/* The TLSDESC entry in a lazy procedure linkage table. */
|
||||||
|
static const bfd_byte tlsdesc_plt_entry[LAZY_PLT_ENTRY_SIZE] =
|
||||||
|
{
|
||||||
|
0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */
|
||||||
|
0xff, 0x35, 8, 0, 0, 0, /* pushq GOT+8(%rip) */
|
||||||
|
0xff, 0x25, 16, 0, 0, 0 /* jmpq *GOT+TDG(%rip) */
|
||||||
|
};
|
||||||
|
|
||||||
bfd_put_64 (output_bfd, (bfd_vma) 0,
|
bfd_put_64 (output_bfd, (bfd_vma) 0,
|
||||||
htab->elf.sgot->contents + htab->tlsdesc_got);
|
htab->elf.sgot->contents + htab->tlsdesc_got);
|
||||||
|
|
||||||
memcpy (htab->elf.splt->contents + htab->tlsdesc_plt,
|
memcpy (htab->elf.splt->contents + htab->tlsdesc_plt,
|
||||||
htab->lazy_plt->plt0_entry,
|
tlsdesc_plt_entry, LAZY_PLT_ENTRY_SIZE);
|
||||||
htab->lazy_plt->plt0_entry_size);
|
|
||||||
|
|
||||||
/* Add offset for pushq GOT+8(%rip), since the
|
/* Add offset for pushq GOT+8(%rip), since ENDBR64 uses 4
|
||||||
instruction uses 6 bytes subtract this value. */
|
bytes and the instruction uses 6 bytes, subtract these
|
||||||
|
values. */
|
||||||
bfd_put_32 (output_bfd,
|
bfd_put_32 (output_bfd,
|
||||||
(htab->elf.sgotplt->output_section->vma
|
(htab->elf.sgotplt->output_section->vma
|
||||||
+ htab->elf.sgotplt->output_offset
|
+ htab->elf.sgotplt->output_offset
|
||||||
@ -4427,14 +4435,13 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
|
|||||||
- htab->elf.splt->output_section->vma
|
- htab->elf.splt->output_section->vma
|
||||||
- htab->elf.splt->output_offset
|
- htab->elf.splt->output_offset
|
||||||
- htab->tlsdesc_plt
|
- htab->tlsdesc_plt
|
||||||
- 6),
|
- 4 - 6),
|
||||||
(htab->elf.splt->contents
|
(htab->elf.splt->contents
|
||||||
+ htab->tlsdesc_plt
|
+ htab->tlsdesc_plt
|
||||||
+ htab->lazy_plt->plt0_got1_offset));
|
+ 4 + 2));
|
||||||
/* Add offset for the PC-relative instruction accessing
|
/* Add offset for indirect branch via GOT+TDG, where TDG
|
||||||
GOT+TDG, where TDG stands for htab->tlsdesc_got,
|
stands for htab->tlsdesc_got, subtracting the offset
|
||||||
subtracting the offset to the end of that
|
to the end of that instruction. */
|
||||||
instruction. */
|
|
||||||
bfd_put_32 (output_bfd,
|
bfd_put_32 (output_bfd,
|
||||||
(htab->elf.sgot->output_section->vma
|
(htab->elf.sgot->output_section->vma
|
||||||
+ htab->elf.sgot->output_offset
|
+ htab->elf.sgot->output_offset
|
||||||
@ -4442,10 +4449,9 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
|
|||||||
- htab->elf.splt->output_section->vma
|
- htab->elf.splt->output_section->vma
|
||||||
- htab->elf.splt->output_offset
|
- htab->elf.splt->output_offset
|
||||||
- htab->tlsdesc_plt
|
- htab->tlsdesc_plt
|
||||||
- htab->lazy_plt->plt0_got2_insn_end),
|
- 4 - 6 - 6),
|
||||||
(htab->elf.splt->contents
|
(htab->elf.splt->contents
|
||||||
+ htab->tlsdesc_plt
|
+ htab->tlsdesc_plt + 4 + 6 + 2));
|
||||||
+ htab->lazy_plt->plt0_got2_offset));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2018-03-25 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/23000
|
||||||
|
* testsuite/ld-x86-64/tlsdesc.pd: Updated.
|
||||||
|
|
||||||
2018-03-23 Nick Clifton <nickc@redhat.com>
|
2018-03-23 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
PR 22948
|
PR 22948
|
||||||
|
@ -13,7 +13,7 @@ Disassembly of section .plt:
|
|||||||
[0-9a-f]+: ff 35 .. .. 20 00 pushq .*\(%rip\) # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
|
[0-9a-f]+: ff 35 .. .. 20 00 pushq .*\(%rip\) # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
|
||||||
[0-9a-f]+: ff 25 .. .. 20 00 jmpq \*.*\(%rip\) # 201360 <_GLOBAL_OFFSET_TABLE_\+0x10>
|
[0-9a-f]+: ff 25 .. .. 20 00 jmpq \*.*\(%rip\) # 201360 <_GLOBAL_OFFSET_TABLE_\+0x10>
|
||||||
[0-9a-f]+: 0f 1f 40 00 nopl 0x0\(%rax\)
|
[0-9a-f]+: 0f 1f 40 00 nopl 0x0\(%rax\)
|
||||||
|
[0-9a-f]+: f3 0f 1e fa endbr64
|
||||||
[0-9a-f]+: ff 35 .. .. 20 00 pushq .*\(%rip\) # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
|
[0-9a-f]+: ff 35 .. .. 20 00 pushq .*\(%rip\) # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
|
||||||
[0-9a-f]+: ff 25 .. .. 20 00 jmpq \*.*\(%rip\) # 201348 <.*>
|
[0-9a-f]+: ff 25 .. .. 20 00 jmpq \*.*\(%rip\) # 201348 <.*>
|
||||||
[0-9a-f]+: 0f 1f 40 00 nopl 0x0\(%rax\)
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user