PR16794, gold ignores R_386_GOTOFF addend
authorAlan Modra <amodra@gmail.com>
Wed, 11 Sep 2019 03:52:42 +0000 (13:22 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 28 Sep 2019 07:17:52 +0000 (16:47 +0930)
An R_386_GOTOFF relocation has an addend, typically used when a
symbol can be replaced by its section symbol plus an offset.
psymval->value(object,0) is quite wrong then, fix it.

PR 16794
* i386.cc (Target_i386::Relocate::relocate <R_386_GOTOFF>): Don't
ignore addend, apply using pcrel32.
* x86_64.cc (Target_x86_64::Relocate::relocate <R_X86_64_GOTOFF64>):
Similarly use pcrel64.

gold/ChangeLog
gold/i386.cc
gold/x86_64.cc

index 964b7d760457fa058d6edf58224f70a2dc760fbe..c2acb20a74dbb38734f765cc70cabe0fc4f2069e 100644 (file)
@@ -1,3 +1,11 @@
+2019-09-28  Alan Modra  <amodra@gmail.com>
+
+       PR 16794
+       * i386.cc (Target_i386::Relocate::relocate <R_386_GOTOFF>): Don't
+       ignore addend, apply using pcrel32.
+       * x86_64.cc (Target_x86_64::Relocate::relocate <R_X86_64_GOTOFF64>):
+       Similarly use pcrel64.
+
 2019-09-24  Nick Clifton  <nickc@redhat.com>
 
        * descriptors.cc: Include <string>
index dd0b268e10bfbb49ee344946591614538cf9e665..2d3db7c2c2fd8f5ab8a36086f731d5956c2433d6 100644 (file)
@@ -2957,10 +2957,9 @@ Target_i386::Relocate::relocate(const Relocate_info<32, false>* relinfo,
 
     case elfcpp::R_386_GOTOFF:
       {
-       elfcpp::Elf_types<32>::Elf_Addr value;
-       value = (psymval->value(object, 0)
-                - target->got_plt_section()->address());
-       Relocate_functions<32, false>::rel32(view, value);
+       elfcpp::Elf_types<32>::Elf_Addr reladdr;
+       reladdr = target->got_plt_section()->address();
+       Relocate_functions<32, false>::pcrel32(view, object, psymval, reladdr);
       }
       break;
 
index c06a2822473fea62eebeaf36bc62490c456f7b59..bafd90ef5ef07cea125d08f72330bd2d32a2c544 100644 (file)
@@ -4852,10 +4852,9 @@ Target_x86_64<size>::Relocate::relocate(
 
     case elfcpp::R_X86_64_GOTOFF64:
       {
-       typename elfcpp::Elf_types<size>::Elf_Addr value;
-       value = (psymval->value(object, 0)
-                - target->got_plt_section()->address());
-       Reloc_funcs::rela64(view, value, addend);
+       typename elfcpp::Elf_types<size>::Elf_Addr reladdr;
+       reladdr = target->got_plt_section()->address();
+       Reloc_funcs::pcrela64(view, object, psymval, addend, reladdr);
       }
       break;
 
This page took 0.035137 seconds and 4 git commands to generate.