aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-10-16 09:26:32 +1030
committerAlan Modra <amodra@gmail.com>2021-01-28 11:52:39 +1030
commit662f9a91098d29a36a371aa12ab79ec3b58d0748 (patch)
treea6f4d5204fb411f49b115073c0787d7abb41691c
parentpower10 on ppc32 (diff)
downloadbinutils-gdb-662f9a91098d29a36a371aa12ab79ec3b58d0748.tar.gz
binutils-gdb-662f9a91098d29a36a371aa12ab79ec3b58d0748.tar.bz2
binutils-gdb-662f9a91098d29a36a371aa12ab79ec3b58d0748.zip
R_PPC64_GOT_LO_DS and R_PPC64_GOT_HA sanity check
The previous sanity check allowed a ld on the HA reloc and addis on the LO_DS. * elf64-ppc.c (ppc64_elf_relocate_section): Tighten sanity check on R_PPC64_GOT_LO_DS and R_PPC64_GOT_HA instructions. (cherry picked from commit fba8689ad3b72a3e895ebd41485d747dba5da811)
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elf64-ppc.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 4d94806609..2350c2f20f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,10 @@
2021-01-28 Alan Modra <amodra@gmail.com>
Apply from master
+ 2020-10-16 Alan Modra <amodra@gmail.com>
+ * elf64-ppc.c (ppc64_elf_relocate_section): Tighten sanity check
+ on R_PPC64_GOT_LO_DS and R_PPC64_GOT_HA instructions.
+
2020-08-25 Alan Modra <amodra@gmail.com>
PR 26489
* elf64-ppc.c (ppc64_elf_size_stubs): Test code_sec->has_toc_reloc
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index f1bce4a703..fe9e54820f 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -16087,14 +16087,16 @@ ppc64_elf_relocate_section (bfd *output_bfd,
&& SYMBOL_REFERENCES_LOCAL (info, &h->elf))
{
insn = bfd_get_32 (input_bfd, contents + (rel->r_offset & ~3));
- if ((insn & (0x3fu << 26 | 0x3)) == 58u << 26 /* ld */)
+ if (r_type == R_PPC64_GOT16_LO_DS
+ && (insn & (0x3fu << 26 | 0x3)) == 58u << 26 /* ld */)
{
insn += (14u << 26) - (58u << 26);
bfd_put_32 (input_bfd, insn, contents + (rel->r_offset & ~3));
r_type = R_PPC64_TOC16_LO;
rel->r_info = ELF64_R_INFO (r_symndx, r_type);
}
- else if ((insn & (0x3fu << 26)) == 15u << 26 /* addis */)
+ else if (r_type == R_PPC64_GOT16_HA
+ && (insn & (0x3fu << 26)) == 15u << 26 /* addis */)
{
r_type = R_PPC64_TOC16_HA;
rel->r_info = ELF64_R_INFO (r_symndx, r_type);