2010-03-22 Doug Kwan <dougkwan@google.com>
[binutils-gdb.git] / gold / sparc.cc
index 43c6e34b0b9ccb09bde296df9e7cee4604eaea7d..e2d59b943a47fd99995b8e11fdfe71334c23cf87 100644 (file)
@@ -193,6 +193,29 @@ class Target_sparc : public Sized_target<size, big_endian>
           const elfcpp::Rela<size, big_endian>& reloc, unsigned int r_type,
           Symbol* gsym);
 
+    inline bool
+    local_reloc_may_be_function_pointer(Symbol_table* , Layout* ,
+                                       Target_sparc* ,
+                                       Sized_relobj<size, big_endian>* ,
+                                               unsigned int ,
+                                       Output_section* ,
+                                       const elfcpp::Rela<size, big_endian>& ,
+                                       unsigned int ,
+                                       const elfcpp::Sym<size, big_endian>&)
+    { return false; }
+
+    inline bool
+    global_reloc_may_be_function_pointer(Symbol_table* , Layout* ,
+                                        Target_sparc* ,
+                                        Sized_relobj<size, big_endian>* ,
+                                        unsigned int ,
+                                        Output_section* ,
+                                        const elfcpp::Rela<size,
+                                                           big_endian>& ,
+                                        unsigned int , Symbol*)
+    { return false; }
+
+
   private:
     static void
     unsupported_reloc_local(Sized_relobj<size, big_endian>*,
@@ -401,13 +424,13 @@ private:
   rela(unsigned char* view,
        unsigned int right_shift,
        typename elfcpp::Elf_types<valsize>::Elf_Addr dst_mask,
-       typename elfcpp::Swap<size, big_endian>::Valtype avalue,
+       typename elfcpp::Swap<size, big_endian>::Valtype value,
        typename elfcpp::Swap<size, big_endian>::Valtype addend)
   {
     typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
     Valtype* wv = reinterpret_cast<Valtype*>(view);
     Valtype val = elfcpp::Swap<valsize, big_endian>::readval(wv);
-    Valtype reloc = ((avalue + addend) >> right_shift);
+    Valtype reloc = ((value + addend) >> right_shift);
 
     val &= ~dst_mask;
     reloc &= dst_mask;
@@ -589,10 +612,10 @@ public:
   // R_SPARC_HI22: (Symbol + Addend) >> 10
   static inline void
   hi22(unsigned char* view,
-       typename elfcpp::Elf_types<size>::Elf_Addr avalue,
+       typename elfcpp::Elf_types<size>::Elf_Addr value,
        typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
-    This_insn::template rela<32>(view, 10, 0x003fffff, avalue, addend);
+    This_insn::template rela<32>(view, 10, 0x003fffff, value, addend);
   }
 
   // R_SPARC_HI22: (Symbol + Addend) >> 10
@@ -620,10 +643,10 @@ public:
   // R_SPARC_LO10: (Symbol + Addend) & 0x3ff
   static inline void
   lo10(unsigned char* view,
-       typename elfcpp::Elf_types<size>::Elf_Addr avalue,
+       typename elfcpp::Elf_types<size>::Elf_Addr value,
        typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
-    This_insn::template rela<32>(view, 0, 0x000003ff, avalue, addend);
+    This_insn::template rela<32>(view, 0, 0x000003ff, value, addend);
   }
 
   // R_SPARC_LO10: (Symbol + Addend) & 0x3ff
@@ -682,10 +705,10 @@ public:
   // R_SPARC_13: (Symbol + Addend)
   static inline void
   rela32_13(unsigned char* view,
-           typename elfcpp::Elf_types<size>::Elf_Addr avalue,
+           typename elfcpp::Elf_types<size>::Elf_Addr value,
            typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
-    This_insn::template rela<32>(view, 0, 0x00001fff, avalue, addend);
+    This_insn::template rela<32>(view, 0, 0x00001fff, value, addend);
   }
 
   // R_SPARC_13: (Symbol + Addend)
@@ -904,22 +927,22 @@ public:
   // R_SPARC_TLS_LDO_HIX22: @dtpoff(Symbol + Addend) >> 10
   static inline void
   ldo_hix22(unsigned char* view,
-           typename elfcpp::Elf_types<size>::Elf_Addr avalue,
+           typename elfcpp::Elf_types<size>::Elf_Addr value,
            typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
-    This_insn::hi22(view, avalue, addend);
+    This_insn::hi22(view, value, addend);
   }
 
   // R_SPARC_TLS_LDO_LOX10: @dtpoff(Symbol + Addend) & 0x3ff
   static inline void
   ldo_lox10(unsigned char* view,
-           typename elfcpp::Elf_types<size>::Elf_Addr avalue,
+           typename elfcpp::Elf_types<size>::Elf_Addr value,
            typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
     typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
     Valtype* wv = reinterpret_cast<Valtype*>(view);
     Valtype val = elfcpp::Swap<32, true>::readval(wv);
-    Valtype reloc = (avalue + addend);
+    Valtype reloc = (value + addend);
 
     val &= ~0x1fff;
     reloc &= 0x3ff;
@@ -930,13 +953,13 @@ public:
   // R_SPARC_TLS_LE_HIX22: (@tpoff(Symbol + Addend) ^ 0xffffffffffffffff) >> 10
   static inline void
   hix22(unsigned char* view,
-       typename elfcpp::Elf_types<size>::Elf_Addr avalue,
+       typename elfcpp::Elf_types<size>::Elf_Addr value,
        typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
     typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
     Valtype* wv = reinterpret_cast<Valtype*>(view);
     Valtype val = elfcpp::Swap<32, true>::readval(wv);
-    Valtype reloc = (avalue + addend);
+    Valtype reloc = (value + addend);
 
     val &= ~0x3fffff;
 
@@ -974,13 +997,13 @@ public:
   // R_SPARC_TLS_LE_LOX10: (@tpoff(Symbol + Addend) & 0x3ff) | 0x1c00
   static inline void
   lox10(unsigned char* view,
-       typename elfcpp::Elf_types<size>::Elf_Addr avalue,
+       typename elfcpp::Elf_types<size>::Elf_Addr value,
        typename elfcpp::Elf_types<size>::Elf_Addr addend)
   {
     typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
     Valtype* wv = reinterpret_cast<Valtype*>(view);
     Valtype val = elfcpp::Swap<32, true>::readval(wv);
-    Valtype reloc = (avalue + addend);
+    Valtype reloc = (value + addend);
 
     val &= ~0x1fff;
     reloc &= 0x3ff;
@@ -1026,11 +1049,12 @@ Target_sparc<size, big_endian>::got_section(Symbol_table* symtab,
       os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
                                           (elfcpp::SHF_ALLOC
                                            | elfcpp::SHF_WRITE),
-                                          this->got_, false);
-      os->set_is_relro();
+                                          this->got_, false, true, false,
+                                          false);
 
       // Define _GLOBAL_OFFSET_TABLE_ at the start of the .got section.
       symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
+                                   Symbol_table::PREDEFINED,
                                    this->got_,
                                    0, 0, elfcpp::STT_OBJECT,
                                    elfcpp::STB_LOCAL,
@@ -1052,7 +1076,8 @@ Target_sparc<size, big_endian>::rela_dyn_section(Layout* layout)
       gold_assert(layout != NULL);
       this->rela_dyn_ = new Reloc_section(parameters->options().combreloc());
       layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA,
-                                     elfcpp::SHF_ALLOC, this->rela_dyn_, true);
+                                     elfcpp::SHF_ALLOC, this->rela_dyn_, true,
+                                     false, false, false);
     }
   return this->rela_dyn_;
 }
@@ -1154,7 +1179,8 @@ Output_data_plt_sparc<size, big_endian>::Output_data_plt_sparc(Layout* layout)
 {
   this->rel_ = new Reloc_section(false);
   layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA,
-                                 elfcpp::SHF_ALLOC, this->rel_, true);
+                                 elfcpp::SHF_ALLOC, this->rel_, true,
+                                 false, false, false);
 }
 
 template<int size, bool big_endian>
@@ -1220,10 +1246,10 @@ template<int size, bool big_endian>
 void
 Output_data_plt_sparc<size, big_endian>::do_write(Output_file* of)
 {
-  const off_t off = this->offset();
+  const off_t offset = this->offset();
   const section_size_type oview_size =
     convert_to_section_size_type(this->data_size());
-  unsigned char* const oview = of->get_output_view(off, oview_size);
+  unsigned char* const oview = of->get_output_view(offset, oview_size);
   unsigned char* pov = oview;
 
   memset(pov, 0, base_plt_entry_size * 4);
@@ -1347,7 +1373,7 @@ Output_data_plt_sparc<size, big_endian>::do_write(Output_file* of)
 
   gold_assert(static_cast<section_size_type>(pov - oview) == oview_size);
 
-  of->write_output_view(off, oview_size, oview);
+  of->write_output_view(offset, oview_size, oview);
 }
 
 // Create a PLT entry for a global symbol.
@@ -1366,15 +1392,21 @@ Target_sparc<size, big_endian>::make_plt_entry(Symbol_table* symtab,
       // Create the GOT sections first.
       this->got_section(symtab, layout);
 
+      // Ensure that .rela.dyn always appears before .rela.plt  This is
+      // necessary due to how, on Sparc and some other targets, .rela.dyn
+      // needs to include .rela.plt in it's range.
+      this->rela_dyn_section(layout);
+
       this->plt_ = new Output_data_plt_sparc<size, big_endian>(layout);
       layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
                                      (elfcpp::SHF_ALLOC
                                       | elfcpp::SHF_EXECINSTR
                                       | elfcpp::SHF_WRITE),
-                                     this->plt_, false);
+                                     this->plt_, false, false, false, false);
 
       // Define _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section.
       symtab->define_in_output_data("_PROCEDURE_LINKAGE_TABLE_", NULL,
+                                   Symbol_table::PREDEFINED,
                                    this->plt_,
                                    0, 0, elfcpp::STT_OBJECT,
                                    elfcpp::STB_LOCAL,
@@ -1666,28 +1698,28 @@ Target_sparc<size, big_endian>::Scan::local(
       if (parameters->options().output_is_position_independent())
         {
           Reloc_section* rela_dyn = target->rela_dyn_section(layout);
+          unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
 
          check_non_pic(object, r_type);
           if (lsym.get_st_type() != elfcpp::STT_SECTION)
             {
-              unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
               rela_dyn->add_local(object, r_sym, orig_r_type, output_section,
                                  data_shndx, reloc.get_r_offset(),
                                  reloc.get_r_addend());
             }
           else
             {
-             unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
               gold_assert(lsym.get_st_value() == 0);
-              rela_dyn->add_local_relative(object, r_sym, orig_r_type,
-                                          output_section, data_shndx,
-                                          reloc.get_r_offset(),
-                                          reloc.get_r_addend());
+             rela_dyn->add_symbolless_local_addend(object, r_sym, orig_r_type,
+                                                   output_section, data_shndx,
+                                                   reloc.get_r_offset(),
+                                                   reloc.get_r_addend());
             }
         }
       break;
 
     case elfcpp::R_SPARC_WDISP30:
+    case elfcpp::R_SPARC_WPLT30:
     case elfcpp::R_SPARC_WDISP22:
     case elfcpp::R_SPARC_WDISP19:
     case elfcpp::R_SPARC_WDISP16:
@@ -1699,6 +1731,9 @@ Target_sparc<size, big_endian>::Scan::local(
     case elfcpp::R_SPARC_PC22:
       break;
 
+    case elfcpp::R_SPARC_GOTDATA_OP:
+    case elfcpp::R_SPARC_GOTDATA_OP_HIX22:
+    case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
     case elfcpp::R_SPARC_GOT10:
     case elfcpp::R_SPARC_GOT13:
     case elfcpp::R_SPARC_GOT22:
@@ -1829,13 +1864,13 @@ Target_sparc<size, big_endian>::Scan::local(
                    Reloc_section* rela_dyn = target->rela_dyn_section(layout);
                    unsigned int off = got->add_constant(0);
 
-                   object->set_local_got_offset(r_sym, GOT_TYPE_TLS_OFFSET,
-                                                off);
-                   rela_dyn->add_local_relative(object, r_sym,
-                                                (size == 64 ?
-                                                 elfcpp::R_SPARC_TLS_TPOFF64 :
-                                                 elfcpp::R_SPARC_TLS_TPOFF32),
-                                                got, off, 0);
+                   object->set_local_got_offset(r_sym, GOT_TYPE_TLS_OFFSET, off);
+
+                   rela_dyn->add_symbolless_local_addend(object, r_sym,
+                                                         (size == 64 ?
+                                                          elfcpp::R_SPARC_TLS_TPOFF64 :
+                                                          elfcpp::R_SPARC_TLS_TPOFF32),
+                                                         got, off, 0);
                  }
              }
            else if (optimized_type != tls::TLSOPT_TO_LE)
@@ -1851,9 +1886,9 @@ Target_sparc<size, big_endian>::Scan::local(
                 gold_assert(lsym.get_st_type() != elfcpp::STT_SECTION);
                 unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
                 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
-                rela_dyn->add_local_relative(object, r_sym, r_type,
-                                            output_section, data_shndx,
-                                            reloc.get_r_offset(), 0);
+                rela_dyn->add_symbolless_local_addend(object, r_sym, r_type,
+                                                     output_section, data_shndx,
+                                                     reloc.get_r_offset(), 0);
              }
            break;
          }
@@ -2028,6 +2063,38 @@ Target_sparc<size, big_endian>::Scan::global(
         // Make a dynamic relocation if necessary.
         if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
           {
+           unsigned int r_off = reloc.get_r_offset();
+
+           // The assembler can sometimes emit unaligned relocations
+           // for dwarf2 cfi directives. 
+           switch (r_type)
+             {
+             case elfcpp::R_SPARC_16:
+               if (r_off & 0x1)
+                 orig_r_type = r_type = elfcpp::R_SPARC_UA16;
+               break;
+             case elfcpp::R_SPARC_32:
+               if (r_off & 0x3)
+                 orig_r_type = r_type = elfcpp::R_SPARC_UA32;
+               break;
+             case elfcpp::R_SPARC_64:
+               if (r_off & 0x7)
+                 orig_r_type = r_type = elfcpp::R_SPARC_UA64;
+               break;
+             case elfcpp::R_SPARC_UA16:
+               if (!(r_off & 0x1))
+                 orig_r_type = r_type = elfcpp::R_SPARC_16;
+               break;
+             case elfcpp::R_SPARC_UA32:
+               if (!(r_off & 0x3))
+                 orig_r_type = r_type = elfcpp::R_SPARC_32;
+               break;
+             case elfcpp::R_SPARC_UA64:
+               if (!(r_off & 0x7))
+                 orig_r_type = r_type = elfcpp::R_SPARC_64;
+               break;
+             }
+
             if (gsym->may_need_copy_reloc())
               {
                target->copy_reloc(symtab, layout, object,
@@ -2056,16 +2123,19 @@ Target_sparc<size, big_endian>::Scan::global(
                                       reloc.get_r_offset(),
                                       reloc.get_r_addend());
                else
-                 rela_dyn->add_global_relative(gsym, orig_r_type,
-                                               output_section, object,
-                                               data_shndx,
-                                               reloc.get_r_offset(),
-                                               reloc.get_r_addend());
+                 rela_dyn->add_symbolless_global_addend(gsym, orig_r_type,
+                                                        output_section,
+                                                        object, data_shndx,
+                                                        reloc.get_r_offset(),
+                                                        reloc.get_r_addend());
               }
           }
       }
       break;
 
+    case elfcpp::R_SPARC_GOTDATA_OP:
+    case elfcpp::R_SPARC_GOTDATA_OP_HIX22:
+    case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
     case elfcpp::R_SPARC_GOT10:
     case elfcpp::R_SPARC_GOT13:
     case elfcpp::R_SPARC_GOT22:
@@ -2189,10 +2259,10 @@ Target_sparc<size, big_endian>::Scan::global(
            if (parameters->options().shared())
              {
                Reloc_section* rela_dyn = target->rela_dyn_section(layout);
-               rela_dyn->add_global_relative(gsym, orig_r_type,
-                                             output_section, object,
-                                             data_shndx, reloc.get_r_offset(),
-                                             0);
+               rela_dyn->add_symbolless_global_addend(gsym, orig_r_type,
+                                                      output_section, object,
+                                                      data_shndx, reloc.get_r_offset(),
+                                                      0);
              }
            break;
 
@@ -2260,9 +2330,9 @@ Target_sparc<size, big_endian>::gc_process_relocs(
                        const unsigned char* plocal_symbols)
 {
   typedef Target_sparc<size, big_endian> Sparc;
-  typedef typename Target_sparc<size, big_endian>::Scan scan;
+  typedef typename Target_sparc<size, big_endian>::Scan Scan;
 
-  gold::gc_process_relocs<size, big_endian, Sparc, elfcpp::SHT_RELA, scan>(
+  gold::gc_process_relocs<size, big_endian, Sparc, elfcpp::SHT_RELA, Scan>(
     symtab,
     layout,
     this,
@@ -2294,7 +2364,7 @@ Target_sparc<size, big_endian>::scan_relocs(
                        const unsigned char* plocal_symbols)
 {
   typedef Target_sparc<size, big_endian> Sparc;
-  typedef typename Target_sparc<size, big_endian>::Scan scan;
+  typedef typename Target_sparc<size, big_endian>::Scan Scan;
 
   if (sh_type == elfcpp::SHT_REL)
     {
@@ -2303,7 +2373,7 @@ Target_sparc<size, big_endian>::scan_relocs(
       return;
     }
 
-  gold::scan_relocs<size, big_endian, Sparc, elfcpp::SHT_RELA, scan>(
+  gold::scan_relocs<size, big_endian, Sparc, elfcpp::SHT_RELA, Scan>(
     symtab,
     layout,
     this,
@@ -2327,37 +2397,11 @@ Target_sparc<size, big_endian>::do_finalize_sections(
     Symbol_table*)
 {
   // Fill in some more dynamic tags.
-  Output_data_dynamic* const odyn = layout->dynamic_data();
-  if (odyn != NULL)
-    {
-      if (this->plt_ != NULL
-         && this->plt_->output_section() != NULL)
-       {
-         const Output_data* od = this->plt_->rel_plt();
-         odyn->add_section_size(elfcpp::DT_PLTRELSZ, od);
-         odyn->add_section_address(elfcpp::DT_JMPREL, od);
-         odyn->add_constant(elfcpp::DT_PLTREL, elfcpp::DT_RELA);
-
-         odyn->add_section_address(elfcpp::DT_PLTGOT, this->plt_);
-       }
-
-      if (this->rela_dyn_ != NULL
-         && this->rela_dyn_->output_section() != NULL)
-       {
-         const Output_data* od = this->rela_dyn_;
-         odyn->add_section_address(elfcpp::DT_RELA, od);
-         odyn->add_section_size(elfcpp::DT_RELASZ, od);
-         odyn->add_constant(elfcpp::DT_RELAENT,
-                            elfcpp::Elf_sizes<size>::rela_size);
-       }
-
-      if (!parameters->options().shared())
-       {
-         // The value of the DT_DEBUG tag is filled in by the dynamic
-         // linker at run time, and used by the debugger.
-         odyn->add_constant(elfcpp::DT_DEBUG, 0);
-       }
-    }
+  const Reloc_section* rel_plt = (this->plt_ == NULL
+                                 ? NULL
+                                 : this->plt_->rel_plt());
+  layout->add_target_dynamic_tags(false, this->plt_, rel_plt,
+                                 this->rela_dyn_, true, true);
 
   // Emit any relocs we saved in an attempt to avoid generating COPY
   // relocs.
@@ -2415,11 +2459,11 @@ Target_sparc<size, big_endian>::Relocate::relocate(
                              || r_type == elfcpp::R_SPARC_WDISP19
                              || r_type == elfcpp::R_SPARC_WDISP16))
     {
-      elfcpp::Elf_Xword avalue;
+      elfcpp::Elf_Xword value;
 
-      avalue = target->plt_section()->address() + gsym->plt_offset();
+      value = target->plt_section()->address() + gsym->plt_offset();
 
-      symval.set_output_value(avalue);
+      symval.set_output_value(value);
 
       psymval = &symval;
     }
@@ -2434,6 +2478,9 @@ Target_sparc<size, big_endian>::Relocate::relocate(
   unsigned int got_offset = 0;
   switch (r_type)
     {
+    case elfcpp::R_SPARC_GOTDATA_OP:
+    case elfcpp::R_SPARC_GOTDATA_OP_HIX22:
+    case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
     case elfcpp::R_SPARC_GOT10:
     case elfcpp::R_SPARC_GOT13:
     case elfcpp::R_SPARC_GOT22:
@@ -2469,14 +2516,30 @@ Target_sparc<size, big_endian>::Relocate::relocate(
       break;
 
     case elfcpp::R_SPARC_16:
-      Relocate_functions<size, big_endian>::rela16(view, object,
-                                                  psymval, addend);
+      if (rela.get_r_offset() & 0x1)
+       {
+         // The assembler can sometimes emit unaligned relocations
+         // for dwarf2 cfi directives. 
+         Reloc::ua16(view, object, psymval, addend);
+       }
+      else
+       Relocate_functions<size, big_endian>::rela16(view, object,
+                                                    psymval, addend);
       break;
 
     case elfcpp::R_SPARC_32:
       if (!parameters->options().output_is_position_independent())
-       Relocate_functions<size, big_endian>::rela32(view, object,
-                                                    psymval, addend);
+       {
+         if (rela.get_r_offset() & 0x3)
+           {
+             // The assembler can sometimes emit unaligned relocations
+             // for dwarf2 cfi directives. 
+             Reloc::ua32(view, object, psymval, addend);
+           }
+         else
+           Relocate_functions<size, big_endian>::rela32(view, object,
+                                                        psymval, addend);
+       }
       break;
 
     case elfcpp::R_SPARC_DISP8:
@@ -2532,10 +2595,15 @@ Target_sparc<size, big_endian>::Relocate::relocate(
       Reloc::lo10(view, got_offset, addend);
       break;
 
+    case elfcpp::R_SPARC_GOTDATA_OP:
+      break;
+
+    case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
     case elfcpp::R_SPARC_GOT13:
       Reloc::rela32_13(view, got_offset, addend);
       break;
 
+    case elfcpp::R_SPARC_GOTDATA_OP_HIX22:
     case elfcpp::R_SPARC_GOT22:
       Reloc::hi22(view, got_offset, addend);
       break;
@@ -2585,8 +2653,17 @@ Target_sparc<size, big_endian>::Relocate::relocate(
 
     case elfcpp::R_SPARC_64:
       if (!parameters->options().output_is_position_independent())
-             Relocate_functions<size, big_endian>::rela64(view, object,
-                                                          psymval, addend);
+       {
+         if (rela.get_r_offset() & 0x7)
+           {
+             // The assembler can sometimes emit unaligned relocations
+             // for dwarf2 cfi directives. 
+             Reloc::ua64(view, object, psymval, addend);
+           }
+         else
+           Relocate_functions<size, big_endian>::rela64(view, object,
+                                                        psymval, addend);
+       }
       break;
 
     case elfcpp::R_SPARC_OLO10:
@@ -2740,7 +2817,7 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
   typedef typename elfcpp::Swap<32, true>::Valtype Insntype;
 
   const elfcpp::Elf_Xword addend = rela.get_r_addend();
-  typename elfcpp::Elf_types<size>::Elf_Addr avalue = psymval->value(object, 0);
+  typename elfcpp::Elf_types<size>::Elf_Addr value = psymval->value(object, 0);
 
   const bool is_final =
     (gsym == NULL
@@ -2760,18 +2837,18 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
          Insntype* wv = reinterpret_cast<Insntype*>(view);
          Insntype val;
 
-         avalue -= tls_segment->memsz();
+         value -= tls_segment->memsz();
 
          switch (r_type)
            {
            case elfcpp::R_SPARC_TLS_GD_HI22:
              // TLS_GD_HI22 --> TLS_LE_HIX22
-             Reloc::hix22(view, avalue, addend);
+             Reloc::hix22(view, value, addend);
              break;
 
            case elfcpp::R_SPARC_TLS_GD_LO10:
              // TLS_GD_LO10 --> TLS_LE_LOX10
-             Reloc::lox10(view, avalue, addend);
+             Reloc::lox10(view, value, addend);
              break;
 
            case elfcpp::R_SPARC_TLS_GD_ADD:
@@ -2795,13 +2872,13 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
           if (gsym != NULL)
             {
               gold_assert(gsym->has_got_offset(got_type));
-              avalue = gsym->got_offset(got_type);
+              value = gsym->got_offset(got_type);
             }
           else
             {
               unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
               gold_assert(object->local_has_got_offset(r_sym, got_type));
-              avalue = object->local_got_offset(r_sym, got_type);
+              value = object->local_got_offset(r_sym, got_type);
             }
           if (optimized_type == tls::TLSOPT_TO_IE)
            {
@@ -2812,12 +2889,12 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
                {
                case elfcpp::R_SPARC_TLS_GD_HI22:
                  // TLS_GD_HI22 --> TLS_IE_HI22
-                 Reloc::hi22(view, avalue, addend);
+                 Reloc::hi22(view, value, addend);
                  break;
 
                case elfcpp::R_SPARC_TLS_GD_LO10:
                  // TLS_GD_LO10 --> TLS_IE_LO10
-                 Reloc::lo10(view, avalue, addend);
+                 Reloc::lo10(view, value, addend);
                  break;
 
                case elfcpp::R_SPARC_TLS_GD_ADD:
@@ -2867,24 +2944,24 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
              switch (r_type)
                {
                case elfcpp::R_SPARC_TLS_GD_HI22:
-                 Reloc::hi22(view, avalue, addend);
+                 Reloc::hi22(view, value, addend);
                  break;
                case elfcpp::R_SPARC_TLS_GD_LO10:
-                 Reloc::lo10(view, avalue, addend);
+                 Reloc::lo10(view, value, addend);
                  break;
                case elfcpp::R_SPARC_TLS_GD_ADD:
                  break;
                case elfcpp::R_SPARC_TLS_GD_CALL:
                  {
                    Symbol_value<size> symval;
-                   elfcpp::Elf_Xword xvalue;
+                   elfcpp::Elf_Xword value;
                    Symbol* tsym;
 
                    tsym = target->tls_get_addr_sym_;
                    gold_assert(tsym);
-                   xvalue = (target->plt_section()->address() +
-                             tsym->plt_offset());
-                   symval.set_output_value(xvalue);
+                   value = (target->plt_section()->address() +
+                            tsym->plt_offset());
+                   symval.set_output_value(value);
                    Reloc::wdisp30(view, object, &symval, addend, address);
                  }
                  break;
@@ -2939,14 +3016,14 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
            case elfcpp::R_SPARC_TLS_LDM_CALL:
              {
                Symbol_value<size> symval;
-               elfcpp::Elf_Xword xvalue;
+               elfcpp::Elf_Xword value;
                Symbol* tsym;
 
                tsym = target->tls_get_addr_sym_;
                gold_assert(tsym);
-               xvalue = (target->plt_section()->address() +
-                         tsym->plt_offset());
-               symval.set_output_value(xvalue);
+               value = (target->plt_section()->address() +
+                        tsym->plt_offset());
+               symval.set_output_value(value);
                Reloc::wdisp30(view, object, &symval, addend, address);
              }
              break;
@@ -2964,20 +3041,20 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
     case elfcpp::R_SPARC_TLS_LDO_HIX22:
       if (optimized_type == tls::TLSOPT_TO_LE)
        {
-         avalue -= tls_segment->memsz();
-         Reloc::hix22(view, avalue, addend);
+         value -= tls_segment->memsz();
+         Reloc::hix22(view, value, addend);
        }
       else
-       Reloc::ldo_hix22(view, avalue, addend);
+       Reloc::ldo_hix22(view, value, addend);
       break;
     case elfcpp::R_SPARC_TLS_LDO_LOX10:
       if (optimized_type == tls::TLSOPT_TO_LE)
        {
-         avalue -= tls_segment->memsz();
-         Reloc::lox10(view, avalue, addend);
+         value -= tls_segment->memsz();
+         Reloc::lox10(view, value, addend);
        }
       else
-       Reloc::ldo_lox10(view, avalue, addend);
+       Reloc::ldo_lox10(view, value, addend);
       break;
     case elfcpp::R_SPARC_TLS_LDO_ADD:
       if (optimized_type == tls::TLSOPT_TO_LE)
@@ -3018,16 +3095,16 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
     case elfcpp::R_SPARC_TLS_IE_LO10:
       if (optimized_type == tls::TLSOPT_TO_LE)
        {
-         avalue -= tls_segment->memsz();
+         value -= tls_segment->memsz();
          switch (r_type)
            {
            case elfcpp::R_SPARC_TLS_IE_HI22:
              // IE_HI22 --> LE_HIX22
-             Reloc::hix22(view, avalue, addend);
+             Reloc::hix22(view, value, addend);
              break;
            case elfcpp::R_SPARC_TLS_IE_LO10:
              // IE_LO10 --> LE_LOX10
-             Reloc::lox10(view, avalue, addend);
+             Reloc::lox10(view, value, addend);
              break;
            }
          break;
@@ -3039,23 +3116,23 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
          if (gsym != NULL)
            {
              gold_assert(gsym->has_got_offset(GOT_TYPE_TLS_OFFSET));
-             avalue = gsym->got_offset(GOT_TYPE_TLS_OFFSET);
+             value = gsym->got_offset(GOT_TYPE_TLS_OFFSET);
            }
          else
            {
              unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
              gold_assert(object->local_has_got_offset(r_sym,
                                                       GOT_TYPE_TLS_OFFSET));
-             avalue = object->local_got_offset(r_sym,
-                                               GOT_TYPE_TLS_OFFSET);
+             value = object->local_got_offset(r_sym,
+                                              GOT_TYPE_TLS_OFFSET);
            }
          switch (r_type)
            {
            case elfcpp::R_SPARC_TLS_IE_HI22:
-             Reloc::hi22(view, avalue, addend);
+             Reloc::hi22(view, value, addend);
              break;
            case elfcpp::R_SPARC_TLS_IE_LO10:
-             Reloc::lo10(view, avalue, addend);
+             Reloc::lo10(view, value, addend);
              break;
            }
          break;
@@ -3076,8 +3153,8 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
       // have been created for this location, so do not apply it now.
       if (!parameters->options().shared())
        {
-         avalue -= tls_segment->memsz();
-         Reloc::hix22(view, avalue, addend);
+         value -= tls_segment->memsz();
+         Reloc::hix22(view, value, addend);
        }
       break;
 
@@ -3086,8 +3163,8 @@ Target_sparc<size, big_endian>::Relocate::relocate_tls(
       // have been created for this location, so do not apply it now.
       if (!parameters->options().shared())
        {
-         avalue -= tls_segment->memsz();
-         Reloc::lox10(view, avalue, addend);
+         value -= tls_segment->memsz();
+         Reloc::lox10(view, value, addend);
        }
       break;
     }
@@ -3238,18 +3315,18 @@ public:
                      (size == 64 ? "elf64-sparc" : "elf32-sparc"))
   { }
 
-  Target* do_recognize(int amachine, int, int)
+  Target* do_recognize(int machine, int, int)
   {
     switch (size)
       {
       case 64:
-       if (amachine != elfcpp::EM_SPARCV9)
+       if (machine != elfcpp::EM_SPARCV9)
          return NULL;
        break;
 
       case 32:
-       if (amachine != elfcpp::EM_SPARC
-           && amachine != elfcpp::EM_SPARC32PLUS)
+       if (machine != elfcpp::EM_SPARC
+           && machine != elfcpp::EM_SPARC32PLUS)
          return NULL;
        break;