This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gold patch] Incremental 11/18: update GOT/PLT


Cary Coutant <ccoutant@google.com> writes:

> 	* gold.cc (queue_middle_tasks): Process existing GOT/PLT entries.
> 	* incremental-dump.cc (dump_incremental_inputs): Mask high-order
> 	bit when checking got_type.
> 	* incremental.cc (Sized_incremental_binary::setup_readers):
> 	Store symbol table and string table locations; initialize bit vector
> 	of file status flags.
> 	(Sized_incremental_binary::do_reserve_layout): Set bit flag for
> 	unchanged files.
> 	(Sized_incremental_binary::do_process_got_plt): New function.
> 	(Sized_incremental_binary::get_symtab_view): Use stored locations.
> 	(Output_section_incremental_inputs::set_final_data_size): Record
> 	file index for each input file.
> 	(Output_section_incremental_inputs::write_got_plt): Store file index
> 	instead of input entry offset for each GOT entry.
> 	* incremental.h
> 	(Incremental_input_entry::Incremental_input_entry): Initialize new
> 	data member.
> 	(Incremental_input_entry::set_offset): Store file index.
> 	(Incremental_input_entry::get_file_index): New function.
> 	(Incremental_input_entry::file_index_): New data member.
> 	(Incremental_binary::process_got_plt): New function.
> 	(Incremental_binary::do_process_got_plt): New function.
> 	(Sized_incremental_binary::Sized_incremental_binary): Initialize new
> 	data members.
> 	(Sized_incremental_binary::~Sized_incremental_binary): New destructor.
> 	(Sized_incremental_binary::set_file_is_unchanged): New function.
> 	(Sized_incremental_binary::file_is_unchanged): New function.
> 	(Sized_incremental_binary::do_process_got_plt): New function.
> 	(Sized_incremental_binary::file_status_): New data member.
> 	(Sized_incremental_binary::main_symtab_loc_): New data member.
> 	(Sized_incremental_binary::main_strtab_loc_): New data member.
> 	* output.cc (Output_data_got::Got_entry::write): Add case
> 	RESERVED_CODE.
> 	(Output_data_got::add_global): Call add_got_entry.
> 	(Output_data_got::add_global_plt): Likewise.
> 	(Output_data_got::add_global_with_rel): Likewise.
> 	(Output_data_got::add_global_with_rela): Likewise.
> 	(Output_data_got::add_global_pair_with_rel): Call add_got_entry_pair.
> 	(Output_data_got::add_global_pair_with_rela): Likewise.
> 	(Output_data_got::add_local): Call add_got_entry.
> 	(Output_data_got::add_local_plt): Likewise.
> 	(Output_data_got::add_local_with_rel): Likewise.
> 	(Output_data_got::add_local_with_rela): Likewise.
> 	(Output_data_got::add_local_pair_with_rel): Call add_got_entry_pair.
> 	(Output_data_got::add_local_pair_with_rela): Likewise.
> 	(Output_data_got::reserve_slot): New function.
> 	(Output_data_got::reserve_slot_for_global): New function.
> 	(Output_section::add_output_section_data): Edit FIXME.
> 	* output.h
> 	(Output_section_data_build::Output_section_data_build): New
> 	constructor with size parameter.
> 	(Output_data_space::Output_data_space): Likewise.
> 	(Output_data_got::Output_data_got): Initialize new data member; new
> 	constructor with size parameter.
> 	(Output_data_got::add_constant): Call add_got_entry.
> 	(Output_data_got::reserve_slot): New function.
> 	(Output_data_got::reserve_slot_for_global): New function.
> 	(class Output_data_got::Got_entry): Add RESERVED_CODE.
> 	(Output_data_got::add_got_entry): New function.
> 	(Output_data_got::add_got_entry_pair): New function.
> 	(Output_data_got::free_list_): New data member.
> 	* target.h (Sized_target::init_got_plt_for_update): New function.
> 	(Sized_target::register_global_plt_entry): New function.
> 	* x86_64.cc (Output_data_plt_x86_64::Output_data_plt_x86_64):
> 	Initialize new data member; call init; add constructor with PLT count.
> 	(Output_data_plt_x86_64::init): New function.
> 	(Output_data_plt_x86_64::add_relocation): New function.
> 	(Output_data_plt_x86_64::reserve_slot): New function.
> 	(Output_data_plt_x86_64::free_list_): New data member.
> 	(Target_x86_64::init_got_plt_for_update): New function.
> 	(Target_x86_64::register_global_plt_entry): New function.
> 	(Output_data_plt_x86_64::add_entry): Allocate from free list for
> 	incremental updates.
> 	(Output_data_plt_x86_64::add_relocation): New function.


> +  // Set the flag for input file N to indicate that the file is unchanged.
> +  void
> +  set_file_is_unchanged(unsigned int n)
> +  {
> +    gold_assert(this->file_status_ != NULL);
> +    this->file_status_[n / 8] |= 1U << (n % 8);
> +  }

You don't have to do this, but consider using std::vector<bool> for
file_status_.  That will give the tight memory layout without requiring
that we get the bit operations right.

> +  // Create a new GOT entry and return its offset.
> +  unsigned int
> +  add_got_entry(Got_entry got_entry)
> +  {
> +    if (!this->is_data_size_valid())
> +      {
> +	this->entries_.push_back(got_entry);
> +	this->set_got_size();
> +	return this->last_got_offset();
> +      }
> +    else
> +      {
> +	// For an incremental update, find an available slot.
> +	off_t got_offset = this->free_list_.allocate(size / 8, size / 8, 0);
> +	if (got_offset == -1)
> +	  gold_fatal(_("out of patch space (GOT);"
> +		       " relink with --incremental-full"));
> +	unsigned int got_index = got_offset / (size / 8);
> +	gold_assert(got_index < this->entries_.size());
> +	this->entries_[got_index] = got_entry;
> +	return static_cast<unsigned int>(got_offset);
> +      }
> +  }
> +
> +  // Create a pair of new GOT entries and return the offset of the first.
> +  unsigned int
> +  add_got_entry_pair(Got_entry got_entry_1, Got_entry got_entry_2)
> +  {
> +    if (!this->is_data_size_valid())
> +      {
> +	unsigned int got_offset;
> +	this->entries_.push_back(got_entry_1);
> +	got_offset = this->last_got_offset();
> +	this->entries_.push_back(got_entry_2);
> +	this->set_got_size();
> +	return got_offset;
> +      }
> +    else
> +      {
> +	// For an incremental update, find an available pair of slots.
> +	off_t got_offset = this->free_list_.allocate(2 * size / 8, size / 8, 0);
> +	if (got_offset == -1)
> +	  gold_fatal(_("out of patch space (GOT);"
> +		       " relink with --incremental-full"));
> +	unsigned int got_index = got_offset / (size / 8);
> +	gold_assert(got_index < this->entries_.size());
> +	this->entries_[got_index] = got_entry_1;
> +	this->entries_[got_index + 1] = got_entry_2;
> +	return static_cast<unsigned int>(got_offset);
> +      }
> +  }

I think these functions are complex enough that they should move from
output.h to output.cc.


This is OK with those changes.

Sorry for the long delay.  Thanks.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]