This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH COMMITTED: Fix overflow warnings by deleting code


I took a closer look at the overflow warnings in gold/powerpc.cc.
They are actually from code that is unused.  The existing code loads a
16-bit value and then clears the low 16 bits.  That is pointless.  I
deleted that code, which eliminates the overflow warnings.

I also changed the code to use the template endianness when writing
out the value, which seems like the right thing to do and is
consistent with the other relocation handling.

Ian


2008-06-30  Ian Lance Taylor  <iant@google.com>

	PR 6660
	PR 6682
	* powerpc.cc (Powerpc_relocate_functions::addr16_ha) [both
	versions]: Don't try to read the value in the contents, since we
	don't use it.  Use the template endianness when writing.


Index: powerpc.cc
===================================================================
RCS file: /cvs/src/src/gold/powerpc.cc,v
retrieving revision 1.3
diff -u -u -p -r1.3 powerpc.cc
--- powerpc.cc	18 Jun 2008 22:32:37 -0000	1.3
+++ powerpc.cc	30 Jun 2008 16:33:11 -0000
@@ -594,9 +594,6 @@ public:
 	    typename elfcpp::Elf_types<size>::Elf_Addr value,
 	    typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
-    typedef typename elfcpp::Swap<16, true>::Valtype Valtype;
-    Valtype* wv = reinterpret_cast<Valtype*>(view);
-    Valtype val = elfcpp::Swap<16, true>::readval(wv);
     typename elfcpp::Elf_types<size>::Elf_Addr reloc;
 
     reloc = value + addend;
@@ -605,10 +602,7 @@ public:
       reloc += 0x10000;
     reloc >>= 16;
 
-    val &= ~static_cast<Valtype>(0xffff);
-    reloc &= static_cast<Valtype>(0xffff);
-
-    elfcpp::Swap<16, true>::writeval(wv, val | reloc);
+    elfcpp::Swap<16, big_endian>::writeval(view, reloc);
   }
 
   static inline void
@@ -617,9 +611,6 @@ public:
 	    const Symbol_value<size>* psymval,
 	    typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
-    typedef typename elfcpp::Swap<16, true>::Valtype Valtype;
-    Valtype* wv = reinterpret_cast<Valtype*>(view);
-    Valtype val = elfcpp::Swap<16, true>::readval(wv);
     typename elfcpp::Elf_types<size>::Elf_Addr reloc;
 
     reloc = psymval->value(object, addend);
@@ -628,10 +619,7 @@ public:
       reloc += 0x10000;
     reloc >>= 16;
 
-    val &= ~static_cast<Valtype>(0xffff);
-    reloc &= static_cast<Valtype>(0xffff);
-
-    elfcpp::Swap<16, true>::writeval(wv, val | reloc);
+    elfcpp::Swap<16, big_endian>::writeval(view, reloc);
   }
 
   // R_PPC_REL16: (Symbol + Addend - Address) & 0xffff

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]