X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Fsymtab.cc;h=a53f6c93fb472f5f10522c0e2155448df261167a;hb=dc1c8a16a38dec431c77f49cf50a9b62d6366138;hp=156c876a62785cea85eda83eb368944af5a0775d;hpb=8b4ee0a5c134be874ba44038d2fbd4d9b7f6d3ee;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/symtab.cc b/gold/symtab.cc index 156c876a62..a53f6c93fb 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -285,11 +285,12 @@ Sized_symbol::init_constant(const char* name, const char* version, template void Sized_symbol::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(); 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* sized_target = parameters->sized_target(); - 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::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(sym, pool, &index, &off); } + // Now do target-specific symbols. + for (std::vector::iterator p = this->target_symbols_.begin(); + p != this->target_symbols_.end(); + ++p) + { + this->add_to_final_symtab(*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::const_iterator p = this->target_symbols_.begin(); + p != this->target_symbols_.end(); + ++p) + { + Sized_symbol* sym = static_cast*>(*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(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(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);