From: Alan Modra Date: Wed, 11 Sep 2019 03:52:42 +0000 (+0930) Subject: PR16794, gold ignores R_386_GOTOFF addend X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea8e302e12bd155a3acd79290ec87d7dda2cce61;p=binutils-gdb.git PR16794, gold ignores R_386_GOTOFF addend 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 ): Don't ignore addend, apply using pcrel32. * x86_64.cc (Target_x86_64::Relocate::relocate ): Similarly use pcrel64. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index 964b7d76045..c2acb20a74d 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,11 @@ +2019-09-28 Alan Modra + + PR 16794 + * i386.cc (Target_i386::Relocate::relocate ): Don't + ignore addend, apply using pcrel32. + * x86_64.cc (Target_x86_64::Relocate::relocate ): + Similarly use pcrel64. + 2019-09-24 Nick Clifton * descriptors.cc: Include diff --git a/gold/i386.cc b/gold/i386.cc index dd0b268e10b..2d3db7c2c2f 100644 --- a/gold/i386.cc +++ b/gold/i386.cc @@ -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; diff --git a/gold/x86_64.cc b/gold/x86_64.cc index c06a2822473..bafd90ef5ef 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -4852,10 +4852,9 @@ Target_x86_64::Relocate::relocate( case elfcpp::R_X86_64_GOTOFF64: { - typename elfcpp::Elf_types::Elf_Addr value; - value = (psymval->value(object, 0) - - target->got_plt_section()->address()); - Reloc_funcs::rela64(view, value, addend); + typename elfcpp::Elf_types::Elf_Addr reladdr; + reladdr = target->got_plt_section()->address(); + Reloc_funcs::pcrela64(view, object, psymval, addend, reladdr); } break;