This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] PowerPC addpcis fix again
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 28 Feb 2017 14:09:50 -0000
- Subject: [binutils-gdb] PowerPC addpcis fix again
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3de43e7beb9839fa268a73be77de73a7b7cd97db
commit 3de43e7beb9839fa268a73be77de73a7b7cd97db
Author: Alan Modra <amodra@gmail.com>
Date: Tue Feb 28 23:42:29 2017 +1030
PowerPC addpcis fix again
In the last patch I said "The patch also fixes overflow checking".
In fact, there wasn't anything wrong with the previous code. So,
revert that change. The new checks are OK too, so this is just a
tidy.
* elf64-ppc.c (ppc64_elf_ha_reloc): Revert last change.
(ppc64_elf_relocate_section): Likewise.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elf64-ppc.c | 16 +++++++---------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 68fb27e..86a19a3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
2017-02-28 Alan Modra <amodra@gmail.com>
+ * elf64-ppc.c (ppc64_elf_ha_reloc): Revert last change.
+ (ppc64_elf_relocate_section): Likewise.
+
+2017-02-28 Alan Modra <amodra@gmail.com>
+
PR 20995
* elf32-nios2.c (nios2_elf32_relocate_section): Use htab
rather than elf32_nios2_hash_table or elf_hash_table.
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 661ef26..5ecd1a3 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -2529,7 +2529,7 @@ ppc64_elf_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
enum elf_ppc64_reloc_type r_type;
long insn;
bfd_size_type octets;
- bfd_vma value, field;
+ bfd_vma value;
/* If this is a relocatable link (output_bfd test tells us), just
call the generic function. Any adjustment will be done at final
@@ -2555,14 +2555,14 @@ ppc64_elf_ha_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
value -= (reloc_entry->address
+ input_section->output_offset
+ input_section->output_section->vma);
- field = (bfd_signed_vma) value >> 16;
+ value = (bfd_signed_vma) value >> 16;
octets = reloc_entry->address * bfd_octets_per_byte (abfd);
insn = bfd_get_32 (abfd, (bfd_byte *) data + octets);
insn &= ~0x1fffc1;
- insn |= (field & 0xffc1) | ((field & 0x3e) << 15);
+ insn |= (value & 0xffc1) | ((value & 0x3e) << 15);
bfd_put_32 (abfd, insn, (bfd_byte *) data + octets);
- if (value + 0x80000000 > 0xffffffff)
+ if (value + 0x8000 > 0xffff)
return bfd_reloc_overflow;
return bfd_reloc_ok;
}
@@ -15255,19 +15255,17 @@ ppc64_elf_relocate_section (bfd *output_bfd,
r = bfd_reloc_outofrange;
else
{
- bfd_signed_vma field;
-
relocation += addend;
relocation -= (rel->r_offset
+ input_section->output_offset
+ input_section->output_section->vma);
- field = (bfd_signed_vma) relocation >> 16;
+ relocation = (bfd_signed_vma) relocation >> 16;
insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
insn &= ~0x1fffc1;
- insn |= (field & 0xffc1) | ((field & 0x3e) << 15);
+ insn |= (relocation & 0xffc1) | ((relocation & 0x3e) << 15);
bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
r = bfd_reloc_ok;
- if (relocation + 0x80000000 > 0xffffffff)
+ if (relocation + 0x8000 > 0xffff)
r = bfd_reloc_overflow;
}
}