diff options
Diffstat (limited to 'gold/incremental.cc')
-rw-r--r-- | gold/incremental.cc | 166 |
1 files changed, 81 insertions, 85 deletions
diff --git a/gold/incremental.cc b/gold/incremental.cc index b831b97..d49c8a5 100644 --- a/gold/incremental.cc +++ b/gold/incremental.cc @@ -276,6 +276,7 @@ Sized_incremental_binary<size, big_endian>::setup_readers() // libraries and scripts. Incremental_inputs_reader<size, big_endian>& inputs = this->inputs_reader_; unsigned int count = inputs.input_file_count(); + this->input_objects_.resize(count); this->input_entry_readers_.reserve(count); this->library_map_.resize(count); this->script_map_.resize(count); @@ -327,10 +328,6 @@ Sized_incremental_binary<size, big_endian>::setup_readers() unsigned int nglobals = this->symtab_reader_.symbol_count(); this->symbol_map_.resize(nglobals); - // Initialize the status of each input file. - this->file_status_ = new unsigned char[(count + 7) / 8]; - memset(this->file_status_, 0, (count + 7) / 8); - this->has_incremental_info_ = true; } @@ -524,8 +521,6 @@ Sized_incremental_binary<size, big_endian>::do_reserve_layout( Input_entry_reader input_file = this->inputs_reader_.input_file(input_file_index); - this->set_file_is_unchanged(input_file_index); - if (input_file.type() == INCREMENTAL_INPUT_SHARED_LIBRARY) return; @@ -579,29 +574,31 @@ Sized_incremental_binary<size, big_endian>::do_process_got_plt( got->reserve_slot(i); continue; } - unsigned int got_desc = got_plt_reader.get_got_desc(i); + unsigned int symndx = got_plt_reader.get_got_symndx(i); if (got_type & 0x80) { - // This is an entry for a local symbol. GOT_DESC is the index - // of the object file entry in the list of input files. Ignore - // this entry if the object file was replaced. + // This is an entry for a local symbol. Ignore this entry if + // the object file was replaced. + unsigned int input_index = got_plt_reader.get_got_input_index(i); gold_debug(DEBUG_INCREMENTAL, "GOT entry %d, type %02x: (local symbol)", i, got_type & 0x7f); - if (this->file_is_unchanged(got_desc)) - got->reserve_slot(i); + Sized_relobj_incr<size, big_endian>* obj = + this->input_object(input_index); + if (obj != NULL) + target->reserve_local_got_entry(i, obj, symndx, got_type & 0x7f); } else { // This is an entry for a global symbol. GOT_DESC is the symbol // table index. // FIXME: This should really be a fatal error (corrupt input). - gold_assert(got_desc >= first_global && got_desc < symtab_count); - Symbol* sym = this->global_symbol(got_desc - first_global); + gold_assert(symndx >= first_global && symndx < symtab_count); + Symbol* sym = this->global_symbol(symndx - first_global); gold_debug(DEBUG_INCREMENTAL, "GOT entry %d, type %02x: %s", i, got_type, sym->name()); - got->reserve_slot_for_global(i, sym, got_type); + target->reserve_global_got_entry(i, sym, got_type); } } @@ -1146,8 +1143,8 @@ Output_section_incremental_inputs<size, big_endian>::set_final_data_size() gold_assert(entry != NULL); (*p)->set_info_offset(info_offset); // Input section count, global symbol count, local symbol offset, - // local symbol count. - info_offset += 16; + // local symbol count, first dynamic reloc, dynamic reloc count. + info_offset += 24; // Each input section. info_offset += (entry->get_input_section_count() * (8 + 2 * sizeof_addr)); @@ -1216,7 +1213,7 @@ Output_section_incremental_inputs<size, big_endian>::set_final_data_size() unsigned int plt_count = target->plt_entry_count(); unsigned int got_plt_size = 8; // GOT entry count, PLT entry count. got_plt_size = (got_plt_size + got_count + 3) & ~3; // GOT type array. - got_plt_size += got_count * 4 + plt_count * 4; // GOT array, PLT array. + got_plt_size += got_count * 8 + plt_count * 4; // GOT array, PLT array. inputs->got_plt_section()->set_current_data_size(got_plt_size); } @@ -1393,11 +1390,15 @@ Output_section_incremental_inputs<size, big_endian>::write_info_blocks( unsigned int nsyms = syms->size(); off_t locals_offset = relobj->local_symbol_offset(); unsigned int nlocals = relobj->output_local_symbol_count(); + unsigned int first_dynrel = relobj->first_dyn_reloc(); + unsigned int ndynrel = relobj->dyn_reloc_count(); Swap32::writeval(pov, nsections); Swap32::writeval(pov + 4, nsyms); Swap32::writeval(pov + 8, static_cast<unsigned int>(locals_offset)); Swap32::writeval(pov + 12, nlocals); - pov += 16; + Swap32::writeval(pov + 16, first_dynrel); + Swap32::writeval(pov + 20, ndynrel); + pov += 24; // Build a temporary array to map input section indexes // from the original object file index to the index in the @@ -1592,11 +1593,14 @@ struct Got_plt_view_info unsigned int first_plt_entry_offset; // Size of a PLT entry (this is a target-dependent value). unsigned int plt_entry_size; - // Value to write in the GOT descriptor array. For global symbols, - // this is the global symbol table index; for local symbols, it is - // the offset of the input file entry in the .gnu_incremental_inputs - // section. - unsigned int got_descriptor; + // Symbol index to write in the GOT descriptor array. For global symbols, + // this is the global symbol table index; for local symbols, it is the + // local symbol table index. + unsigned int sym_index; + // Input file index to write in the GOT descriptor array. For global + // symbols, this is 0; for local symbols, it is the index of the input + // file entry in the .gnu_incremental_inputs section. + unsigned int input_index; }; // Functor class for processing a GOT offset list for local symbols. @@ -1621,8 +1625,9 @@ class Local_got_offset_visitor : public Got_offset_list::Visitor // high bit to flag a local symbol. gold_assert(got_type < 0x7f); this->info_.got_type_p[got_index] = got_type | 0x80; - unsigned char* pov = this->info_.got_desc_p + got_index * 4; - elfcpp::Swap<32, big_endian>::writeval(pov, this->info_.got_descriptor); + unsigned char* pov = this->info_.got_desc_p + got_index * 8; + elfcpp::Swap<32, big_endian>::writeval(pov, this->info_.sym_index); + elfcpp::Swap<32, big_endian>::writeval(pov + 4, this->info_.input_index); } private: @@ -1652,8 +1657,9 @@ class Global_got_offset_visitor : public Got_offset_list::Visitor // high bit to flag a local symbol. gold_assert(got_type < 0x7f); this->info_.got_type_p[got_index] = got_type; - unsigned char* pov = this->info_.got_desc_p + got_index * 4; - elfcpp::Swap<32, big_endian>::writeval(pov, this->info_.got_descriptor); + unsigned char* pov = this->info_.got_desc_p + got_index * 8; + elfcpp::Swap<32, big_endian>::writeval(pov, this->info_.sym_index); + elfcpp::Swap<32, big_endian>::writeval(pov + 4, 0); } private: @@ -1680,7 +1686,8 @@ class Global_symbol_visitor_got_plt const Got_offset_list* got_offsets = sym->got_offset_list(); if (got_offsets != NULL) { - this->info_.got_descriptor = sym->symtab_index(); + this->info_.sym_index = sym->symtab_index(); + this->info_.input_index = 0; Got_visitor v(this->info_); got_offsets->for_all_got_offsets(&v); } @@ -1719,7 +1726,7 @@ Output_section_incremental_inputs<size, big_endian>::write_got_plt( view_info.got_type_p = pov + 8; view_info.got_desc_p = (view_info.got_type_p + ((view_info.got_count + 3) & ~3)); - view_info.plt_desc_p = view_info.got_desc_p + view_info.got_count * 4; + view_info.plt_desc_p = view_info.got_desc_p + view_info.got_count * 8; gold_assert(pov + view_size == view_info.plt_desc_p + view_info.plt_count * 4); @@ -1745,7 +1752,7 @@ Output_section_incremental_inputs<size, big_endian>::write_got_plt( gold_assert(entry != NULL); const Object* obj = entry->object(); gold_assert(obj != NULL); - view_info.got_descriptor = (*p)->get_file_index(); + view_info.input_index = (*p)->get_file_index(); Got_visitor v(view_info); obj->for_all_local_got_entries(&v); } @@ -1755,35 +1762,35 @@ Output_section_incremental_inputs<size, big_endian>::write_got_plt( symtab_->for_all_symbols<size, Symbol_visitor>(Symbol_visitor(view_info)); } -// Class Sized_incr_relobj. Most of these methods are not used for +// Class Sized_relobj_incr. Most of these methods are not used for // Incremental objects, but are required to be implemented by the // base class Object. template<int size, bool big_endian> -Sized_incr_relobj<size, big_endian>::Sized_incr_relobj( +Sized_relobj_incr<size, big_endian>::Sized_relobj_incr( const std::string& name, Sized_incremental_binary<size, big_endian>* ibase, unsigned int input_file_index) - : Sized_relobj_base<size, big_endian>(name, NULL), ibase_(ibase), + : Sized_relobj<size, big_endian>(name, NULL), ibase_(ibase), input_file_index_(input_file_index), input_reader_(ibase->inputs_reader().input_file(input_file_index)), local_symbol_count_(0), output_local_dynsym_count_(0), local_symbol_index_(0), local_symbol_offset_(0), local_dynsym_offset_(0), - symbols_(), section_offsets_(), incr_reloc_offset_(-1U), - incr_reloc_count_(0), incr_reloc_output_index_(0), incr_relocs_(NULL), - local_symbols_() + symbols_(), incr_reloc_offset_(-1U), incr_reloc_count_(0), + incr_reloc_output_index_(0), incr_relocs_(NULL), local_symbols_() { if (this->input_reader_.is_in_system_directory()) this->set_is_in_system_directory(); const unsigned int shnum = this->input_reader_.get_input_section_count() + 1; this->set_shnum(shnum); + ibase->set_input_object(input_file_index, this); } // Read the symbols. template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_read_symbols(Read_symbols_data*) +Sized_relobj_incr<size, big_endian>::do_read_symbols(Read_symbols_data*) { gold_unreachable(); } @@ -1792,7 +1799,7 @@ Sized_incr_relobj<size, big_endian>::do_read_symbols(Read_symbols_data*) template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_layout( +Sized_relobj_incr<size, big_endian>::do_layout( Symbol_table*, Layout* layout, Read_symbols_data*) @@ -1802,7 +1809,7 @@ Sized_incr_relobj<size, big_endian>::do_layout( gold_assert(incremental_inputs != NULL); Output_sections& out_sections(this->output_sections()); out_sections.resize(shnum); - this->section_offsets_.resize(shnum); + this->section_offsets().resize(shnum); for (unsigned int i = 1; i < shnum; i++) { typename Input_entry_reader::Input_section_info sect = @@ -1815,7 +1822,7 @@ Sized_incr_relobj<size, big_endian>::do_layout( Output_section* os = this->ibase_->output_section(sect.output_shndx); gold_assert(os != NULL); out_sections[i] = os; - this->section_offsets_[i] = static_cast<Address>(sect.sh_offset); + this->section_offsets()[i] = static_cast<Address>(sect.sh_offset); } } @@ -1823,7 +1830,7 @@ Sized_incr_relobj<size, big_endian>::do_layout( // input files from a plugin. template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_layout_deferred_sections(Layout*) +Sized_relobj_incr<size, big_endian>::do_layout_deferred_sections(Layout*) { } @@ -1831,7 +1838,7 @@ Sized_incr_relobj<size, big_endian>::do_layout_deferred_sections(Layout*) template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_add_symbols( +Sized_relobj_incr<size, big_endian>::do_add_symbols( Symbol_table* symtab, Read_symbols_data*, Layout*) @@ -1916,7 +1923,7 @@ Sized_incr_relobj<size, big_endian>::do_add_symbols( template<int size, bool big_endian> Archive::Should_include -Sized_incr_relobj<size, big_endian>::do_should_include_member( +Sized_relobj_incr<size, big_endian>::do_should_include_member( Symbol_table*, Layout*, Read_symbols_data*, @@ -1929,29 +1936,18 @@ Sized_incr_relobj<size, big_endian>::do_should_include_member( template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_for_all_global_symbols( +Sized_relobj_incr<size, big_endian>::do_for_all_global_symbols( Read_symbols_data*, Library_base::Symbol_visitor_base*) { // This routine is not used for incremental objects. } -// Iterate over local symbols, calling a visitor class V for each GOT offset -// associated with a local symbol. - -template<int size, bool big_endian> -void -Sized_incr_relobj<size, big_endian>::do_for_all_local_got_entries( - Got_offset_list::Visitor*) const -{ - // FIXME: Implement Sized_incr_relobj::do_for_all_local_got_entries. -} - // Get the size of a section. template<int size, bool big_endian> uint64_t -Sized_incr_relobj<size, big_endian>::do_section_size(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_size(unsigned int) { gold_unreachable(); } @@ -1960,7 +1956,7 @@ Sized_incr_relobj<size, big_endian>::do_section_size(unsigned int) template<int size, bool big_endian> std::string -Sized_incr_relobj<size, big_endian>::do_section_name(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_name(unsigned int) { gold_unreachable(); } @@ -1969,7 +1965,7 @@ Sized_incr_relobj<size, big_endian>::do_section_name(unsigned int) template<int size, bool big_endian> Object::Location -Sized_incr_relobj<size, big_endian>::do_section_contents(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_contents(unsigned int) { gold_unreachable(); } @@ -1978,7 +1974,7 @@ Sized_incr_relobj<size, big_endian>::do_section_contents(unsigned int) template<int size, bool big_endian> uint64_t -Sized_incr_relobj<size, big_endian>::do_section_flags(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_flags(unsigned int) { gold_unreachable(); } @@ -1987,7 +1983,7 @@ Sized_incr_relobj<size, big_endian>::do_section_flags(unsigned int) template<int size, bool big_endian> uint64_t -Sized_incr_relobj<size, big_endian>::do_section_entsize(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_entsize(unsigned int) { gold_unreachable(); } @@ -1996,7 +1992,7 @@ Sized_incr_relobj<size, big_endian>::do_section_entsize(unsigned int) template<int size, bool big_endian> uint64_t -Sized_incr_relobj<size, big_endian>::do_section_address(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_address(unsigned int) { gold_unreachable(); } @@ -2005,7 +2001,7 @@ Sized_incr_relobj<size, big_endian>::do_section_address(unsigned int) template<int size, bool big_endian> unsigned int -Sized_incr_relobj<size, big_endian>::do_section_type(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_type(unsigned int) { gold_unreachable(); } @@ -2014,7 +2010,7 @@ Sized_incr_relobj<size, big_endian>::do_section_type(unsigned int) template<int size, bool big_endian> unsigned int -Sized_incr_relobj<size, big_endian>::do_section_link(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_link(unsigned int) { gold_unreachable(); } @@ -2023,7 +2019,7 @@ Sized_incr_relobj<size, big_endian>::do_section_link(unsigned int) template<int size, bool big_endian> unsigned int -Sized_incr_relobj<size, big_endian>::do_section_info(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_info(unsigned int) { gold_unreachable(); } @@ -2032,7 +2028,7 @@ Sized_incr_relobj<size, big_endian>::do_section_info(unsigned int) template<int size, bool big_endian> uint64_t -Sized_incr_relobj<size, big_endian>::do_section_addralign(unsigned int) +Sized_relobj_incr<size, big_endian>::do_section_addralign(unsigned int) { gold_unreachable(); } @@ -2041,7 +2037,7 @@ Sized_incr_relobj<size, big_endian>::do_section_addralign(unsigned int) template<int size, bool big_endian> Xindex* -Sized_incr_relobj<size, big_endian>::do_initialize_xindex() +Sized_relobj_incr<size, big_endian>::do_initialize_xindex() { gold_unreachable(); } @@ -2050,7 +2046,7 @@ Sized_incr_relobj<size, big_endian>::do_initialize_xindex() template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_get_global_symbol_counts( +Sized_relobj_incr<size, big_endian>::do_get_global_symbol_counts( const Symbol_table*, size_t*, size_t*) const { gold_unreachable(); @@ -2060,7 +2056,7 @@ Sized_incr_relobj<size, big_endian>::do_get_global_symbol_counts( template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_read_relocs(Read_relocs_data*) +Sized_relobj_incr<size, big_endian>::do_read_relocs(Read_relocs_data*) { } @@ -2069,7 +2065,7 @@ Sized_incr_relobj<size, big_endian>::do_read_relocs(Read_relocs_data*) template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_gc_process_relocs(Symbol_table*, +Sized_relobj_incr<size, big_endian>::do_gc_process_relocs(Symbol_table*, Layout*, Read_relocs_data*) { @@ -2080,7 +2076,7 @@ Sized_incr_relobj<size, big_endian>::do_gc_process_relocs(Symbol_table*, template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_scan_relocs(Symbol_table*, +Sized_relobj_incr<size, big_endian>::do_scan_relocs(Symbol_table*, Layout* layout, Read_relocs_data*) { @@ -2125,7 +2121,7 @@ Sized_incr_relobj<size, big_endian>::do_scan_relocs(Symbol_table*, template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_count_local_symbols( +Sized_relobj_incr<size, big_endian>::do_count_local_symbols( Stringpool_template<char>* pool, Stringpool_template<char>*) { @@ -2166,7 +2162,7 @@ Sized_incr_relobj<size, big_endian>::do_count_local_symbols( template<int size, bool big_endian> unsigned int -Sized_incr_relobj<size, big_endian>::do_finalize_local_symbols( +Sized_relobj_incr<size, big_endian>::do_finalize_local_symbols( unsigned int index, off_t off, Symbol_table*) @@ -2180,7 +2176,7 @@ Sized_incr_relobj<size, big_endian>::do_finalize_local_symbols( template<int size, bool big_endian> unsigned int -Sized_incr_relobj<size, big_endian>::do_set_local_dynsym_indexes( +Sized_relobj_incr<size, big_endian>::do_set_local_dynsym_indexes( unsigned int index) { // FIXME: set local dynsym indexes. @@ -2191,7 +2187,7 @@ Sized_incr_relobj<size, big_endian>::do_set_local_dynsym_indexes( template<int size, bool big_endian> unsigned int -Sized_incr_relobj<size, big_endian>::do_set_local_dynsym_offset(off_t) +Sized_relobj_incr<size, big_endian>::do_set_local_dynsym_offset(off_t) { return 0; } @@ -2204,7 +2200,7 @@ Sized_incr_relobj<size, big_endian>::do_set_local_dynsym_offset(off_t) template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_relocate(const Symbol_table*, +Sized_relobj_incr<size, big_endian>::do_relocate(const Symbol_table*, const Layout* layout, Output_file* of) { @@ -2330,7 +2326,7 @@ Sized_incr_relobj<size, big_endian>::do_relocate(const Symbol_table*, template<int size, bool big_endian> void -Sized_incr_relobj<size, big_endian>::do_set_section_offset(unsigned int, +Sized_relobj_incr<size, big_endian>::do_set_section_offset(unsigned int, uint64_t) { } @@ -2617,7 +2613,7 @@ make_sized_incremental_object( obj = new Sized_incr_dynobj<32, false>(name, sized_ibase, input_file_index); else - obj = new Sized_incr_relobj<32, false>(name, sized_ibase, + obj = new Sized_relobj_incr<32, false>(name, sized_ibase, input_file_index); } break; @@ -2631,7 +2627,7 @@ make_sized_incremental_object( obj = new Sized_incr_dynobj<32, true>(name, sized_ibase, input_file_index); else - obj = new Sized_incr_relobj<32, true>(name, sized_ibase, + obj = new Sized_relobj_incr<32, true>(name, sized_ibase, input_file_index); } break; @@ -2645,7 +2641,7 @@ make_sized_incremental_object( obj = new Sized_incr_dynobj<64, false>(name, sized_ibase, input_file_index); else - obj = new Sized_incr_relobj<64, false>(name, sized_ibase, + obj = new Sized_relobj_incr<64, false>(name, sized_ibase, input_file_index); } break; @@ -2659,7 +2655,7 @@ make_sized_incremental_object( obj = new Sized_incr_dynobj<64, true>(name, sized_ibase, input_file_index); else - obj = new Sized_incr_relobj<64, true>(name, sized_ibase, + obj = new Sized_relobj_incr<64, true>(name, sized_ibase, input_file_index); } break; @@ -2705,7 +2701,7 @@ template class Sized_incremental_binary<32, false>; template -class Sized_incr_relobj<32, false>; +class Sized_relobj_incr<32, false>; template class Sized_incr_dynobj<32, false>; @@ -2716,7 +2712,7 @@ template class Sized_incremental_binary<32, true>; template -class Sized_incr_relobj<32, true>; +class Sized_relobj_incr<32, true>; template class Sized_incr_dynobj<32, true>; @@ -2727,7 +2723,7 @@ template class Sized_incremental_binary<64, false>; template -class Sized_incr_relobj<64, false>; +class Sized_relobj_incr<64, false>; template class Sized_incr_dynobj<64, false>; @@ -2738,7 +2734,7 @@ template class Sized_incremental_binary<64, true>; template -class Sized_incr_relobj<64, true>; +class Sized_relobj_incr<64, true>; template class Sized_incr_dynobj<64, true>; |