summaryrefslogtreecommitdiff
path: root/gold/symtab.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2016-02-04 16:55:39 -0800
committerCary Coutant <ccoutant@gmail.com>2016-03-03 18:19:53 -0800
commitdc1c8a16a38dec431c77f49cf50a9b62d6366138 (patch)
treedde11c01459658ee118c3eefe93f8343beb9d623 /gold/symtab.cc
parent8b4ee0a5c134be874ba44038d2fbd4d9b7f6d3ee (diff)
downloadbinutils-gdb-dc1c8a16a38dec431c77f49cf50a9b62d6366138.tar.gz
Add support for STT_SPARC_REGISTER symbols.
gold/ PR gold/19019 * layout.h (Layout::add_target_specific_dynamic_tag): New function. * layout.cc (Layout::add_target_specific_dynamic_tag): New function. * mips.cc (Target_mips::make_symbol): Adjust function signature. * sparc.cc (Target_sparc::Target_sparc): Initialize register_syms_. (Target_sparc::do_is_defined_by_abi): Remove test for STT_SPARC_REGISTER. (Target_sparc::Register_symbol): New struct type. (Target_sparc::register_syms_): New data member. (Target_sparc<64, true>::sparc_info): Set has_make_symbol to true. (Target_sparc::make_symbol): New function. (Target_sparc::do_finalize_sections): Add register symbols and new dynamic table entries. * symtab.h (Sized_symbol::init_undefined): Add value parameter. (Symbol_table::add_target_global_symbol): New function. (Symbol_table::target_symbols_): New data member. * symtab.cc (Sized_symbol::init_undefined): Add value parameter. (Symbol_table::Symbol_table): Initialize target_symbols_. (Symbol_table::add_from_object): Pass additional parameters to Target::make_symbol. (Symbol_table::define_special_symbol): Likewise. (Symbol_table::add_undefined_symbol_from_command_line): Pass 0 for undefined symbol value. (Symbol_table::set_dynsym_indexes): Process target-specific symbols. (Symbol_table::sized_finalize): Likewise. (Symbol_table::sized_write_globals): Likewise. * target.h (Sized_target::make_symbol): Add name, st_type, object, st_shndx, and value parameters.
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r--gold/symtab.cc85
1 files changed, 78 insertions, 7 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 156c876a627..a53f6c93fb4 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -285,11 +285,12 @@ Sized_symbol<size>::init_constant(const char* name, const char* version,
template<int size>
void
Sized_symbol<size>::init_undefined(const char* name, const char* version,
- elfcpp::STT type, elfcpp::STB binding,
- elfcpp::STV visibility, unsigned char nonvis)
+ Value_type value, elfcpp::STT type,
+ elfcpp::STB binding, elfcpp::STV visibility,
+ unsigned char nonvis)
{
this->init_base_undefined(name, version, type, binding, visibility, nonvis);
- this->value_ = 0;
+ this->value_ = value;
this->symsize_ = 0;
}
@@ -565,7 +566,8 @@ Symbol_table::Symbol_table(unsigned int count,
: saw_undefined_(0), offset_(0), table_(count), namepool_(),
forwarders_(), commons_(), tls_commons_(), small_commons_(),
large_commons_(), forced_locals_(), warnings_(),
- version_script_(version_script), gc_(NULL), icf_(NULL)
+ version_script_(version_script), gc_(NULL), icf_(NULL),
+ target_symbols_()
{
namepool_.reserve(count);
}
@@ -1058,7 +1060,8 @@ Symbol_table::add_from_object(Object* object,
ret = new Sized_symbol<size>();
else
{
- ret = target->make_symbol();
+ ret = target->make_symbol(name, sym.get_st_type(), object,
+ st_shndx, sym.get_st_value());
if (ret == NULL)
{
// This means that we don't want a symbol table
@@ -1858,7 +1861,8 @@ Symbol_table::define_special_symbol(const char** pname, const char** pversion,
{
Sized_target<size, big_endian>* sized_target =
parameters->sized_target<size, big_endian>();
- sym = sized_target->make_symbol();
+ sym = sized_target->make_symbol(*pname, elfcpp::STT_NOTYPE,
+ NULL, elfcpp::SHN_UNDEF, 0);
if (sym == NULL)
return NULL;
}
@@ -2437,7 +2441,7 @@ Symbol_table::add_undefined_symbol_from_command_line(const char* name)
gold_assert(oldsym == NULL);
- sym->init_undefined(name, version, elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL,
+ sym->init_undefined(name, version, 0, elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL,
elfcpp::STV_DEFAULT, 0);
++this->saw_undefined_;
}
@@ -2534,6 +2538,17 @@ Symbol_table::set_dynsym_indexes(unsigned int index,
// symbols.
index = versions->finalize(this, index, syms);
+ // Process target-specific symbols.
+ for (std::vector<Symbol*>::iterator p = this->target_symbols_.begin();
+ p != this->target_symbols_.end();
+ ++p)
+ {
+ (*p)->set_dynsym_index(index);
+ ++index;
+ syms->push_back(*p);
+ dynpool->add((*p)->name(), false, NULL);
+ }
+
return index;
}
@@ -2639,6 +2654,14 @@ Symbol_table::sized_finalize(off_t off, Stringpool* pool,
this->add_to_final_symtab<size>(sym, pool, &index, &off);
}
+ // Now do target-specific symbols.
+ for (std::vector<Symbol*>::iterator p = this->target_symbols_.begin();
+ p != this->target_symbols_.end();
+ ++p)
+ {
+ this->add_to_final_symtab<size>(*p, pool, &index, &off);
+ }
+
this->output_count_ = index - orig_index;
return off;
@@ -3108,6 +3131,54 @@ Symbol_table::sized_write_globals(const Stringpool* sympool,
}
}
+ // Write the target-specific symbols.
+ for (std::vector<Symbol*>::const_iterator p = this->target_symbols_.begin();
+ p != this->target_symbols_.end();
+ ++p)
+ {
+ Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(*p);
+
+ unsigned int sym_index = sym->symtab_index();
+ unsigned int dynsym_index;
+ if (dynamic_view == NULL)
+ dynsym_index = -1U;
+ else
+ dynsym_index = sym->dynsym_index();
+
+ unsigned int shndx;
+ switch (sym->source())
+ {
+ case Symbol::IS_CONSTANT:
+ shndx = elfcpp::SHN_ABS;
+ break;
+ case Symbol::IS_UNDEFINED:
+ shndx = elfcpp::SHN_UNDEF;
+ break;
+ default:
+ gold_unreachable();
+ }
+
+ if (sym_index != -1U)
+ {
+ sym_index -= first_global_index;
+ gold_assert(sym_index < output_count);
+ unsigned char* ps = psyms + (sym_index * sym_size);
+ this->sized_write_symbol<size, big_endian>(sym, sym->value(), shndx,
+ sym->binding(), sympool,
+ ps);
+ }
+
+ if (dynsym_index != -1U)
+ {
+ dynsym_index -= first_dynamic_global_index;
+ gold_assert(dynsym_index < dynamic_count);
+ unsigned char* pd = dynamic_view + (dynsym_index * sym_size);
+ this->sized_write_symbol<size, big_endian>(sym, sym->value(), shndx,
+ sym->binding(), dynpool,
+ pd);
+ }
+ }
+
of->write_output_view(this->offset_, oview_size, psyms);
if (dynamic_view != NULL)
of->write_output_view(this->dynamic_offset_, dynamic_size, dynamic_view);