aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-12-06 11:35:42 -0800
committerH.J. Lu <hjl.tools@gmail.com>2022-12-08 08:05:45 -0800
commite9c11d58b951ed64255a7889fdcb087e3bed89de (patch)
tree3cf56fe61dc7ab7b53fc7259b1aad93d37508de8 /bfd
parent2d77a94ff17a81260b80997db476f87cba5f4b11 (diff)
downloadfsf-binutils-gdb-e9c11d58b951ed64255a7889fdcb087e3bed89de.zip
fsf-binutils-gdb-e9c11d58b951ed64255a7889fdcb087e3bed89de.tar.gz
fsf-binutils-gdb-e9c11d58b951ed64255a7889fdcb087e3bed89de.tar.bz2
x86-64: Remove BND from 64-bit IBT PLT
Since MPX support has been removed from x86-64 psABI, remove BND from 64-bit IBT PLT by using x32 IBT PLT. bfd/ PR ld/29851 * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Also check x32 IBT PLT for 64-bit. (elf_x86_64_link_setup_gnu_properties): Always use x32 IBT PLT. ld/ PR ld/29851 * testsuite/ld-x86-64/ibt-plt-1.d: Updated. * testsuite/ld-x86-64/ibt-plt-2a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d.d: Likewise. * testsuite/ld-x86-64/plt-main-ibt-x32.dd: Moved to ... * testsuite/ld-x86-64/plt-main-ibt.dd: This. * testsuite/ld-x86-64/x86-64.exp: Don't use plt-main-ibt-x32.dd.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf64-x86-64.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index fb87279..2a5f5a5 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -4926,6 +4926,8 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd,
const struct elf_x86_non_lazy_plt_layout *non_lazy_bnd_plt;
const struct elf_x86_lazy_plt_layout *lazy_ibt_plt;
const struct elf_x86_non_lazy_plt_layout *non_lazy_ibt_plt;
+ const struct elf_x86_lazy_plt_layout *x32_lazy_ibt_plt;
+ const struct elf_x86_non_lazy_plt_layout *x32_non_lazy_ibt_plt;
asection *plt;
enum elf_x86_plt_type plt_type;
struct elf_x86_plt plts[] =
@@ -4957,11 +4959,15 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd,
{
lazy_ibt_plt = &elf_x86_64_lazy_ibt_plt;
non_lazy_ibt_plt = &elf_x86_64_non_lazy_ibt_plt;
+ x32_lazy_ibt_plt = &elf_x32_lazy_ibt_plt;
+ x32_non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt;
}
else
{
lazy_ibt_plt = &elf_x32_lazy_ibt_plt;
non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt;
+ x32_lazy_ibt_plt = NULL;
+ x32_non_lazy_ibt_plt = NULL;
}
count = 0;
@@ -4987,7 +4993,21 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd,
lazy_plt->plt0_got1_offset) == 0)
&& (memcmp (plt_contents + 6, lazy_plt->plt0_entry + 6,
2) == 0))
- plt_type = plt_lazy;
+ {
+ if (x32_lazy_ibt_plt != NULL
+ && (memcmp (plt_contents
+ + x32_lazy_ibt_plt->plt_entry_size,
+ x32_lazy_ibt_plt->plt_entry,
+ x32_lazy_ibt_plt->plt_got_offset) == 0))
+ {
+ /* The fist entry in the x32 lazy IBT PLT is the same
+ as the lazy PLT. */
+ plt_type = plt_lazy | plt_second;
+ lazy_plt = x32_lazy_ibt_plt;
+ }
+ else
+ plt_type = plt_lazy;
+ }
else if (lazy_bnd_plt != NULL
&& (memcmp (plt_contents, lazy_bnd_plt->plt0_entry,
lazy_bnd_plt->plt0_got1_offset) == 0)
@@ -5037,6 +5057,16 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd,
plt_type = plt_second;
non_lazy_plt = non_lazy_ibt_plt;
}
+ else if (x32_non_lazy_ibt_plt != NULL
+ && plt->size >= x32_non_lazy_ibt_plt->plt_entry_size
+ && (memcmp (plt_contents,
+ x32_non_lazy_ibt_plt->plt_entry,
+ x32_non_lazy_ibt_plt->plt_got_offset) == 0))
+ {
+ /* Match x32 IBT PLT. */
+ plt_type = plt_second;
+ non_lazy_plt = x32_non_lazy_ibt_plt;
+ }
}
if (plt_type == plt_unknown)
@@ -5298,16 +5328,8 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
init_table.non_lazy_plt = &elf_x86_64_non_lazy_plt;
}
- if (ABI_64_P (info->output_bfd))
- {
- init_table.lazy_ibt_plt = &elf_x86_64_lazy_ibt_plt;
- init_table.non_lazy_ibt_plt = &elf_x86_64_non_lazy_ibt_plt;
- }
- else
- {
- init_table.lazy_ibt_plt = &elf_x32_lazy_ibt_plt;
- init_table.non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt;
- }
+ init_table.lazy_ibt_plt = &elf_x32_lazy_ibt_plt;
+ init_table.non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt;
if (ABI_64_P (info->output_bfd))
{