]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[GOLD] Fix powerpc64 optimization of TOC accesses
authorAlan Modra <amodra@gmail.com>
Tue, 17 Oct 2017 14:03:05 +0000 (00:33 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 17 Oct 2017 23:06:48 +0000 (09:36 +1030)
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)

gold/ChangeLog
gold/powerpc.cc

index 32c0e21f5490ded93383fd9a943d5fbb9277539d..622a63a21428800f8cd77cc6ee08d44bb1303665 100644 (file)
@@ -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
index 22590c1e435202fb004d4e9db707956279e4e7b7..b5db66549efa5910ecbcc3c47b51edf05bfa425e 100644 (file)
@@ -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;