diff options
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r-- | gold/symtab.cc | 85 |
1 files changed, 78 insertions, 7 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc index 156c876..a53f6c9 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); |