diff options
author | Alan Modra <amodra@gmail.com> | 2020-10-16 09:26:32 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-10-16 09:26:32 +1030 |
commit | fba8689ad3b72a3e895ebd41485d747dba5da811 (patch) | |
tree | 4a71aa6eeafe0439b9a671b5ab2411407acc9683 /bfd | |
parent | a1c72cdfaba25bfc8a02fda36df566a24c401839 (diff) | |
download | gdb-fba8689ad3b72a3e895ebd41485d747dba5da811.zip gdb-fba8689ad3b72a3e895ebd41485d747dba5da811.tar.gz gdb-fba8689ad3b72a3e895ebd41485d747dba5da811.tar.bz2 |
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3ff3b1e..7083e47 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +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-10-09 Alan Modra <amodra@gmail.com> * elf64-ppc.c (write_plt_relocs_for_local_syms): Don't do local diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index c30215b..157c454 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -16091,14 +16091,16 @@ ppc64_elf_relocate_section (bfd *output_bfd, && (h == NULL || 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); |