This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_29-branch] [GOLD] Fix powerpc64 optimization of TOC accesses
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 17 Oct 2017 23:07:03 -0000
- Subject: [binutils-gdb/binutils-2_29-branch] [GOLD] Fix powerpc64 optimization of TOC accesses
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ac7c988b464401474d73c68f1bd59dffe42a84a8
commit ac7c988b464401474d73c68f1bd59dffe42a84a8
Author: Alan Modra <amodra@gmail.com>
Date: Wed Oct 18 00:33:05 2017 +1030
[GOLD] Fix powerpc64 optimization of TOC accesses
Fixes a thinko. Given code that puts variables into the TOC (a bad
idea, but some see the TOC as a small data section) this bug could
result in an attempt to optimize a sequence that should not be
optimized.
* powerpc.cc (Target_powerpc::Scan::local): Correct dst_off
calculation for TOC16 relocs.
(Target_powerpc::Scan::global): Likewise.
(cherry picked from commit 412294daf8786fd9060059b8be7fc59a35e13922)
Diff:
---
gold/ChangeLog | 7 +++++++
gold/powerpc.cc | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 32c0e21..622a63a 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2017-10-18 Kyle Butt <iteratee@google.com>
+ Alan Modra <amodra@gmail.com>
+
+ * powerpc.cc (Target_powerpc::Scan::local): Correct dst_off
+ calculation for TOC16 relocs.
+ (Target_powerpc::Scan::global): Likewise.
+
2017-09-28 Alan Modra <amodra@gmail.com>
* powerpc.cc (Target_powerpc<64,*>::powerpc_info): Set
diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index 22590c1..b5db665 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -6649,7 +6649,7 @@ Target_powerpc<size, big_endian>::Scan::local(
shndx = ppc_object->adjust_sym_shndx(r_sym, shndx, &is_ordinary);
if (is_ordinary && shndx == ppc_object->toc_shndx())
{
- Address dst_off = lsym.get_st_value() + reloc.get_r_offset();
+ Address dst_off = lsym.get_st_value() + reloc.get_r_addend();
if (dst_off < ppc_object->section_size(shndx))
{
bool ok = false;
@@ -7317,7 +7317,7 @@ Target_powerpc<size, big_endian>::Scan::global(
if (shndx == sym_object->toc_shndx())
{
Sized_symbol<size>* sym = symtab->get_sized_symbol<size>(gsym);
- Address dst_off = sym->value() + reloc.get_r_offset();
+ Address dst_off = sym->value() + reloc.get_r_addend();
if (dst_off < sym_object->section_size(shndx))
{
bool ok = false;