[binutils-gdb] Fix breakage for SHT_REL targets where get_r_addend() gives internal error.

Cary Coutant ccoutant@sourceware.org
Tue Jan 12 19:40:00 GMT 2016


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8a8880cb673893c479b473f598905c0490897817

commit 8a8880cb673893c479b473f598905c0490897817
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Tue Jan 12 11:39:50 2016 -0800

    Fix breakage for SHT_REL targets where get_r_addend() gives internal error.
    
    gold/
    	* arm.cc (Target_arm::Classify_reloc::get_r_addend): New method.
    	* i386.cc (Target_i386::Classify_reloc::get_r_addend): New method.
    	* mips.cc (Target_arm::Mips_classify_reloc::get_r_addend): (Both
    	specializations) New method.

Diff:
---
 gold/ChangeLog |  7 +++++++
 gold/arm.cc    |  8 ++++++++
 gold/i386.cc   |  8 ++++++++
 gold/mips.cc   | 12 ++++++++++--
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index c49ec6c9..c16b4a3 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2016-01-12  Cary Coutant  <ccoutant@gmail.com>
+
+	* arm.cc (Target_arm::Classify_reloc::get_r_addend): New method.
+	* i386.cc (Target_i386::Classify_reloc::get_r_addend): New method.
+	* mips.cc (Target_arm::Mips_classify_reloc::get_r_addend): (Both
+	specializations) New method.
+
 2016-01-11  Cary Coutant  <ccoutant@gmail.com>
 
 	PR gold/19353
diff --git a/gold/arm.cc b/gold/arm.cc
index 4cd0b91..ed13c87 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -2749,6 +2749,14 @@ class Target_arm : public Sized_target<32, big_endian>
       public gold::Default_classify_reloc<elfcpp::SHT_REL, 32, big_endian>
   {
    public:
+    typedef typename Reloc_types<elfcpp::SHT_REL, 32, big_endian>::Reloc
+	Reltype;
+
+    // Return the explicit addend of the relocation (return 0 for SHT_REL).
+    static typename elfcpp::Elf_types<32>::Elf_Swxword
+    get_r_addend(const Reltype*)
+    { return 0; }
+
     // Return the size of the addend of the relocation (only used for SHT_REL).
     static unsigned int
     get_size_for_reloc(unsigned int, Relobj*);
diff --git a/gold/i386.cc b/gold/i386.cc
index a7168a8..3715e5e 100644
--- a/gold/i386.cc
+++ b/gold/i386.cc
@@ -743,6 +743,14 @@ class Target_i386 : public Sized_target<32, false>
       public gold::Default_classify_reloc<elfcpp::SHT_REL, 32, false>
   {
    public:
+    typedef typename Reloc_types<elfcpp::SHT_REL, 32, false>::Reloc
+	Reltype;
+
+    // Return the explicit addend of the relocation (return 0 for SHT_REL).
+    static typename elfcpp::Elf_types<32>::Elf_Swxword
+    get_r_addend(const Reltype*)
+    { return 0; }
+
     // Return the size of the addend of the relocation (only used for SHT_REL).
     static unsigned int
     get_size_for_reloc(unsigned int, Relobj*);
diff --git a/gold/mips.cc b/gold/mips.cc
index c57ef4f..6c4f379 100644
--- a/gold/mips.cc
+++ b/gold/mips.cc
@@ -2964,7 +2964,11 @@ class Mips_classify_reloc<sh_type_, 32, big_endian> :
   // Return the explicit addend of the relocation (return 0 for SHT_REL).
   static inline unsigned int
   get_r_addend(const Reltype* reloc)
-  { return Mips_reloc_types<sh_type_, 32, big_endian>::get_r_addend(reloc); }
+  {
+    if (sh_type_ == elfcpp::SHT_REL)
+      return 0;
+    return Mips_reloc_types<sh_type_, 32, big_endian>::get_r_addend(reloc);
+  }
 
   // Write the r_info field to a new reloc, using the r_info field from
   // the original reloc, replacing the r_sym field with R_SYM.
@@ -3010,7 +3014,11 @@ class Mips_classify_reloc<sh_type_, 64, big_endian> :
   // Return the explicit addend of the relocation (return 0 for SHT_REL).
   static inline typename elfcpp::Elf_types<64>::Elf_Swxword
   get_r_addend(const Reltype* reloc)
-  { return Mips_reloc_types<sh_type_, 64, big_endian>::get_r_addend(reloc); }
+  {
+    if (sh_type_ == elfcpp::SHT_REL)
+      return 0;
+    return Mips_reloc_types<sh_type_, 64, big_endian>::get_r_addend(reloc);
+  }
 
   // Write the r_info field to a new reloc, using the r_info field from
   // the original reloc, replacing the r_sym field with R_SYM.



More information about the Binutils-cvs mailing list