[binutils-gdb/binutils-2_34-branch] aarch64: set sh_entsize of .plt to 0
Szabolcs Nagy
nsz@sourceware.org
Tue Aug 11 11:10:30 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e3b314d3a61db4b0b36975fa00eb9043a6142448
commit e3b314d3a61db4b0b36975fa00eb9043a6142448
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Wed Jul 29 15:47:50 2020 +0100
aarch64: set sh_entsize of .plt to 0
On aarch64 the first PLT entry is 32 bytes, subsequent entries
are 16 bytes by default but can be 24 bytes with BTI or with
PAC-PLT.
sh_entsize of .plt was set to the PLT entry size, so in some
cases sh_size % sh_entsize != 0, which breaks some tools.
Note that PLT0 (and the TLSDESC stub code which is also in the
PLT) were historically not padded up to meet the sh_size
requirement, but to ensure that PLT stub code is aligned on
cache lines. Similar layout is present on other targets too
which just happens to make sh_size a multiple of sh_entsize and
it is not expected that sh_entsize of .plt is used for anything.
This patch sets sh_entsize of .plt to 0: the section does not
hold a table of fixed-size entries so other values are not
conforming in principle to the ELF spec.
bfd/ChangeLog:
Backport from mainline.
2020-07-30 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR ld/26312
* elfnn-aarch64.c (elfNN_aarch64_init_small_plt0_entry): Set sh_entsize
to 0.
(elfNN_aarch64_finish_dynamic_sections): Remove sh_entsize setting.
(cherry picked from commit 4d3bb35620e70d543d438bf21be1307f7ea0f5d0)
Diff:
---
bfd/ChangeLog | 10 ++++++++++
bfd/elfnn-aarch64.c | 11 +++++------
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ca87f744a3d..ecd099580a4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2020-08-11 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ Backport from mainline.
+ 2020-07-30 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ PR ld/26312
+ * elfnn-aarch64.c (elfNN_aarch64_init_small_plt0_entry): Set sh_entsize
+ to 0.
+ (elfNN_aarch64_finish_dynamic_sections): Remove sh_entsize setting.
+
2020-04-21 Tamar Christina <tamar.christina@arm.com>
Backport from mainline.
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 5fabcd8f646..0493cbb080a 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -9571,8 +9571,11 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED,
memcpy (htab->root.splt->contents, htab->plt0_entry,
htab->plt_header_size);
- elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize =
- htab->plt_header_size;
+
+ /* PR 26312: Explicitly set the sh_entsize to 0 so that
+ consumers do not think that the section contains fixed
+ sized objects. */
+ elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize = 0;
plt_got_2nd_ent = (htab->root.sgotplt->output_section->vma
+ htab->root.sgotplt->output_offset
@@ -9674,10 +9677,6 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
{
elfNN_aarch64_init_small_plt0_entry (output_bfd, htab);
- elf_section_data (htab->root.splt->output_section)->
- this_hdr.sh_entsize = htab->plt_entry_size;
-
-
if (htab->tlsdesc_plt && !(info->flags & DF_BIND_NOW))
{
BFD_ASSERT (htab->dt_tlsdesc_got != (bfd_vma)-1);
More information about the Binutils-cvs
mailing list