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-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
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.
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())
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;
}
}
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
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;
}
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);
}
// 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())
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);
// 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());
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); }
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); }
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
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;
{
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);
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;
}
}
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); }
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
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.
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())
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;
}
}
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);
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
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
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.
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())
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;
}
}
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