This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] PowerPC64, don't relocate nops
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 2 Feb 2018 12:17:17 -0000
- Subject: [binutils-gdb] PowerPC64, don't relocate nops
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d830549dba59f4e11412fd6dc18b7b1d4c6cf557
commit d830549dba59f4e11412fd6dc18b7b1d4c6cf557
Author: Alan Modra <amodra@gmail.com>
Date: Fri Feb 2 16:55:21 2018 +1030
PowerPC64, don't relocate nops
This fixes a "bug" in that nops emitted as part of code optimization
were being relocated. As it happens the relocation value was always
zero so the nop wasn't changed. Whew! I've also moved the use of
"howto" later since I was caught out in some recent code changes with
the howto not matching r_type.
* elf64-ppc.c (ppc64_elf_relocate_section): Don't relocate nops
emitted for toc sequence optimization. Set and use "howto" later.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elf64-ppc.c | 13 +++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 664a974..090fc23 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-02 Alan Modra <amodra@gmail.com>
+
+ * elf64-ppc.c (ppc64_elf_relocate_section): Don't relocate nops
+ emitted for toc sequence optimization. Set and use "howto" later.
+
2018-02-01 Simon Marchi <simon.marchi@ericsson.com>
* elf64-ppc.c (ppc64_elf_archive_symbol_lookup): Avoid pointer
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 9e4a4b5..d6ec12f 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -15067,7 +15067,6 @@ ppc64_elf_relocate_section (bfd *output_bfd,
/* Multi-instruction sequences that access the TOC can be
optimized, eg. addis ra,r2,0; addi rb,ra,x;
to nop; addi rb,r2,x; */
- howto = ppc64_elf_howto_table[(int) r_type];
switch (r_type)
{
default:
@@ -15099,6 +15098,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
{
bfd_byte *p = contents + (rel->r_offset & ~3);
bfd_put_32 (input_bfd, NOP, p);
+ goto copy_reloc;
}
break;
@@ -15140,9 +15140,13 @@ ppc64_elf_relocate_section (bfd *output_bfd,
/* xgettext:c-format */
info->callbacks->minfo
(_("%H: warning: %s unexpected insn %#x.\n"),
- input_bfd, input_section, rel->r_offset, howto->name, insn);
+ input_bfd, input_section, rel->r_offset,
+ ppc64_elf_howto_table[r_type]->name, insn);
else
- bfd_put_32 (input_bfd, NOP, p);
+ {
+ bfd_put_32 (input_bfd, NOP, p);
+ goto copy_reloc;
+ }
}
break;
@@ -15240,7 +15244,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
/* xgettext:c-format */
(_("%H: error: %s not a multiple of %u\n"),
input_bfd, input_section, rel->r_offset,
- howto->name,
+ ppc64_elf_howto_table[r_type]->name,
mask + 1);
bfd_set_error (bfd_error_bad_value);
ret = FALSE;
@@ -15252,6 +15256,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
/* Dynamic relocs are not propagated for SEC_DEBUGGING sections
because such sections are not SEC_ALLOC and thus ld.so will
not process them. */
+ howto = ppc64_elf_howto_table[(int) r_type];
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
&& h->elf.def_dynamic)