Line 291... |
Line 291... |
this->init_base_undefined(name, version, type, binding, visibility, nonvis);
|
this->init_base_undefined(name, version, type, binding, visibility, nonvis);
|
this->value_ = 0;
|
this->value_ = 0;
|
this->symsize_ = 0;
|
this->symsize_ = 0;
|
}
|
}
|
|
|
|
// Return an allocated string holding the symbol's name as
|
|
// name@version. This is used for relocatable links.
|
|
|
|
std::string
|
|
Symbol::versioned_name() const
|
|
{
|
|
gold_assert(this->version_ != NULL);
|
|
std::string ret = this->name_;
|
|
ret.push_back('@');
|
|
if (this->is_def_)
|
|
ret.push_back('@');
|
|
ret += this->version_;
|
|
return ret;
|
|
}
|
|
|
// Return true if SHNDX represents a common symbol.
|
// Return true if SHNDX represents a common symbol.
|
|
|
bool
|
bool
|
Symbol::is_common_shndx(unsigned int shndx)
|
Symbol::is_common_shndx(unsigned int shndx)
|
{
|
{
|
Line 397... |
Line 412... |
// If exporting all symbols or building a shared library,
|
// If exporting all symbols or building a shared library,
|
// and the symbol is defined in a regular object and is
|
// and the symbol is defined in a regular object and is
|
// externally visible, we need to add it.
|
// externally visible, we need to add it.
|
if ((parameters->options().export_dynamic() || parameters->options().shared())
|
if ((parameters->options().export_dynamic() || parameters->options().shared())
|
&& !this->is_from_dynobj()
|
&& !this->is_from_dynobj()
|
|
&& !this->is_undefined()
|
&& this->is_externally_visible())
|
&& this->is_externally_visible())
|
return true;
|
return true;
|
|
|
return false;
|
return false;
|
}
|
}
|
Line 1174... |
Line 1190... |
elfcpp::Sym<size, big_endian> sym2(symbuf);
|
elfcpp::Sym<size, big_endian> sym2(symbuf);
|
if (just_symbols)
|
if (just_symbols)
|
{
|
{
|
memcpy(symbuf, p, sym_size);
|
memcpy(symbuf, p, sym_size);
|
elfcpp::Sym_write<size, big_endian> sw(symbuf);
|
elfcpp::Sym_write<size, big_endian> sw(symbuf);
|
if (orig_st_shndx != elfcpp::SHN_UNDEF && is_ordinary)
|
if (orig_st_shndx != elfcpp::SHN_UNDEF
|
|
&& is_ordinary
|
|
&& relobj->e_type() == elfcpp::ET_REL)
|
{
|
{
|
// Symbol values in object files are section relative.
|
// Symbol values in relocatable object files are section
|
// This is normally what we want, but since here we are
|
// relative. This is normally what we want, but since here
|
// converting the symbol to absolute we need to add the
|
// we are converting the symbol to absolute we need to add
|
// section address. The section address in an object
|
// the section address. The section address in an object
|
// file is normally zero, but people can use a linker
|
// file is normally zero, but people can use a linker
|
// script to change it.
|
// script to change it.
|
sw.put_st_value(sym.get_st_value()
|
sw.put_st_value(sym.get_st_value()
|
+ relobj->section_address(orig_st_shndx));
|
+ relobj->section_address(orig_st_shndx));
|
}
|
}
|
Line 1220... |
Line 1238... |
Sized_symbol<size>* res;
|
Sized_symbol<size>* res;
|
res = this->add_from_object(relobj, name, name_key, ver, ver_key,
|
res = this->add_from_object(relobj, name, name_key, ver, ver_key,
|
is_default_version, *psym, st_shndx,
|
is_default_version, *psym, st_shndx,
|
is_ordinary, orig_st_shndx);
|
is_ordinary, orig_st_shndx);
|
|
|
|
if (is_forced_local)
|
|
this->force_local(res);
|
|
|
// If building a shared library using garbage collection, do not
|
// If building a shared library using garbage collection, do not
|
// treat externally visible symbols as garbage.
|
// treat externally visible symbols as garbage.
|
if (parameters->options().gc_sections()
|
if (parameters->options().gc_sections()
|
&& parameters->options().shared())
|
&& parameters->options().shared())
|
this->gc_mark_symbol_for_shlib(res);
|
this->gc_mark_symbol_for_shlib(res);
|
|
|
if (is_forced_local)
|
|
this->force_local(res);
|
|
|
|
if (is_defined_in_discarded_section)
|
if (is_defined_in_discarded_section)
|
res->set_is_defined_in_discarded_section();
|
res->set_is_defined_in_discarded_section();
|
|
|
(*sympointers)[i] = res;
|
(*sympointers)[i] = res;
|
}
|
}
|
Line 1865... |
Line 1883... |
else if (version != NULL)
|
else if (version != NULL)
|
sym->set_is_default();
|
sym->set_is_default();
|
return sym;
|
return sym;
|
}
|
}
|
|
|
if (Symbol_table::should_override_with_special(oldsym, defined))
|
if (Symbol_table::should_override_with_special(oldsym, type, defined))
|
this->override_with_special(oldsym, sym);
|
this->override_with_special(oldsym, sym);
|
|
|
if (resolve_oldsym)
|
if (resolve_oldsym)
|
return sym;
|
return sym;
|
else
|
else
|
Line 1979... |
Line 1997... |
else if (version != NULL)
|
else if (version != NULL)
|
sym->set_is_default();
|
sym->set_is_default();
|
return sym;
|
return sym;
|
}
|
}
|
|
|
if (Symbol_table::should_override_with_special(oldsym, defined))
|
if (Symbol_table::should_override_with_special(oldsym, type, defined))
|
this->override_with_special(oldsym, sym);
|
this->override_with_special(oldsym, sym);
|
|
|
if (resolve_oldsym)
|
if (resolve_oldsym)
|
return sym;
|
return sym;
|
else
|
else
|
Line 2098... |
Line 2116... |
sym->set_is_default();
|
sym->set_is_default();
|
return sym;
|
return sym;
|
}
|
}
|
|
|
if (force_override
|
if (force_override
|
|| Symbol_table::should_override_with_special(oldsym, defined))
|
|| Symbol_table::should_override_with_special(oldsym, type, defined))
|
this->override_with_special(oldsym, sym);
|
this->override_with_special(oldsym, sym);
|
|
|
if (resolve_oldsym)
|
if (resolve_oldsym)
|
return sym;
|
return sym;
|
else
|
else
|
Line 2414... |
Line 2432... |
void
|
void
|
Symbol_table::add_to_final_symtab(Symbol* sym, Stringpool* pool,
|
Symbol_table::add_to_final_symtab(Symbol* sym, Stringpool* pool,
|
unsigned int* pindex, off_t* poff)
|
unsigned int* pindex, off_t* poff)
|
{
|
{
|
sym->set_symtab_index(*pindex);
|
sym->set_symtab_index(*pindex);
|
|
if (sym->version() == NULL || !parameters->options().relocatable())
|
pool->add(sym->name(), false, NULL);
|
pool->add(sym->name(), false, NULL);
|
|
else
|
|
pool->add(sym->versioned_name(), true, NULL);
|
++*pindex;
|
++*pindex;
|
*poff += elfcpp::Elf_sizes<size>::sym_size;
|
*poff += elfcpp::Elf_sizes<size>::sym_size;
|
}
|
}
|
|
|
// Set the final value for all the symbols. This is called after
|
// Set the final value for all the symbols. This is called after
|
Line 2923... |
Line 2944... |
elfcpp::STB binding,
|
elfcpp::STB binding,
|
const Stringpool* pool,
|
const Stringpool* pool,
|
unsigned char* p) const
|
unsigned char* p) const
|
{
|
{
|
elfcpp::Sym_write<size, big_endian> osym(p);
|
elfcpp::Sym_write<size, big_endian> osym(p);
|
|
if (sym->version() == NULL || !parameters->options().relocatable())
|
osym.put_st_name(pool->get_offset(sym->name()));
|
osym.put_st_name(pool->get_offset(sym->name()));
|
|
else
|
|
osym.put_st_name(pool->get_offset(sym->versioned_name()));
|
osym.put_st_value(value);
|
osym.put_st_value(value);
|
// Use a symbol size of zero for undefined symbols from shared libraries.
|
// Use a symbol size of zero for undefined symbols from shared libraries.
|
if (shndx == elfcpp::SHN_UNDEF && sym->is_from_dynobj())
|
if (shndx == elfcpp::SHN_UNDEF && sym->is_from_dynobj())
|
osym.put_st_size(0);
|
osym.put_st_size(0);
|
else
|
else
|
Line 3280... |
Line 3304... |
Warnings::issue_warning(const Symbol* sym,
|
Warnings::issue_warning(const Symbol* sym,
|
const Relocate_info<size, big_endian>* relinfo,
|
const Relocate_info<size, big_endian>* relinfo,
|
size_t relnum, off_t reloffset) const
|
size_t relnum, off_t reloffset) const
|
{
|
{
|
gold_assert(sym->has_warning());
|
gold_assert(sym->has_warning());
|
|
|
|
// We don't want to issue a warning for a relocation against the
|
|
// symbol in the same object file in which the symbol is defined.
|
|
if (sym->object() == relinfo->object)
|
|
return;
|
|
|
Warning_table::const_iterator p = this->warnings_.find(sym->name());
|
Warning_table::const_iterator p = this->warnings_.find(sym->name());
|
gold_assert(p != this->warnings_.end());
|
gold_assert(p != this->warnings_.end());
|
gold_warning_at_location(relinfo, relnum, reloffset,
|
gold_warning_at_location(relinfo, relnum, reloffset,
|
"%s", p->second.text.c_str());
|
"%s", p->second.text.c_str());
|
}
|
}
|