From f0f9babffe098a7419062b594894ac5c57b28e88 Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Mon, 25 Apr 2011 20:28:48 +0000 Subject: * incremental-dump.cc (dump_incremental_inputs): Print local symbol info for each input file. * incremental.cc (Output_section_incremental_inputs::set_final_data_size): Add local symbol info to input file entries in incremental info. (Output_section_incremental_inputs::write_info_blocks): Likewise. (Sized_incr_relobj::Sized_incr_relobj): Initialize new data members. (Sized_incr_relobj::do_add_symbols): Cosmetic change. (Sized_incr_relobj::do_count_local_symbols): Replace stub with implementation. (Sized_incr_relobj::do_finalize_local_symbols): Likewise. (Sized_incr_relobj::do_relocate): Write the local symbols. (Sized_incr_dynobj::do_add_symbols): Cosmetic change. * incremental.h (Incremental_inputs_reader::get_symbol_offset): Adjust size of input file header. (Incremental_inputs_reader::get_local_symbol_offset): New function. (Incremental_inputs_reader::get_local_symbol_count): New function. (Incremental_inputs_reader::get_input_section): Adjust size of input file header. (Incremental_inputs_reader::get_global_symbol_reader): Likewise. (Sized_incr_relobj::This): New typedef. (Sized_incr_relobj::sym_size): New const data member. (Sized_incr_relobj::Local_symbol): New struct. (Sized_incr_relobj::do_output_local_symbol_count): New function. (Sized_incr_relobj::do_local_symbol_offset): New function. (Sized_incr_relobj::local_symbol_count_): New data member. (Sized_incr_relobj::output_local_dynsym_count_): New data member. (Sized_incr_relobj::local_symbol_index_): New data member. (Sized_incr_relobj::local_symbol_offset_): New data member. (Sized_incr_relobj::local_dynsym_offset_): New data member. (Sized_incr_relobj::local_symbols_): New data member. * object.h (Relobj::output_local_symbol_count): New function. (Relobj::local_symbol_offset): New function. (Relobj::do_output_local_symbol_count): New function. (Relobj::do_local_symbol_offset): New function. (Sized_relobj::do_output_local_symbol_count): New function. (Sized_relobj::do_local_symbol_offset): New function. --- gold/incremental.h | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 4 deletions(-) (limited to 'gold/incremental.h') diff --git a/gold/incremental.h b/gold/incremental.h index dad5d66..41ae188 100644 --- a/gold/incremental.h +++ b/gold/incremental.h @@ -725,7 +725,7 @@ class Incremental_inputs_reader || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); unsigned int section_count = this->get_input_section_count(); - return (this->info_offset_ + 8 + return (this->info_offset_ + 16 + section_count * input_section_entry_size + symndx * 20); } @@ -746,6 +746,26 @@ class Incremental_inputs_reader } } + // Return the offset of the first local symbol -- for objects only. + unsigned int + get_local_symbol_offset() const + { + gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT + || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); + + return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 8); + } + + // Return the local symbol count -- for objects only. + unsigned int + get_local_symbol_count() const + { + gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT + || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); + + return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 12); + } + // Return the object count -- for scripts only. unsigned int get_object_count() const @@ -816,7 +836,7 @@ class Incremental_inputs_reader { Input_section_info info; const unsigned char* p = (this->inputs_->p_ - + this->info_offset_ + 8 + + this->info_offset_ + 16 + n * input_section_entry_size); unsigned int name_offset = Swap32::readval(p); info.name = this->inputs_->get_string(name_offset); @@ -834,7 +854,7 @@ class Incremental_inputs_reader || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); unsigned int section_count = this->get_input_section_count(); const unsigned char* p = (this->inputs_->p_ - + this->info_offset_ + 8 + + this->info_offset_ + 16 + section_count * input_section_entry_size + n * 20); return Incremental_global_symbol_reader(p); @@ -1522,12 +1542,42 @@ class Sized_incr_relobj : public Sized_relobj_base } private: + // For convenience. + typedef Sized_incr_relobj This; + static const int sym_size = elfcpp::Elf_sizes::sym_size; + typedef typename Sized_relobj_base::Output_sections Output_sections; typedef Incremental_inputs_reader Inputs_reader; typedef typename Inputs_reader::Incremental_input_entry_reader Input_entry_reader; + // A local symbol. + struct Local_symbol + { + Local_symbol(const char* name_, Address value_, unsigned int size_, + unsigned int shndx_, unsigned int type_, + bool needs_dynsym_entry_) + : st_value(value_), name(name_), st_size(size_), st_shndx(shndx_), + st_type(type_), output_dynsym_index(0), + needs_dynsym_entry(needs_dynsym_entry_) + { } + // The symbol value. + Address st_value; + // The symbol name. This points to the stringpool entry. + const char* name; + // The symbol size. + unsigned int st_size; + // The output section index. + unsigned int st_shndx : 28; + // The symbol type. + unsigned int st_type : 4; + // The index of the symbol in the output dynamic symbol table. + unsigned int output_dynsym_index : 31; + // TRUE if the symbol needs to appear in the dynamic symbol table. + unsigned int needs_dynsym_entry : 1; + }; + // Return TRUE if this is an incremental (unchanged) input file. bool do_is_incremental() const @@ -1625,7 +1675,17 @@ class Sized_incr_relobj : public Sized_relobj_base // Return the number of local symbols. unsigned int do_local_symbol_count() const - { return 0; } + { return this->local_symbol_count_; } + + // Return the number of local symbols in the output symbol table. + unsigned int + do_output_local_symbol_count() const + { return this->local_symbol_count_; } + + // Return the file offset for local symbols in the output symbol table. + off_t + do_local_symbol_offset() const + { return this->local_symbol_offset_; } // Read the relocs. void @@ -1671,6 +1731,17 @@ class Sized_incr_relobj : public Sized_relobj_base unsigned int input_file_index_; // The reader for the input file. Input_entry_reader input_reader_; + // The number of local symbols. + unsigned int local_symbol_count_; + // The number of local symbols which go into the output file's dynamic + // symbol table. + unsigned int output_local_dynsym_count_; + // This starting symbol index in the output symbol table. + unsigned int local_symbol_index_; + // The file offset for local symbols in the output symbol table. + unsigned int local_symbol_offset_; + // The file offset for local symbols in the output symbol table. + unsigned int local_dynsym_offset_; // The entries in the symbol table for the external symbols. Symbols symbols_; // For each input section, the offset of the input section in its @@ -1686,6 +1757,8 @@ class Sized_incr_relobj : public Sized_relobj_base unsigned int incr_reloc_output_index_; // A copy of the incremental relocations from this object. unsigned char* incr_relocs_; + // The local symbols. + std::vector local_symbols_; }; // An incremental Dynobj. This class represents a shared object that has -- cgit v1.1