// Set the visibility.
void
- set_visibility(elfcpp::STV vis)
- { this->visibility_ = vis; }
+ set_visibility(elfcpp::STV visibility)
+ { this->visibility_ = visibility; }
// Override symbol visibility.
void
needs_dynsym_entry() const
{
return (this->needs_dynsym_entry_
- || (this->in_reg() && this->in_dyn()));
+ || (this->in_reg()
+ && this->in_dyn()
+ && this->is_externally_visible()));
}
// Mark this symbol as needing an entry in the dynamic symbol table.
unsigned int
got_offset(unsigned int got_type) const
{
- unsigned int got_off = this->got_offsets_.get_offset(got_type);
- gold_assert(got_off != -1U);
- return got_off;
+ unsigned int got_offset = this->got_offsets_.get_offset(got_type);
+ gold_assert(got_offset != -1U);
+ return got_offset;
}
// Set the GOT offset of this symbol.
void
- set_got_offset(unsigned int got_type, unsigned int got_off)
- { this->got_offsets_.set_offset(got_type, got_off); }
+ set_got_offset(unsigned int got_type, unsigned int got_offset)
+ { this->got_offsets_.set_offset(got_type, got_offset); }
// Return whether this symbol has an entry in the PLT section.
bool
// Set the PLT offset of this symbol.
void
- set_plt_offset(unsigned int plt_off)
+ set_plt_offset(unsigned int plt_offset)
{
this->has_plt_offset_ = true;
- this->plt_offset_ = plt_off;
+ this->plt_offset_ = plt_offset;
}
// Return whether this dynamic symbol needs a special value in the
bool is_ordinary;
if (this->source_ != FROM_OBJECT)
return this->source_ != IS_UNDEFINED;
- unsigned int sec_shndx = this->shndx(&is_ordinary);
+ unsigned int shndx = this->shndx(&is_ordinary);
return (is_ordinary
- ? sec_shndx != elfcpp::SHN_UNDEF
- : !Symbol::is_common_shndx(sec_shndx));
+ ? shndx != elfcpp::SHN_UNDEF
+ : !Symbol::is_common_shndx(shndx));
}
// Return true if this symbol is from a dynamic object.
bool
is_common() const
{
- if (this->type_ == elfcpp::STT_COMMON)
- return true;
if (this->source_ != FROM_OBJECT)
return false;
+ if (this->type_ == elfcpp::STT_COMMON)
+ return true;
bool is_ordinary;
- unsigned int sec_shndx = this->shndx(&is_ordinary);
- return !is_ordinary && Symbol::is_common_shndx(sec_shndx);
+ unsigned int shndx = this->shndx(&is_ordinary);
+ return !is_ordinary && Symbol::is_common_shndx(shndx);
}
// Return whether this symbol can be seen outside this object.
// Set the symbol size. This is used when resolving common symbols.
void
- set_symsize(Size_type symsz)
- { this->symsize_ = symsz; }
+ set_symsize(Size_type symsize)
+ { this->symsize_ = symsize; }
// Set the symbol value. This is called when we store the final
// values of the symbols into the symbol table.
void
- set_value(Value_type val)
- { this->value_ = val; }
+ set_value(Value_type value)
+ { this->value_ = value; }
// Allocate a common symbol by giving it a location in the output
// file.
class Symbol_table
{
public:
+ // The different places where a symbol definition can come from.
+ enum Defined
+ {
+ // Defined in an object file--the normal case.
+ OBJECT,
+ // Defined for a COPY reloc.
+ COPY,
+ // Defined on the command line using --defsym.
+ DEFSYM,
+ // Defined (so to speak) on the command line using -u.
+ UNDEFINED,
+ // Defined in a linker script.
+ SCRIPT,
+ // Predefined by the linker.
+ PREDEFINED,
+ };
+
+ // The order in which we sort common symbols.
+ enum Sort_commons_order
+ {
+ SORT_COMMONS_BY_SIZE_DESCENDING,
+ SORT_COMMONS_BY_ALIGNMENT_DESCENDING,
+ SORT_COMMONS_BY_ALIGNMENT_ASCENDING
+ };
+
// COUNT is an estimate of how many symbosl will be inserted in the
// symbol table. It's ok to put 0 if you don't know; a correct
// guess will just save some CPU by reducing hashtable resizes.
~Symbol_table();
void
- set_icf(Icf* _icf)
- { this->icf_ = _icf;}
+ set_icf(Icf* icf)
+ { this->icf_ = icf;}
Icf*
icf() const
is_section_folded(Object* obj, unsigned int shndx) const;
void
- set_gc(Garbage_collection* garbage)
- { this->gc_ = garbage; }
+ set_gc(Garbage_collection* gc)
+ { this->gc_ = gc; }
Garbage_collection*
gc() const
// Define a special symbol based on an Output_data. It is a
// multiple definition error if this symbol is already defined.
Symbol*
- define_in_output_data(const char* name, const char* version,
+ define_in_output_data(const char* name, const char* version, Defined,
Output_data*, uint64_t value, uint64_t symsize,
elfcpp::STT type, elfcpp::STB binding,
elfcpp::STV visibility, unsigned char nonvis,
// Define a special symbol based on an Output_segment. It is a
// multiple definition error if this symbol is already defined.
Symbol*
- define_in_output_segment(const char* name, const char* version,
+ define_in_output_segment(const char* name, const char* version, Defined,
Output_segment*, uint64_t value, uint64_t symsize,
elfcpp::STT type, elfcpp::STB binding,
elfcpp::STV visibility, unsigned char nonvis,
// Define a special symbol with a constant value. It is a multiple
// definition error if this symbol is already defined.
Symbol*
- define_as_constant(const char* name, const char* version,
+ define_as_constant(const char* name, const char* version, Defined,
uint64_t value, uint64_t symsize, elfcpp::STT type,
elfcpp::STB binding, elfcpp::STV visibility,
unsigned char nonvis, bool only_if_ref,
// Whether we should override a symbol, based on flags in
// resolve.cc.
static bool
- should_override(const Symbol*, unsigned int, Object*, bool*);
+ should_override(const Symbol*, unsigned int, Defined, Object*, bool*);
// Report a problem in symbol resolution.
static void
report_resolve_problem(bool is_error, const char* msg, const Symbol* to,
- Object* object);
+ Defined, Object* object);
// Override a symbol.
template<int size, bool big_endian>
// Whether we should override a symbol with a special symbol which
// is automatically defined by the linker.
static bool
- should_override_with_special(const Symbol*);
+ should_override_with_special(const Symbol*, Defined);
// Override a symbol with a special symbol.
template<int size>
// Define a symbol in an Output_data, sized version.
template<int size>
Sized_symbol<size>*
- do_define_in_output_data(const char* name, const char* version, Output_data*,
+ do_define_in_output_data(const char* name, const char* version, Defined,
+ Output_data*,
typename elfcpp::Elf_types<size>::Elf_Addr value,
typename elfcpp::Elf_types<size>::Elf_WXword ssize,
elfcpp::STT type, elfcpp::STB binding,
template<int size>
Sized_symbol<size>*
do_define_in_output_segment(
- const char* name, const char* version, Output_segment* os,
+ const char* name, const char* version, Defined, Output_segment* os,
typename elfcpp::Elf_types<size>::Elf_Addr value,
typename elfcpp::Elf_types<size>::Elf_WXword ssize,
elfcpp::STT type, elfcpp::STB binding,
template<int size>
Sized_symbol<size>*
do_define_as_constant(
- const char* name, const char* version,
+ const char* name, const char* version, Defined,
typename elfcpp::Elf_types<size>::Elf_Addr value,
typename elfcpp::Elf_types<size>::Elf_WXword ssize,
elfcpp::STT type, elfcpp::STB binding,
// Allocate the common symbols, sized version.
template<int size>
void
- do_allocate_commons(Layout*, Mapfile*);
+ do_allocate_commons(Layout*, Mapfile*, Sort_commons_order);
// Allocate the common symbols from one list.
template<int size>
void
do_allocate_commons_list(Layout*, Commons_section_type, Commons_type*,
- Mapfile*);
+ Mapfile*, Sort_commons_order);
// Implement detect_odr_violations.
template<int size, bool big_endian>