+2009-12-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gold/10893
+ * i386.cc (Target_i386::Scan::globa): Use is_func instead of
+ checking elfcpp::STT_FUNC.
+ (Target_i386::Relocate::relocate): Likewise.
+ * x86_64.cc (Target_x86_64::Scan::global): Likewise.
+
+ * symtab.cc (Symbol_table::sized_write_symbol): Turn IFUNC
+ symbols from shared libraries into normal FUNC symbols.
+
+ * symtab.h (Symbol): Add is_func and use it.
+
2009-12-05 Doug Kwan <dougkwan@google.com>
* arm.cc (Target_arm::arm_info): Initialize new fields
* object.cc (Sized_relobj::do_layout): Skip attribute section.
* gold/powerpc.cc (Target_powerpc::powerpc_info): Initialize new
fields attributes_section and attributes_vendor.
- * sparc.cc (Target_sparc::sparc_info): Same.
+ * sparc.cc (Target_sparc::sparc_info): Same.
* target.h (Target::attributes_section, Target::attributes_vendor,
Target::is_attributes_section, Target::attribute_arg_type,
Target::attributes_order): New method definitions.
}
// Make a dynamic relocation if necessary.
int flags = Symbol::NON_PIC_REF;
- if (gsym->type() == elfcpp::STT_FUNC)
+ if (gsym->is_func())
flags |= Symbol::FUNCTION_CALL;
if (gsym->needs_dynamic_reloc(flags))
{
case elfcpp::R_386_PC32:
{
int ref_flags = Symbol::NON_PIC_REF;
- if (gsym != NULL && gsym->type() == elfcpp::STT_FUNC)
+ if (gsym != NULL && gsym->is_func())
ref_flags |= Symbol::FUNCTION_CALL;
if (should_apply_static_reloc(gsym, ref_flags, true, output_section))
Relocate_functions<32, false>::pcrel32(view, object, psymval, address);
case elfcpp::R_386_PC16:
{
int ref_flags = Symbol::NON_PIC_REF;
- if (gsym != NULL && gsym->type() == elfcpp::STT_FUNC)
+ if (gsym != NULL && gsym->is_func())
ref_flags |= Symbol::FUNCTION_CALL;
if (should_apply_static_reloc(gsym, ref_flags, false, output_section))
Relocate_functions<32, false>::pcrel16(view, object, psymval, address);
case elfcpp::R_386_PC8:
{
int ref_flags = Symbol::NON_PIC_REF;
- if (gsym != NULL && gsym->type() == elfcpp::STT_FUNC)
+ if (gsym != NULL && gsym->is_func())
ref_flags |= Symbol::FUNCTION_CALL;
if (should_apply_static_reloc(gsym, ref_flags, false,
output_section))
osym.put_st_size(0);
else
osym.put_st_size(sym->symsize());
+ elfcpp::STT type = sym->type();
+ // Turn IFUNC symbols from shared libraries into normal FUNC symbols.
+ if (type == elfcpp::STT_GNU_IFUNC
+ && sym->is_from_dynobj())
+ type = elfcpp::STT_FUNC;
// A version script may have overridden the default binding.
if (sym->is_forced_local())
- osym.put_st_info(elfcpp::elf_st_info(elfcpp::STB_LOCAL, sym->type()));
+ osym.put_st_info(elfcpp::elf_st_info(elfcpp::STB_LOCAL, type));
else
- osym.put_st_info(elfcpp::elf_st_info(sym->binding(), sym->type()));
+ osym.put_st_info(elfcpp::elf_st_info(sym->binding(), type));
osym.put_st_other(elfcpp::elf_st_other(sym->visibility(), sym->nonvis()));
osym.put_st_shndx(shndx);
}
type() const
{ return this->type_; }
+ // Return true for function symbol.
+ bool
+ is_func() const
+ {
+ return (this->type_ == elfcpp::STT_FUNC
+ || this->type_ == elfcpp::STT_GNU_IFUNC);
+ }
+
// Return the symbol visibility.
elfcpp::STV
visibility() const
return (!parameters->doing_static_link()
&& !parameters->options().pie()
- && this->type() == elfcpp::STT_FUNC
+ && this->is_func()
&& (this->is_from_dynobj()
|| this->is_undefined()
|| this->is_preemptible()));
return (!parameters->options().shared()
&& parameters->options().copyreloc()
&& this->is_from_dynobj()
- && this->type() != elfcpp::STT_FUNC);
+ && !this->is_func());
}
protected:
target->make_plt_entry(symtab, layout, gsym);
// Make a dynamic relocation if necessary.
int flags = Symbol::NON_PIC_REF;
- if (gsym->type() == elfcpp::STT_FUNC)
+ if (gsym->is_func())
flags |= Symbol::FUNCTION_CALL;
if (gsym->needs_dynamic_reloc(flags))
{