PR 9766
[deliverable/binutils-gdb.git] / gold / powerpc.cc
index 1eb72697a28fdfc5eaac556324b305a61cee2d63..2d1d9844ca7b92517f462673961959354f7cff46 100644 (file)
@@ -129,7 +129,7 @@ class Target_powerpc : public Sized_target<size, big_endian>
 
   // Return whether SYM is defined by the ABI.
   bool
-  do_is_defined_by_abi(Symbol* sym) const
+  do_is_defined_by_abi(const Symbol* sym) const
   {
     return strcmp(sym->name(), "___tls_get_addr") == 0;
   }
@@ -280,7 +280,8 @@ class Target_powerpc : public Sized_target<size, big_endian>
 
   // Copy a relocation against a global symbol.
   void
-  copy_reloc(Symbol_table* symtab, Layout* layout, Relobj* object,
+  copy_reloc(Symbol_table* symtab, Layout* layout,
+             Sized_relobj<size, big_endian>* object,
             unsigned int shndx, Output_section* output_section,
             Symbol* sym, const elfcpp::Rela<size, big_endian>& reloc)
   {
@@ -594,9 +595,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 +603,7 @@ public:
       reloc += 0x10000;
     reloc >>= 16;
 
-    val &= ~0xffff;
-    reloc &= 0xffff;
-
-    elfcpp::Swap<16, true>::writeval(wv, val | reloc);
+    elfcpp::Swap<16, big_endian>::writeval(view, reloc);
   }
 
   static inline void
@@ -617,9 +612,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 +620,7 @@ public:
       reloc += 0x10000;
     reloc >>= 16;
 
-    val &= ~0xffff;
-    reloc &= 0xffff;
-
-    elfcpp::Swap<16, true>::writeval(wv, val | reloc);
+    elfcpp::Swap<16, big_endian>::writeval(view, reloc);
   }
 
   // R_PPC_REL16: (Symbol + Addend - Address) & 0xffff
@@ -674,9 +663,6 @@ public:
           typename elfcpp::Elf_types<size>::Elf_Addr addend,
           typename elfcpp::Elf_types<size>::Elf_Addr address)
   {
-    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) - address);
@@ -684,10 +670,7 @@ public:
       reloc += 0x10000;
     reloc >>= 16;
 
-    val &= ~0xffff;
-    reloc &= 0xffff;
-
-    elfcpp::Swap<16, true>::writeval(wv, val | reloc);
+    elfcpp::Swap<16, big_endian>::writeval(view, reloc);
   }
 };
 
@@ -1558,10 +1541,12 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
   // Pick the value to use for symbols defined in shared objects.
   Symbol_value<size> symval;
   if (gsym != NULL
-      && (gsym->is_from_dynobj()
-          || (parameters->options().shared()
-              && (gsym->is_undefined() || gsym->is_preemptible())))
-      && gsym->has_plt_offset())
+      && gsym->use_plt_offset(r_type == elfcpp::R_POWERPC_REL24
+                             || r_type == elfcpp::R_PPC_LOCAL24PC
+                             || r_type == elfcpp::R_PPC_REL16
+                             || r_type == elfcpp::R_PPC_REL16_LO
+                             || r_type == elfcpp::R_PPC_REL16_HI
+                             || r_type == elfcpp::R_PPC_REL16_HA))
     {
       elfcpp::Elf_Xword value;
 
@@ -1690,7 +1675,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
       break;
 
     case elfcpp::R_PPC_REL16_HA:
-      Reloc::rel16_lo(view, object, psymval, addend, address);
+      Reloc::rel16_ha(view, object, psymval, addend, address);
       break;
 
     case elfcpp::R_POWERPC_GOT16:
This page took 0.025555 seconds and 4 git commands to generate.