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 2/3] Support for incremental linking: write incremental got_plt info


Cary Coutant <ccoutant@google.com> writes:

> elfcpp/ChangeLog:
>
> 	* elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_GOT_PLT.
>
> gold/ChangeLog:
>
> 	* arm.cc (Target_arm::got_size): Add const.
> 	(Target_arm::got_entry_count): New function.
> 	(Target_arm::plt_entry_count): New function.
> 	(Target_arm::first_plt_entry_offset): New function.
> 	(Target_arm::plt_entry_size): New function.
> 	(Output_data_plt_arm::entry_count): New function.
> 	(Output_data_plt_arm::first_plt_entry_offset): New function.
> 	(Output_data_plt_arm::get_plt_entry_size): New function.
> 	* i386.cc (Target_i386::got_size): Add const.
> 	(Target_i386::got_entry_count): New function.
> 	(Target_i386::plt_entry_count): New function.
> 	(Target_i386::first_plt_entry_offset): New function.
> 	(Target_i386::plt_entry_size): New function.
> 	(Output_data_plt_i386::entry_count): New function.
> 	(Output_data_plt_i386::first_plt_entry_offset): New function.
> 	(Output_data_plt_i386::get_plt_entry_size): New function.
> 	* incremental-dump.cc (dump_incremental_inputs): Adjust call to
> 	find_incremental_inputs_sections.  Dump incremental_got_plt section.
> 	* incremental.cc: Include target.h.
> 	(Sized_incremental_binary::do_find_incremental_inputs_sections): Add
> 	parameter.  Adjust all callers.  Find incremental_got_plt section.
> 	(Incremental_inputs::create_data_sections): Create incremental_got_plt
> 	section.
> 	(Output_section_incremental_inputs::set_final_data_size): Calculate
> 	size of incremental_got_plt section.
> 	(Output_section_incremental_inputs::do_write): Write the
> 	incremental_got_plt section.
> 	(Got_plt_view_info): New struct.
> 	(Local_got_offset_visitor): New class.
> 	(Global_got_offset_visitor): New class.
> 	(Global_symbol_visitor_got_plt): New class.
> 	(Output_section_incremental_inputs::write_got_plt): New function.
> 	* incremental.h (Incremental_binary::find_incremental_inputs_sections):
> 	Add parameter.  Adjust all callers.
> 	(Incremental_binary::do_find_incremental_inputs_sections): Likewise.
> 	(Incremental_inputs::got_plt_section): New function.
> 	(Incremental_inputs::got_plt_section_): New data member.
> 	(Incremental_got_plt_reader): New class.
> 	* layout.cc (Layout::create_incremental_info_sections): Add the
> 	incremental_got_plt section.
> 	* object.h (Got_offset_list::get_list): New function.
> 	(Got offset_list::for_all_got_offsets): New function.
> 	(Sized_relobj::local_got_offset_list): New function.
> 	* powerpc.cc (Target_powerpc::got_size): Add const.
> 	(Target_powerpc::got_entry_count): New function.
> 	(Target_powerpc::plt_entry_count): New function.
> 	(Target_powerpc::first_plt_entry_offset): New function.
> 	(Target_powerpc::plt_entry_size): New function.
> 	(Output_data_plt_powerpc::entry_count): New function.
> 	(Output_data_plt_powerpc::first_plt_entry_offset): New function.
> 	(Output_data_plt_powerpc::get_plt_entry_size): New function.
> 	* sparc.cc (Target_sparc::got_size): Add const.
> 	(Target_sparc::got_entry_count): New function.
> 	(Target_sparc::plt_entry_count): New function.
> 	(Target_sparc::first_plt_entry_offset): New function.
> 	(Target_sparc::plt_entry_size): New function.
> 	(Output_data_plt_sparc::entry_count): New function.
> 	(Output_data_plt_sparc::first_plt_entry_offset): New function.
> 	(Output_data_plt_sparc::get_plt_entry_size): New function.
> 	* symtab.h (Symbol::got_offset_list): New function.
> 	(Symbol_table::for_all_symbols): New function.
> 	* target.h (Sized_target::got_entry_count): New function.
> 	(Sized_target::plt_entry_count): New function.
> 	(Sized_target::plt_entry_size): New function.
> 	* x86_64.cc (Target_x86_64::got_size): Add const.
> 	(Target_x86_64::got_entry_count): New function.
> 	(Target_x86_64::plt_entry_count): New function.
> 	(Target_x86_64::first_plt_entry_offset): New function.
> 	(Target_x86_64::plt_entry_size): New function.
> 	(Output_data_plt_x86_64::entry_count): New function.
> 	(Output_data_plt_x86_64::first_plt_entry_offset): New function.
> 	(Output_data_plt_x86_64::get_plt_entry_size): New function.


> +  void
> +  operator()(unsigned int got_type, unsigned int got_offset)
> +  {
> +    unsigned int got_index = got_offset / this->got_entry_size_;
> +    gold_assert(got_index < this->info_.got_count);
> +    // We can only handle GOT entry types in the range 0..0x7e
> +    // because we use a byte array to store them, and we use the
> +    // 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);
> +  }

This is interesting, because it means that if you change the values qof
the GOT_TYPE_ enums in the gold source code, existing incremental input
files will fail in surprising ways.  That is, it makes the specific enum
values part of the incremental linking ABI.  We won't remember to change
the incremental link version every time we change an enum value.  On the
other hand, it's fairly unlikely that we will ever change an enum
value.  Any suggestion on how to make this more foolproof?q


This is OK.

Thanks.

Ian


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