* i386.cc (Output_data_plt_i386::address_for_global,
authorAlan Modra <amodra@gmail.com>
Fri, 5 Oct 2012 00:45:54 +0000 (00:45 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 5 Oct 2012 00:45:54 +0000 (00:45 +0000)
address_for_local): Add plt offset to returned value.  Adjust uses.
* sparc.cc (Output_data_plt_sparc::address_for_global,
address_for_local): Likewise.
* tilegx.cc (Output_data_plt_tilegx::address_for_global,
address_for_local): Likewise.
* x86_64.cc (Output_data_plt_x86_64::address_for_global,
address_for_local): Likewise.
* target.h (Target::plt_address_for_global, plt_address_for_local):
Update comment.
* output.cc (Output_reloc::symbol_value): Don't add plt offset here.
(Output_data_got::Got_entry::write): Nor here.
* output.h: Comment fix.

gold/ChangeLog
gold/i386.cc
gold/output.cc
gold/output.h
gold/sparc.cc
gold/target.h
gold/tilegx.cc
gold/x86_64.cc

index 125d4627282448284c36a204dde7eed00a4d8da6..7b3bc9252845707a1abc42934af84d3ca832fd35 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-05  Alan Modra  <amodra@gmail.com>
+
+       * i386.cc (Output_data_plt_i386::address_for_global,
+       address_for_local): Add plt offset to returned value.  Adjust uses.
+       * sparc.cc (Output_data_plt_sparc::address_for_global,
+       address_for_local): Likewise.
+       * tilegx.cc (Output_data_plt_tilegx::address_for_global,
+       address_for_local): Likewise.
+       * x86_64.cc (Output_data_plt_x86_64::address_for_global,
+       address_for_local): Likewise.
+       * target.h (Target::plt_address_for_global, plt_address_for_local):
+       Update comment.
+       * output.cc (Output_reloc::symbol_value): Don't add plt offset here.
+       (Output_data_got::Got_entry::write): Nor here.
+       * output.h: Comment fix.
+
 2012-10-02  Jiong Wang  <jiwang@tilera.com>
 
        * tilegx.cc (Target_tilegx::do_finalize_sections): Adjust
index 47779d0e8cd4532c8934b113cfc006f950c00d42..9c52e93166e970620bb6301c3890152ea5589591 100644 (file)
@@ -1151,16 +1151,19 @@ Output_data_plt_i386::address_for_global(const Symbol* gsym)
   if (gsym->type() == elfcpp::STT_GNU_IFUNC
       && gsym->can_use_relative_reloc(false))
     offset = (this->count_ + 1) * this->get_plt_entry_size();
-  return this->address() + offset;
+  return this->address() + offset + gsym->plt_offset();
 }
 
 // Return the PLT address to use for a local symbol.  These are always
 // IRELATIVE relocs.
 
 uint64_t
-Output_data_plt_i386::address_for_local(const Relobj*, unsigned int)
+Output_data_plt_i386::address_for_local(const Relobj* object,
+                                       unsigned int r_sym)
 {
-  return this->address() + (this->count_ + 1) * this->get_plt_entry_size();
+  return (this->address()
+         + (this->count_ + 1) * this->get_plt_entry_size()
+         + object->local_plt_offset(r_sym));
 }
 
 // The first entry in the PLT for an executable.
@@ -2677,8 +2680,7 @@ Target_i386::Relocate::relocate(const Relocate_info<32, false>* relinfo,
   else if (gsym != NULL
           && gsym->use_plt_offset(Scan::get_reference_flags(r_type)))
     {
-      symval.set_output_value(target->plt_address_for_global(gsym)
-                             + gsym->plt_offset());
+      symval.set_output_value(target->plt_address_for_global(gsym));
       psymval = &symval;
     }
   else if (gsym == NULL && psymval->is_ifunc_symbol())
@@ -2686,8 +2688,7 @@ Target_i386::Relocate::relocate(const Relocate_info<32, false>* relinfo,
       unsigned int r_sym = elfcpp::elf_r_sym<32>(rel.get_r_info());
       if (object->local_has_plt_offset(r_sym))
        {
-         symval.set_output_value(target->plt_address_for_local(object, r_sym)
-                                 + object->local_plt_offset(r_sym));
+         symval.set_output_value(target->plt_address_for_local(object, r_sym));
          psymval = &symval;
        }
     }
@@ -3649,7 +3650,7 @@ uint64_t
 Target_i386::do_dynsym_value(const Symbol* gsym) const
 {
   gold_assert(gsym->is_from_dynobj() && gsym->has_plt_offset());
-  return this->plt_address_for_global(gsym) + gsym->plt_offset();
+  return this->plt_address_for_global(gsym);
 }
 
 // Return a string used to fill a code section with nops to take up
index 96fdd9fa81c2d309a8b9a0ef85042599efbc6679..6e5cd2510a0e9f9e352e3fe9114611a3958d0842 100644 (file)
@@ -1129,11 +1129,7 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::symbol_value(
       const Sized_symbol<size>* sym;
       sym = static_cast<const Sized_symbol<size>*>(this->u1_.gsym);
       if (this->use_plt_offset_ && sym->has_plt_offset())
-       {
-         uint64_t plt_address =
-           parameters->target().plt_address_for_global(sym);
-         return plt_address + sym->plt_offset();
-       }
+       return parameters->target().plt_address_for_global(sym);
       else
        return sym->value() + addend;
     }
@@ -1151,11 +1147,7 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::symbol_value(
       this->u1_.relobj->sized_relobj();
   gold_assert(relobj != NULL);
   if (this->use_plt_offset_)
-    {
-      uint64_t plt_address =
-         parameters->target().plt_address_for_local(relobj, lsi);
-      return plt_address + relobj->local_plt_offset(lsi);
-    }
+    return parameters->target().plt_address_for_local(relobj, lsi);
   const Symbol_value<size>* symval = relobj->local_symbol(lsi);
   return symval->value(relobj, addend);
 }
@@ -1385,8 +1377,7 @@ Output_data_got<got_size, big_endian>::Got_entry::write(
        // RELATIVE relocation.
        Symbol* gsym = this->u_.gsym;
        if (this->use_plt_or_tls_offset_ && gsym->has_plt_offset())
-         val = (parameters->target().plt_address_for_global(gsym)
-                + gsym->plt_offset());
+         val = parameters->target().plt_address_for_global(gsym);
        else
          {
            switch (parameters->size_and_endianness())
@@ -1442,11 +1433,7 @@ Output_data_got<got_size, big_endian>::Got_entry::write(
         const unsigned int lsi = this->local_sym_index_;
        bool is_tls = object->local_is_tls(lsi);
        if (this->use_plt_or_tls_offset_ && !is_tls)
-         {
-           uint64_t plt_address =
-             parameters->target().plt_address_for_local(object, lsi);
-           val = plt_address + object->local_plt_offset(lsi);
-         }
+         val = parameters->target().plt_address_for_local(object, lsi);
        else
          {
            uint64_t lval = object->local_symbol_value(lsi, 0);
@@ -2609,9 +2596,9 @@ Output_section::add_relaxed_input_section(Layout* layout,
 
   // For a relaxed section, we use the current data size.  Linker scripts
   // get all the input sections, including relaxed one from an output
-  // section and add them back to them same output section to compute the
+  // section and add them back to the same output section to compute the
   // output section size.  If we do not account for sizes of relaxed input
-  // sections,  an output section would be incorrectly sized.
+  // sections, an output section would be incorrectly sized.
   off_t offset_in_section = this->current_data_size_for_child();
   off_t aligned_offset_in_section = align_address(offset_in_section,
                                                  poris->addralign());
index d5bcc27ddb5e6c187c45f357e751dcfab470840d..d52d0756bfb75a83ce4981a49391e91c79d8842a 100644 (file)
@@ -2247,7 +2247,7 @@ class Output_data_got : public Output_data_got_base
   add_global_plt(Symbol* gsym, unsigned int got_type);
 
   // Like add_global, but for a TLS symbol where the value will be
-  // offset using Target::tls_offset_for_global
+  // offset using Target::tls_offset_for_global.
   bool
   add_global_tls(Symbol* gsym, unsigned int got_type)
   { return add_global_plt(gsym, got_type); }
@@ -2277,7 +2277,7 @@ class Output_data_got : public Output_data_got_base
   add_local_plt(Relobj* object, unsigned int sym_index, unsigned int got_type);
 
   // Like add_local, but for a TLS symbol where the value will be
-  // offset using Target::tls_offset_for_local
+  // offset using Target::tls_offset_for_local.
   bool
   add_local_tls(Relobj* object, unsigned int sym_index, unsigned int got_type)
   { return add_local_plt(object, sym_index, got_type); }
index 71dd3d53c30a82faad335c4fccd6c1593730fc06..4ec3037c4ab6ac9cca336c945fc161f522c29269 100644 (file)
@@ -1619,7 +1619,7 @@ Output_data_plt_sparc<size, big_endian>::address_for_global(const Symbol* gsym)
   if (gsym->type() == elfcpp::STT_GNU_IFUNC
       && gsym->can_use_relative_reloc(false))
     offset = plt_index_to_offset(this->count_ + 4);
-  return this->address() + offset;
+  return this->address() + offset + gsym->plt_offset();
 }
 
 // Return the PLT address to use for a local symbol.  These are always
@@ -1628,10 +1628,12 @@ Output_data_plt_sparc<size, big_endian>::address_for_global(const Symbol* gsym)
 template<int size, bool big_endian>
 uint64_t
 Output_data_plt_sparc<size, big_endian>::address_for_local(
-       const Relobj*,
-       unsigned int)
+       const Relobj* object,
+       unsigned int r_sym)
 {
-  return this->address() + plt_index_to_offset(this->count_ + 4);
+  return (this->address()
+         + plt_index_to_offset(this->count_ + 4)
+         + object->local_plt_offset(r_sym));
 }
 
 static const unsigned int sparc_nop = 0x01000000;
@@ -3199,7 +3201,7 @@ Target_sparc<size, big_endian>::Relocate::relocate(
     {
       elfcpp::Elf_Xword value;
 
-      value = target->plt_address_for_global(gsym) + gsym->plt_offset();
+      value = target->plt_address_for_global(gsym);
 
       symval.set_output_value(value);
 
@@ -3210,8 +3212,7 @@ Target_sparc<size, big_endian>::Relocate::relocate(
       unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
       if (object->local_has_plt_offset(r_sym))
        {
-         symval.set_output_value(target->plt_address_for_local(object, r_sym)
-                                 + object->local_plt_offset(r_sym));
+         symval.set_output_value(target->plt_address_for_local(object, r_sym));
          psymval = &symval;
        }
     }
index 65c15fce028a0f0b679d42d5c254ddb2109b99e7..3464a2ba4565ad2460ed46763cb74e5b509d59c5 100644 (file)
@@ -256,16 +256,12 @@ class Target
   reloc_addend(void* arg, unsigned int type, uint64_t addend) const
   { return this->do_reloc_addend(arg, type, addend); }
 
-  // Return the PLT address to use for a global symbol.  This is used
-  // for STT_GNU_IFUNC symbols.  The symbol's plt_offset is relative
-  // to this PLT address.
+  // Return the PLT address to use for a global symbol.
   uint64_t
   plt_address_for_global(const Symbol* sym) const
   { return this->do_plt_address_for_global(sym); }
 
-  // Return the PLT address to use for a local symbol.  This is used
-  // for STT_GNU_IFUNC symbols.  The symbol's plt_offset is relative
-  // to this PLT address.
+  // Return the PLT address to use for a local symbol.
   uint64_t
   plt_address_for_local(const Relobj* object, unsigned int symndx) const
   { return this->do_plt_address_for_local(object, symndx); }
index a209a97106ab3921e96f296d6c1cd7d2c837b9df..3c618028a6400f7fabe5ba3405755b267ea5e8a8 100644 (file)
@@ -2194,7 +2194,7 @@ Output_data_plt_tilegx<size, big_endian>::address_for_global(
   if (gsym->type() == elfcpp::STT_GNU_IFUNC
       && gsym->can_use_relative_reloc(false))
     offset = (this->count_ + 1) * this->get_plt_entry_size();
-  return this->address() + offset;
+  return this->address() + offset + gsym->plt_offset();
 }
 
 // Return the PLT address to use for a local symbol.  These are always
@@ -2202,10 +2202,13 @@ Output_data_plt_tilegx<size, big_endian>::address_for_global(
 
 template<int size, bool big_endian>
 uint64_t
-Output_data_plt_tilegx<size, big_endian>::address_for_local(const Relobj*,
-                                                            unsigned int)
+Output_data_plt_tilegx<size, big_endian>::address_for_local(
+    const Relobj* object,
+    unsigned int r_sym)
 {
-  return this->address() + (this->count_ + 1) * this->get_plt_entry_size();
+  return (this->address()
+         + (this->count_ + 1) * this->get_plt_entry_size()
+         + object->local_plt_offset(r_sym));
 }
 
 // Set the final size.
@@ -4334,8 +4337,7 @@ Target_tilegx<size, big_endian>::Relocate::relocate(
   if (gsym != NULL
       && gsym->use_plt_offset(Scan::get_reference_flags(r_type)))
     {
-      symval.set_output_value(target->plt_address_for_global(gsym)
-                              + gsym->plt_offset());
+      symval.set_output_value(target->plt_address_for_global(gsym));
       psymval = &symval;
     }
   else if (gsym == NULL && psymval->is_ifunc_symbol())
@@ -4343,8 +4345,7 @@ Target_tilegx<size, big_endian>::Relocate::relocate(
       unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
       if (object->local_has_plt_offset(r_sym))
         {
-          symval.set_output_value(target->plt_address_for_local(object, r_sym)
-                                  + object->local_plt_offset(r_sym));
+          symval.set_output_value(target->plt_address_for_local(object, r_sym));
           psymval = &symval;
         }
     }
@@ -4557,8 +4558,7 @@ Target_tilegx<size, big_endian>::Relocate::relocate(
                 if (opt_t == tls::TLSOPT_NONE) {
                   Symbol *tls_sym = relinfo->symtab->lookup("__tls_get_addr");
                   symval.set_output_value(
-                    target->plt_address_for_global(tls_sym)
-                     + tls_sym->plt_offset());
+                    target->plt_address_for_global(tls_sym));
                   psymval = &symval;
                   TilegxReloc::imm_x_pcrel_general(view, object, psymval,
                                                    addend, address, r_howto);
@@ -4870,7 +4870,7 @@ uint64_t
 Target_tilegx<size, big_endian>::do_dynsym_value(const Symbol* gsym) const
 {
   gold_assert(gsym->is_from_dynobj() && gsym->has_plt_offset());
-  return this->plt_address_for_global(gsym) + gsym->plt_offset();
+  return this->plt_address_for_global(gsym);
 }
 
 // Return the value to use for the base of a DW_EH_PE_datarel offset
index 5914160b2ad000650fbcdf2efac8534564795ad9..0fbfec62dbeb3b7449f1f2e9d25f2f2505259103 100644 (file)
@@ -1385,7 +1385,7 @@ Output_data_plt_x86_64<size>::address_for_global(const Symbol* gsym)
   if (gsym->type() == elfcpp::STT_GNU_IFUNC
       && gsym->can_use_relative_reloc(false))
     offset = (this->count_ + 1) * this->get_plt_entry_size();
-  return this->address() + offset;
+  return this->address() + offset + gsym->plt_offset();
 }
 
 // Return the PLT address to use for a local symbol.  These are always
@@ -1393,9 +1393,12 @@ Output_data_plt_x86_64<size>::address_for_global(const Symbol* gsym)
 
 template<int size>
 uint64_t
-Output_data_plt_x86_64<size>::address_for_local(const Relobj*, unsigned int)
+Output_data_plt_x86_64<size>::address_for_local(const Relobj* object,
+                                               unsigned int r_sym)
 {
-  return this->address() + (this->count_ + 1) * this->get_plt_entry_size();
+  return (this->address()
+         + (this->count_ + 1) * this->get_plt_entry_size()
+         + object->local_plt_offset(r_sym));
 }
 
 // Set the final size.
@@ -3234,8 +3237,7 @@ Target_x86_64<size>::Relocate::relocate(
   if (gsym != NULL
       && gsym->use_plt_offset(Scan::get_reference_flags(r_type)))
     {
-      symval.set_output_value(target->plt_address_for_global(gsym)
-                             + gsym->plt_offset());
+      symval.set_output_value(target->plt_address_for_global(gsym));
       psymval = &symval;
     }
   else if (gsym == NULL && psymval->is_ifunc_symbol())
@@ -3243,8 +3245,7 @@ Target_x86_64<size>::Relocate::relocate(
       unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
       if (object->local_has_plt_offset(r_sym))
        {
-         symval.set_output_value(target->plt_address_for_local(object, r_sym)
-                                 + object->local_plt_offset(r_sym));
+         symval.set_output_value(target->plt_address_for_local(object, r_sym));
          psymval = &symval;
        }
     }
@@ -4253,7 +4254,7 @@ uint64_t
 Target_x86_64<size>::do_dynsym_value(const Symbol* gsym) const
 {
   gold_assert(gsym->is_from_dynobj() && gsym->has_plt_offset());
-  return this->plt_address_for_global(gsym) + gsym->plt_offset();
+  return this->plt_address_for_global(gsym);
 }
 
 // Return a string used to fill a code section with nops to take up