(struct Opd_ent): Use "Address" rather than "Offset".
(Output_data_got_powerpc::got_base_offset): Return Valtype.
(Target_powerpc::got_section): Make public.
(Target_powerpc::scan_relocs): Move code setting symbols..
(Powerpc_relobj::do_scan_relocs): ..to here, new function.
Create _SDA_BASE_ only when referenced.
dynamic relocs for GOT_TPREL got entries, without symbol if
resolving locally.
(Target_powerpc::do_gc_add_reference): Don't add for dynamic objects.
(Target_powerpc::scan_relocs): Define _GLOBAL_OFFSET_TABLE_ early.
(Target_powerpc::Relocate:relocate): REL32 reloc may be unaligned.
(Target_powerpc::do_finalize_sections): Call it.
(Output_data_save_res): New class and supporting functions.
(Target_powerpc::symval_for_branch): Only look up .opd entry for
normal symbols defined in object files.
(struct Opd_ent): Make "discard" a bit field. Add "gc_mark".
(Target_powerpc::do_gc_mark_symbol): Delay marking function code
section if scan_opd_relocs not yet called.
(Target_powerpc::gc_process_relocs): Call process_gc_mark.
do_plt_address_for_global): New functions.
(Output_data_got_powerpc::do_write): Don't segfault when linking
statically.
(Output_data_plt_powerpc::add_entry, add_ifunc_entry,
add_local_ifunc_entry): Return true on adding entry..
(Target_powerpc::make_plt_entry): ..use to avoid unnecessary
glink->add_entry call. Remove unused symtab param. Adjust calls.
(Target_powerpc::make_local_ifunc_plt_entry): Likewise.
(Target_powerpc::make_iplt_section): Remove symtab param. Don't
set up symbols here.
(Target_powerpc::do_finalize_sections): Instead set up __rela_iplt
syms here. Do so even when no .iplt. Don't segfault when linking
statically.
(Output_data_glink::add_entry, find_entry): Rearrange params. Add
new variants without reloc param.
(Glink_sym_ent::Glink_sym_ent): Likewise.
(Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Accept any
reloc when refs will resolve to plt call stub.
(Target_powerpc::Scan::local): Correct ifunc handling. Allow
R_PPC_PLTREL24 to resolve locally.
(Target_powerpc::Scan::global): Correct ifunc handling.
(Target_powerpc::Relocate::relocate): Correct local sym glink
lookup. Don't destroy "value" when we have a plt call stub,
and when checking plt call validity.
(Target_powerpc::do_dynsym_value): Simplify.
(Target_powerpc::iplt_section, make_iplt_section,
reloc_needs_plt_for_ifunc, make_local_ifunc_plt_entry): New functions.
(Target_powerpc::make_plt_entry): Handle ifunc syms.
Target_powerpc::plt_entry_count): Count iplt entries too.
(Output_data_plt_powerpc::Output_data_plt_powerpc): Don't create
reloc section in constructor. New params.
(Target_powerpc::make_plt_section): Create reloc section here instead.
(Output_data_plt_powerpc::add_ifunc_entry, add_local_ifunc_entry): New
functions.
(Output_data_plt_powerpc::initial_plt_entry_size_, name_): New vars.
(Output_data_glink::add_entry, find_entry): New functions to
deal with local syms.
(Glink_sym_ent): Add support for local syms.
(Output_data_glink::do_write): Handle ifunc plt entries.
(Target_powerpc::Scan::get_reference_flags): Handle more relocs.
(Target_powerpc::Scan::local, global): Handle ifunc syms.
(Target_powerpc::Relocate::relocate): Likewise.
(Target_powerpc::do_dynsym_value): Use glink stub, not plt entry.
do_adjust_local_symbol): New functions.
* object.cc (Sized_relobj_file::do_count_local_symbols): Use the above.
* powerpc.cc (Powerpc_relobj::do_adjust_local_symbol): New function.
(Powerpc_relobj::scan_opd_relocs): Warn on unexpected opd relocs
and irregular opd entry spacing.
(Powerpc_relobj::do_read_relocs): Add opd size checks.
(Global_symbol_visitor_opd): New functor.
(Target_powerpc::do_finalize_sections): Omit global symbols defined
on deleted opd entries.
against symbols in discarded sections. Pass is_discarded
param.
* arm.cc, * i386.cc, * sparc.cc, * x86_64.cc (Target_*::Scan::local):
Add is_discarded param.
* powerpc (Target_powerpc::Scan::local): Likewise. Use
is_discarded to flag opd entry as discarded. Don't emit dyn
relocs on such entries.
(Target_powerpc::Scan::global): Similarly detect and handle
such opd entries.
(Powerpc_relobj): Replace opd_ent_shndx_ and opd_ent_off_ with
opd_ent_. Update all uses.
(Powerpc_relobj::get_opd_discard, set_opd_discard): New functions.
(Target_powerpc::relocate_section): Zero out discarded opd
entry relocs.
(Sized_target::gc_add_reference, do_gc_add_reference): New functions.
* gc.h (gc_process_relocs): Call target gc_add_reference.
* gold.cc (queue_middle_tasks): Use gc_mark_symbol on start sym.
* symtab.cc (Symbol_table::gc_mark_undef_symbols): Use gc_mark_symbol.
(Symbol_table::gc_mark_symbol): Call target gc_mark_symbol. Remove
unnecessary cast.
* powerpc.cc (Powerpc_relobj::get_opd_ent): Rearrange parameters
to cater for when we don't need code offset. Update use.
(Powerpc_relobj::access_from_map_, opd_valid_): New vars.
(Powerpc_relobj::access_from_map, add_reference, opd_valid,
set_opd_valid): New functions.
(Target_powerpc::do_gc_add_reference): New function.
(Target_powerpc::gc_process_relocs): Call gc()->add_reference on
stashed refs.
(Target_powerpc::do_gc_mark_symbol): New function.
(Powerpc_relobj::toc_base_offset): New stub function.
(Target_powerpc): Add tp_offset, dtp_offset. Rename
got_mod_index_offset to tlsld_got_offset. Update all refs.
(Target_powerpc::Relocate::enum skip_tls): New.
(Target_powerpc::call_tls_get_addr_): New var.
(Target_powerpc::is_branch_reloc): Move to file scope.
(Target_powerpc::relocate_tls, optimize_tls_reloc): Delete.
(Target_powerpc::optimize_tls_gd, optimize_tls_ld, optimize_tls_ie):
New functions.
(Target_powerpc::enum Got_type): Delete old values, add new ones.
(powerpc_info): Correct common_pagesize for ppc64.
(at_tls_transform, needs_dynamic_reloc, use_plt_offset): New functions.
(Powerpc_relocate_functions): Add overflow check enums and functions.
Add non-shift version of rela, rela_ua. Delete all rel public
functions. Delete addr16_lo. Add addr64, addr64_u, addr32,
addr32_u, addr24, addr16_u, addr16_hi2, addr16_ha2, addr16_hi3,
addr16_ha3, addr14 functions.
(Output_data_got_powerpc::add_constant_pair): New function.
(Output_data_got_powerpc::got_base_offset): Likewise.
(Output_data_got_powerpc::do_write): Correct 64-bit got header.
(instruction constants): Sort, add some more.
(Output_data_glink::do_write): Add and use Address typedef. Use
object->toc_base_offset() stub for 64-bit.
(Target_powerpc::tlsld_got_offset): Use add_constant_pair.
(Target_powerpc::Scan::get_reference_flags): Handle more relocs.
(Target_powerpc::Scan::local, global): Emit relative dynamic reloc
for R_PPC64_TOC. Handle more relocs. Generate got entries for TLS.
Always treat .opd relocs as against locally defined symbol.
Correct condition for RELATIVE relocs.
(Target_powerpc::do_finalize_sections): Test for NULL sections.
(Target_powerpc::Relocate::relocate): Use plt call stub as value
for 32-bit syms with a plt entry. Correct ppc64 toc base
calculations. Handle TLS relocs, and more. Add overflow
checking and adjust for Powerpc_relocate_functions changes.
(Target_powerpc::relocate_for_relocatable): Handle zero r_sym.
Reinstate --emit-relocs code with FIXME.
(Powerpc_relobj): Rename got2_section_ to special_.
Add opd_ent_shndx_ and opd_ent_off_ vectors.
(Powerpc_relobj::opd_shndx, init_opd, get_opd_ent, set_opd_ent,
scan_opd_relocs, do_read_relocs, opd_ent_ndx): New functions.
(Target_powerpc): Add Address typedef and invalid_address. Use
throughout.
(Target_powerpc::is_branch_reloc): New function.
(Powerpc_relocate_functions): Add Address typedef, use throughout.
(Powerpc_relocate_functions:rela, rela_ua): Correct type used
for dst_mask, value and addend.
(Powerpc_relobj::do_find_special_sections): Find .opd for 64-bit.
(ld_2_1, cror_15_15_15, cror_31_31_31): New insn constants.
(Output_data_glink::do_write): Correct toc base. Don't try to use
uint16_t for 24-bit offset. Use get_output_section_offset and
check return.
(Target_powerpc::Scan::local): Handle more relocs.
(Target_powerpc::do_finalize_sections): Set up DT_PPC64_GLINK.
(Target_powerpc::Relocate::relocate): Correct toc base calculation.
Plug in toc restoring insn after plt calls. Translate branches
to function descriptor symbols to corresponding entry point.
(Target_powerpc::relocate_for_relocatable): Check return from
get_output_section_offset.
* symtab.h: Comment typo.
(Target::do_output_section_name): New function.
* layout.cc (Layout::choose_output_section): Call the above.
* powerpc.cc (Target_powerpc::do_output_section_name): New function.
* powerpc.h: Add more relocs.
(R_PPC_REL16*): Rename to R_POWERPC_REL16*.
gold/
* powerpc.cc: Update for renamed R_PPC_REL16 relocs.
(Output_data_got_powerpc::do_write): Don't rely on base class lookup
for replace_constant call.
(Output_data_plt_powerpc::do_print_to_mapfile): New function.
(Output_data_glink::do_print_to_mapfile): New function.
(Target_powerpc::Scan::local): Ignore R_PPC64_TOCSAVE.
(Target_powerpc::Relocate::relocate): Likewise.
(Powerpc_relobj::do_find_special_sections): Don't use set_got2_shndx.
(Output_data_glink::add_entry,find_entry): Remove shndx param.
(class Glink_sym_ent): Rename from struct Glink_sym_ent. Remove
all references to shndx_. Handle special case for R_PPC_PLTREL24
here.
(class Glink_sym_ent_hash): Rename from struct Glink_sym_ent_hash.
(Output_data_glink::do_write): Retrieve got2_shdnx from object.
(Target_powerpc::make_plt_entry): Don't special case R_PPC_PLTREL24
here.
(Target_powerpc::Scan::global): Nor on make_plt_entry call.
(Target_powerpc::Relocate::relocate): Nor on glink->find_entry call.
(Sized_relobj_file::find_special_sections): New function.
* object.cc (Sized_relobj_file::find_shdr): New function.
(Sized_relobj_file::find_eh_frame): Use find_shdr.
(Sized_relobj_file::find_special_sections): New function, split out..
(Sized_relobj_file::do_read_symbols): ..from here.
* output.h (Output_data_got::replace_constant): New function.
(Output_data_got::num_entries): New function.
(Output_data_got::last_got_offset,set_got_size): Use num_entries.
(Output_data_got::got_offset): Protected rather than private.
(Output_data_got::replace_got_entry): New function.
* output.cc (Output_data_got::replace_got_entry): New function.
* powerpc.cc (class Powerpc_relobj): New.
(class Powerpc_relocate_functions): Delete all psymval variants or
convert to value,addend type. Delete pcrela, pcrela_unaligned.
Implement _ha functions using corresponding _hi function.
(Powerpc_relobj::find_special_sections): New function.
(Target_powerpc::do_make_elf_object): New function.
(class Output_data_got_powerpc): New.
(class Output_data_glink): New.
(class Powerpc_scan_relocatable_reloc): New.
Many more changes througout file.
* configure: Regenerate.
gold/
* nacl.cc: New file.
* nacl.h: New file.
* Makefile.am (CCFILES, HFILES): Add them.
* Makefile.in: Regenerate.
* i386.cc (Output_data_plt_i386_nacl): New class.
(Output_data_plt_i386_nacl_exec): New class.
(Output_data_plt_i386_nacl_dyn): New class.
(Target_i386_nacl): New class.
(Target_selector_i386_nacl): New class.
(target_selector_i386): Use it instead of Target_selector_i386.
* x86_64.cc (Output_data_plt_x86_64_nacl): New class.
(Target_x86_64_nacl): New class.
(Target_selector_x86_64_nacl): New class.
(target_selector_x86_64, target_selector_x32): Use it instead of
Target_selector_x86_64.
* arm.cc (Output_data_plt_arm_nacl): New class.
(Target_arm_nacl): New class.
(Target_selector_arm_nacl): New class.
(target_selector_arm, target_selector_armbe): Use it instead of
Target_selector_arm.
* target-select.cc (select_target): Take new Input_file* and off_t
arguments, pass them on to recognize method of selector.
* object.cc (make_elf_sized_object): Update caller.
* parameters.cc (parameters_force_valid_target): Likewise.
* incremental.cc (make_sized_incremental_binary): Likewise.
* target-select.h: Update decl.
(Target_selector::recognize): Take new Input_file* argument,
pass it on to do_recognize.
(Target_selector::do_recognize): Take new Input_file* argument.
* freebsd.h (Target_selector_freebsd::do_recognize): Likewise.
* powerpc.cc (Target_selector_powerpc::do_recognize): Likewise.
* sparc.cc (Target_selector_sparc::do_recognize): Likewise.
* testsuite/testfile.cc (Target_selector::do_recognize): Likewise.
* target.h (Target::Target_info): New members isolate_execinstr
and rosegment_gap.
(Target::isolate_execinstr, Target::rosegment_gap): New methods.
* arm.cc (Target_arm::arm_info): Update initializer.
* i386.cc (Target_i386::i386_info): Likewise.
* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
* sparc.cc (Target_sparc::sparc_info): Likewise.
* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
* layout.cc (Layout::attach_allocated_section_to_segment):
Take new const Target* argument. If target->isolate_execinstr(), act
like --rosegment.
(Layout::find_first_load_seg): Take new const Target* argument;
if target->isolate_execinstr(), reject PF_X segments.
(Layout::relaxation_loop_body): Update caller.
(Layout::set_segment_offsets): If target->isolate_execinstr(),
reset file offset to zero when we hit LOAD_SEG, and then do a second
loop over the segments before LOAD_SEG to reassign offsets after
addresses have been determined. Handle target->rosegment_gap().
(Layout::attach_section_to_segment): Take new const Target* argument;
pass it to attach_allocated_section_to_segment.
(Layout::make_output_section): Update caller.
(Layout::attach_sections_to_segments): Take new const Target* argument;
pass it to attach_section_to_segment.
* gold.cc (queue_middle_tasks): Update caller.
* layout.h (Layout): Update method decls with new arguments.
* arm.cc (Target_arm::Target_arm): Take optional argument for the
Target_info pointer to use.
(Target_arm::do_make_data_plt): New virtual method.
(Target_arm::make_data_plt): New method that calls it.
(Target_arm::make_plt_entry): Use it.
(Output_data_plt_arm::Output_data_plt_arm): Take additional argument
for the section alignment.
(Output_data_plt_arm::do_first_plt_entry_offset): New abstract virtual
method.
(Output_data_plt_arm::first_plt_entry_offset): Call it.
(Output_data_plt_arm::do_get_plt_entry_size): New abstract virtual
method.
(Output_data_plt_arm::get_plt_entry_size): Call it.
(Output_data_plt_arm::do_fill_plt_entry): New abstract virtual method.
(Output_data_plt_arm::fill_plt_entry): New method that calls it.
(Output_data_plt_arm::do_fill_first_plt_entry): New abstract virtual
method.
(Output_data_plt_arm::fill_first_plt_entry): New method that calls it.
(Output_data_plt_arm::set_final_data_size): Use get_plt_entry_size
method instead of sizeof(plt_entry).
(Output_data_plt_arm::add_entry): Likewise.
Use first_plt_entry_offset method instead of sizeof(first_plt_entry).
(Target_arm::first_plt_entry_offset): Call method on this->plt_ rather
than static method.
(Target_arm::plt_entry_size): Likewise.
(Output_data_plt_arm::first_plt_entry, Output_data_plt_arm::plt_entry):
Move to ...
(Output_data_plt_arm_standard): ... here, new class.
(Output_data_plt_arm::do_write): Move guts of PLT filling to...
(Output_data_plt_arm_standard::do_fill_first_plt_entry): ... here ...
(Output_data_plt_arm_standard::do_fill_plt_entry): ... and here.
* x86_64.cc (Output_data_plt_x86_64::Output_data_plt_x86_64):
Take additional argument for the PLT entry size.
(Output_data_plt_x86_64::get_tlsdesc_plt_offset):
Use get_plt_entry_size method rather than plt_entry_size variable.
(Output_data_plt_x86_64::reserve_slot): Likewise.
(Output_data_plt_x86_64::do_adjust_output_section): Likewise.
(Output_data_plt_x86_64::add_entry): Likewise.
(Output_data_plt_x86_64::add_local_ifunc_entry): Likewise.
(Output_data_plt_x86_64::address_for_global): Likewise.
(Output_data_plt_x86_64::address_for_local): Likewise.
(Output_data_plt_x86_64::set_final_data_size): Likewise.
(Output_data_plt_x86_64::first_plt_entry_offset): Likewise.
Make method non-static.
(Output_data_plt_x86_64::do_get_plt_entry_size): New abstract virtual
method.
(Output_data_plt_x86_64::get_plt_entry_size): Just call that.
(Output_data_plt_x86_64::do_add_eh_frame): New abstract virtual method.
(Output_data_plt_x86_64::add_eh_frame): New method to call it.
(Output_data_plt_x86_64::do_fill_first_plt_entry): New abstract
virtual method.
(Output_data_plt_x86_64::fill_first_plt_entry): New method to call it.
(Output_data_plt_x86_64::do_fill_plt_entry): New abstract
virtual method.
(Output_data_plt_x86_64::fill_plt_entry): New method to call it.
(Output_data_plt_x86_64::do_fill_tlsdesc_entry): New abstract
virtual method.
(Output_data_plt_x86_64::fill_tlsdesc_entry): New method to call it.
(Output_data_plt_x86_64::plt_entry_size)
(Output_data_plt_x86_64::first_plt_entry)
(Output_data_plt_x86_64::plt_entry)
(Output_data_plt_x86_64::tlsdesc_plt_entry)
(Output_data_plt_x86_64::plt_eh_frame_fde_size)
(Output_data_plt_x86_64::plt_eh_frame_fde): Move to ...
(Output_data_plt_x86_64_standard): ... here, new class.
(Target_x86_64::Target_x86_64): Take optional argument for the
Target_info pointer to use.
(Target_x86_64::do_make_data_plt): New virtual method.
(Target_x86_64::make_data_plt): New method to call it.
(Target_x86_64::init_got_plt_for_update): Use that.
Call this->plt_->add_eh_frame method here.
(Output_data_plt_x86_64::init): Don't do add_eh_frame_for_plt here.
(Target_x86_64::first_plt_entry_offset): Call method on this->plt_
rather than static method.
(Target_x86_64::plt_entry_size): Likewise.
(Output_data_plt_x86_64::do_write): Use get_plt_entry_size method
rather than plt_entry_size variable. Move guts of PLT filling to...
(Output_data_plt_x86_64_standard::do_fill_first_plt_entry): ... here ...
(Output_data_plt_x86_64_standard::do_fill_plt_entry): ... and here ...
(Output_data_plt_x86_64_standard::do_fill_tlsdesc_entry): ... and here.
* i386.cc (Output_data_plt_i386::Output_data_plt_i386): Take
additional argument for the section alignment.
Don't do add_eh_frame_for_plt here.
(Output_data_plt_i386::first_plt_entry_offset): Make the method
non-static. Use get_plt_entry_size method rather than plt_entry_size
variable.
(Output_data_plt_i386::do_get_plt_entry_size): New abstract virtual
method.
(Output_data_plt_i386::get_plt_entry_size): Call it.
(Output_data_plt_i386::do_add_eh_frame): New abstract virtual method.
(Output_data_plt_i386::add_eh_frame): New method to call it.
(Output_data_plt_i386::do_fill_first_plt_entry): New abstract virtual
method.
(Output_data_plt_i386::fill_first_plt_entry): New method to call it.
(Output_data_plt_i386::do_fill_plt_entry): New abstract virtual
method.
(Output_data_plt_i386::fill_plt_entry): New method to call it.
(Output_data_plt_i386::set_final_data_size): Use get_plt_entry_size
method instead of plt_entry_size.
(Output_data_plt_i386::plt_entry_size)
(Output_data_plt_i386::plt_eh_frame_fde_size)
(Output_data_plt_i386::plt_eh_frame_fde): Move to ...
(Output_data_plt_i386_standard): ... here, new class.
(Output_data_plt_i386_exec): New class.
(Output_data_plt_i386::exec_first_plt_entry): Move to ...
(Output_data_plt_i386_exec::first_plt_entry): ... here.
(Output_data_plt_i386::exec_plt_entry): Move to ...
(Output_data_plt_i386_exec::plt_entry): ... here.
(Output_data_plt_i386_dyn): New class.
(Output_data_plt_i386::first_plt_entry): Move to ...
(Output_data_plt_i386_dyn::first_plt_entry): ... here.
(Output_data_plt_i386::dyn_plt_entry): Move to ...
(Output_data_plt_i386_dyn::plt_entry): ... here.
(Target_i386::Target_i386): Take optional argument for the Target_info
pointer to use.
(Target_i386::do_make_data_plt): New virtual method.
(Target_i386::make_data_plt): New method to call it.
(Target_i386::make_plt_section): Use that.
Call this->plt_->add_eh_frame method here.
(Output_data_plt_i386::add_entry): Use get_plt_entry_size method
rather than plt_entry_size variable.
(Output_data_plt_i386::add_local_ifunc_entry): Likewise.
(Output_data_plt_i386::address_for_local): Likewise.
(Output_data_plt_i386::do_write): Likewise.
Move guts of PLT filling to...
(Output_data_plt_i386_exec::do_fill_first_plt_entry): ... here ...
(Output_data_plt_i386_exec::do_fill_plt_entry): ... and here ...
(Output_data_plt_i386_dyn::do_fill_first_plt_entry): ... and here ...
(Output_data_plt_i386_dyn::do_fill_plt_entry): ... and here.
Change-Id: Id24b95600489835ff5e860a39c147203d4380c2b
(Relobj::local_plt_offset): New function.
(Relobj::local_has_got_offset): New function.
(Relobj::local_got_offset): New function.
(Relobj::set_local_got_offset): New function.
(Relobj::do_local_symbol_value): New pure virtual function.
(Relobj::do_local_plt_offset): Likewise.
(Relobj::do_local_has_got_offset): Likewise.
(Relobj::do_local_got_offset): Likewise.
(Relobj::do_set_local_got_offset): Likewise.
(Sized_relobj::do_local_has_got_offset): Rename from
local_has_got_offset.
(Sized_relobj::do_local_got_offset): Rename from local_got_offset.
(Sized_relobj::do_set_local_got_offset): Rename from
set_local_got_offset.
(Sized_relobj_file::do_local_plt_offset): Rename from
local_plt_offset.
(Sized_relobj_file::do_local_symbol_value): New function.
* object.cc (Sized_relobj_file::do_local_plt_offset): Rename from
local_plt_offset.
* output.cc (Output_data_got::Got_entry::write): Change object to
Relobj. Use local_symbol_value.
(Output_data_got::add_global_with_rel): Change rel_dyn to
Output_data_reloc_generic*. Use add_global_generic.
(Output_data_got::add_global_with_rela): Remove. Change all
callers to use add_global_with_rel.
(Output_data_got::add_global_pair_with_rel): Change rel_dyn to
Output_data_reloc_generic*. Use add_global_generic.
(Output_data_got::add_global_pair_with_rela): Remove. Change all
callers to use add_global_pair_with_rel.
(Output_data_got::add_local): Change object to Relobj*.
(Output_data_got::add_local_plt): Likewise.
(Output_data_got::add_local_with_rel): Change object to Relobj*,
change rel_dyn to Output_data_reloc_generic*. Use
add_local_generic.
(Output_data_got::add_local_with_rela): Remove. Change all
callers to use all_local_with_rel.
(Output_data_got::add_local_pair_with_rel): Change object to
Relobj*, change rel_dyn to Output_data_reloc_generic*. Use
add_output_section_generic.
(Output_data_got::add_local_pair_with_rela): Remove. Change all
callers to use add_local_pair_with_rel.
(Output_data_got::reserve_local): Change object to Relobj*.
* output.h: (class Output_data_reloc_generic): Add pure virtual
declarations for add_global_generic, add_local_generic,
add_output_section_generic.
(class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new
functions for Output_data_reloc_generic. Update declarations for
changes listed in output.cc.
(class Output_data_got): Change template parameter to got_size.
Don't define Rel_dyn or Rela_dyn. Update declarations per above.
* incremental.h (Sized_relobj_incr::do_local_symbol_value): New
function.
(Sized_relobj_incr::do_local_plt_offset): New function.
* copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call
add_global_generic.
* gold/output.cc (Output_reloc::Output_reloc): Add use_plt_offset flag.
(Output_reloc::symbol_value): Return PLT offset if flag is set.
* gold/output.h (class Output_reloc): Add use_plt_offset flag.
(Output_reloc::type_): Adjust size of bit field.
(Output_reloc::use_plt_offset_): New bit field.
(class Output_data_reloc): Adjust all calls to Output_reloc_type.
(Output_data_reloc::add_local_relative): (RELA only) Add use_plt_offset
flag. Adjust all callers.
* gold/x86_64.cc (Target_x86_64::Scan::local): Check for IFUNC when
creating RELATIVE relocations.
* target-select.cc (Target_selector::Target_selector): Add
emulation parameter. Change all callers.
(select_target_by_bfd_name): Rename from select_target_by_name.
Change all callers.
(select_target_by_emulation): New function.
(supported_emulation_names): New function.
* target-select.h (class Target_selector): Add emulation_ field.
Update declarations.
(Target_selector::recognize_by_bfd_name): Rename from
recognize_by_name. Change all callers.
(Target_selector::supported_bfd_names): Rename from
supported_names. Change all callers.
(Target_selector::recognize_by_emulation): New function.
(Target_selector::supported_emulations): New function.
(Target_selector::emulation): New function.
(Target_selector::do_recognize_by_bfd_name): Rename from
do_recognize_by_name. Change all callers.
(Target_selector::do_supported_bfd_names): Rename from
do_supported_names. Change all callers.
(Target_selector::do_recognize_by_emulation): New function.
(Target_selector::do_supported_emulations): New function.
(select_target_by_bfd_name): Change name in declaration.
(select_target_by_emulation): Declare.
(supported_emulation_names): Declare.
* parameters.cc (parameters_force_valid_target): Try to find
target based on emulation from -m option.
* options.h (class General_options): Change doc string for -m.
* options.cc (help): Print emulations.
(General_options::parse_V): Likewise.
* freebsd.h (Target_selector_freebsd::Target_selector_freebsd):
Add emulation parameter. Change all callers.
info; adjust display of GOT entries.
* incremental.cc (Sized_incremental_binary::setup_readers): Allocate
vector of input objects; remove file_status_.
(Sized_incremental_binary::do_reserve_layout): Remove file_status_.
(Sized_incremental_binary::do_process_got_plt): Adjust calls to
got_plt reader; call target hooks to reserve GOT entries.
(Output_section_incremental_inputs::set_final_data_size): Adjust size
of input file info header and GOT info entry.
(Output_section_incremental_inputs::write_info_blocks): Write dynamic
relocation info.
(Got_plt_view_info::got_descriptor): Remove.
(Got_plt_view_info::sym_index): New data member.
(Got_plt_view_info::input_index): New data member.
(Local_got_offset_visitor::visit): Write input file index.
(Global_got_offset_visitor::visit): Write 0 for input file index.
(Global_symbol_visitor_got_plt::operator()): Replace got_descriptor
with sym_index and input_index.
(Output_section_incremental_inputs::write_got_plt): Adjust size of
incremental info GOT entry; replace got_descriptor with input_index.
(Sized_relobj_incr::Sized_relobj_incr): Adjust initializers; record
map from input file index to object.
(Sized_relobj_incr::do_layout): Replace direct data member reference
with accessor function.
(Sized_relobj_incr::do_for_all_local_got_entries): Move to base class.
* incremental.h (Incremental_input_entry_reader::get_symbol_offset):
Adjust size of input file info header.
(Incremental_input_entry_reader::get_first_dyn_reloc): New function.
(Incremental_input_entry_reader::get_dyn_reloc_count): New function.
(Incremental_input_entry_reader::get_input_section): Adjust size of
input file info header.
(Incremental_got_plt_reader::Incremental_got_plt_reader): Adjust size
of incremental info GOT entry.
(Incremental_got_plt_reader::get_got_desc): Remove.
(Incremental_got_plt_reader::get_got_symndx): New function.
(Incremental_got_plt_reader::get_got_input_index): New function.
(Sized_incremental_binary::Sized_incremental_binary): Remove
file_status_; add input_objects_.
(Sized_incremental_binary::~Sized_incremental_binary): Remove.
(Sized_incremental_binary::set_file_is_unchanged): Remove.
(Sized_incremental_binary::file_is_unchanged): Remove.
(Sized_incremental_binary::set_input_object): New function.
(Sized_incremental_binary::input_object): New function.
(Sized_incremental_binary::file_status_): Remove.
(Sized_incremental_binary::input_objects_): New data member.
(Sized_relobj_incr): Rename Sized_incr_relobj to this; adjust all
references.
(Sized_relobj_incr::invalid_address): Move to base class.
(Sized_relobj_incr::is_output_section_offset_invalid): Move to base
class.
(Sized_relobj_incr::do_output_section_offset): Likewise.
(Sized_relobj_incr::do_for_all_local_got_entries): Likewise.
(Sized_relobj_incr::section_offsets_): Likewise.
* object.cc (Sized_relobj::do_for_all_local_got_entries): New
function.
(Sized_relobj_file::Sized_relobj_file): Remove local_got_offsets_.
(Sized_relobj_file::layout_section): Replace refs to section_offsets_
with accessor function.
(Sized_relobj_file::do_layout): Likewise.
(Sized_relobj_file::do_layout_deferred_sections): Likewise.
(Sized_relobj_file::do_for_all_local_got_entries): Move to base class.
(Sized_relobj_file::compute_final_local_value): Replace refs to
section_offsets_ with accessor function.
(Sized_relobj_file::do_finalize_local_symbols): Likewise.
* object.h (Relobj::Relobj): Initialize new data members.
(Relobj::add_dyn_reloc): New function.
(Relobj::first_dyn_reloc): New function.
(Relobj::dyn_reloc_count): New function.
(Relobj::first_dyn_reloc_): New data member.
(Relobj::dyn_reloc_count_): New data member.
(Sized_relobj): Rename Sized_relobj_base to this; adjust all
references.
(Sized_relobj::Address): New typedef.
(Sized_relobj::invalid_address): Move here from child class.
(Sized_relobj::Sized_relobj): Initialize new data members.
(Sized_relobj::sized_relobj): New function.
(Sized_relobj::is_output_section_offset_invalid): Move here from
child class.
(Sized_relobj::get_output_section_offset): Likewise.
(Sized_relobj::local_has_got_offset): Likewise.
(Sized_relobj::local_got_offset): Likewise.
(Sized_relobj::set_local_got_offset): Likewise.
(Sized_relobj::do_for_all_local_got_entries): Likewise.
(Sized_relobj::clear_got_offsets): New function.
(Sized_relobj::section_offsets): Move here from child class.
(Sized_relobj::do_output_section_offset): Likewise.
(Sized_relobj::do_set_section_offset): Likewise.
(Sized_relobj::Local_got_offsets): Likewise.
(Sized_relobj::local_got_offsets_): Likewise.
(Sized_relobj::section_offsets_): Likewise.
(Sized_relobj_file): Rename Sized_relobj to this; adjust all
references.
(Sized_relobj_file::is_output_section_offset_invalid): Move to base
class.
(Sized_relobj_file::sized_relobj): New function
(Sized_relobj_file::local_has_got_offset): Move to base class.
(Sized_relobj_file::local_got_offset): Likewise.
(Sized_relobj_file::set_local_got_offset): Likewise.
(Sized_relobj_file::get_output_section_offset): Likewise.
(Sized_relobj_file::do_for_all_local_got_entries): Likewise.
(Sized_relobj_file::do_output_section_offset): Likewise.
(Sized_relobj_file::do_set_section_offset): Likewise.
(Sized_relobj_file::Local_got_offsets): Likewise.
(Sized_relobj_file::local_got_offsets_): Likewise.
(Sized_relobj_file::section_offsets_): Likewise.
* output.cc (Output_reloc::Output_reloc): Adjust type of relobj
(all constructors).
(set_needs_dynsym_index): Convert relobj to derived class pointer.
(Output_reloc::get_symbol_index): Likewise.
(Output_reloc::local_section_offset): Likewise.
(Output_reloc::get_address): Likewise.
(Output_reloc::symbol_value): Likewise.
(Output_data_got::reserve_slot): Move to class definition.
(Output_data_got::reserve_local): New function.
(Output_data_got::reserve_slot_for_global): Remove.
(Output_data_got::reserve_global): New function.
* output.h (Output_reloc::Output_reloc): Adjust type of relobj
(all constructors, two instantiations).
(Output_reloc::get_relobj): New function (two instantiations).
(Output_reloc::u1_.relobj, Output_reloc::u2_.relobj): Adjust type.
(Output_data_reloc_base::add): Convert relobj to derived class pointer.
(Output_data_reloc::add_global): Adjust type of relobj.
(Output_data_reloc::add_global_relative): Likewise.
(Output_data_reloc::add_symbolless_global_addend): Likewise.
(Output_data_reloc::add_local): Likewise.
(Output_data_reloc::add_local_relative): Likewise.
(Output_data_reloc::add_symbolless_local_addend): Likewise.
(Output_data_reloc::add_local_section): Likewise.
(Output_data_reloc::add_output_section): Likewise.
(Output_data_reloc::add_absolute): Likewise.
(Output_data_reloc::add_target_specific): Likewise.
(Output_data_got::reserve_slot): Move definition here.
(Output_data_got::reserve_local): New function.
(Output_data_got::reserve_global): New function.
* reloc.cc (Sized_relobj_file::do_read_relocs): Replace refs to
section_offsets_ with accessor function.
(Sized_relobj_file::write_sections): Likewise.
(Sized_relobj_file::do_relocate_sections): Likewise.
* target.h (Sized_target::reserve_local_got_entry): New function.
(Sized_target::reserve_global_got_entry): New function.
* x86_64.cc (Target_x86_64::reserve_local_got_entry): New function.
(Target_x86_64::reserve_global_got_entry): New function.
(Target_x86_64::init_got_plt_for_update): Create rela_dyn section.
* symtab.h (Symbol::NON_PIC_REF): Remove.
(Symbol::RELATIVE_REF, Symbol::TLS_REF): New Reference_flags.
(Symbol::FUNCTION_CALL): Renumber. Reword comment.
(Symbol::needs_dynamic_reloc): Don't check NON_PIC_REF.
(Symbol::use_plt_offset): Take a flags argument and pass it
directly to needs_dynamic_reloc. Restrict check for undefined
weak symbols to function calls.
* arm.cc (Target_arm::Scan::get_reference_flags): New function.
(Target_arm::Scan::global): Use it.
(Target_arm::Scan::scan_reloc_for_stub): Likewise.
(Target_arm::Relocate::relocate): Likewise.
(Target_arm::Relocate::should_apply_static_reloc): Replace flags
parameter with an r_type parameter. Use get_reference_flags
to get the flags.
(Target_arm::Relocate::relocate): Update accordingly.
* i386.cc (Target_i386::Scan::get_reference_flags): New function.
(Target_i386::Scan::reloc_needs_plt_for_ifunc): Use it.
(Target_i386::Scan::global): Likewise.
(Target_i386::Relocate::relocate): Likewise.
(Target_i386::Relocate::should_apply_static_reloc): Replace flags
parameter with an r_type parameter. Use get_reference_flags
to get the flags.
(Target_i386::Relocate::relocate): Update accordingly.
* powerpc.cc (Target_powerpc::Scan::get_reference_flags): New function.
(Target_powerpc::Scan::global): Use it.
(Target_powerpc::Scan::scan_reloc_for_stub): Likewise.
(Target_powerpc::Relocate::relocate): Likewise.
* sparc.cc (Target_sparc::Scan::get_reference_flags): New function.
(Target_sparc::Scan::global): Use it.
(Target_sparc::Scan::scan_reloc_for_stub): Likewise.
(Target_sparc::Relocate::relocate): Likewise.
* x86_64.cc (Target_x86_64::Scan::get_reference_flags): New function.
(Target_x86_64::Scan::reloc_needs_plt_for_ifunc): Use it.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
* 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.
paramter to the call to gold::gc_process_relocs.
* i386.cc (Target_i386<big_endian>::gc_process_relocs): Add template
paramter to the call to gold::gc_process_relocs.
* x86_64.cc (Target_x86_64<big_endian>::gc_process_relocs): Add template
parameter to the call to gold::gc_process_relocs.
* powerpc.cc (Target_powerpc<big_endian>::gc_process_relocs): Add
template parameter to the call to gold::gc_process_relocs.
* sparc.cc (Target_sparc<big_endian>::gc_process_relocs): Add template
paramter to the call to gold::gc_process_relocs.
* gc.h (get_embedded_addend_size): New function.
(gc_process_relocs): Save the size of the reloc for use by ICF.
* icf.cc (get_section_contents): Get the addend from the text section
for SHT_REL relocation sections.
* icf.h (Icf::Reloc_addend_size_info): New typedef.
(Icf::Reloc_info): Add new member reloc_addend_size_info.
* int_encoding.h (read_from_pointer): New overloaded function.
* testsuite/Makefile.am (icf_sht_rel_addend_test): New test.
* testsuite/icf_sht_rel_addend_test.sh: New file.
* testsuite/icf_sht_rel_addend_test_1.cc: New file.
* testsuite/icf_sht_rel_addend_test_2.cc: New file.
* arm.cc (Scan::local_reloc_may_be_function_pointer): New function.
(Scan::global_reloc_may_be_function_pointer): New function.
* sparc.cc (Scan::local_reloc_may_be_function_pointer): New function.
(Scan::global_reloc_may_be_function_pointer): New function.
* powerpc.cc (Scan::local_reloc_may_be_function_pointer): New function.
(Scan::global_reloc_may_be_function_pointer): New function.
* i386.cc (Scan::local_reloc_may_be_function_pointer): New function.
(Scan::global_reloc_may_be_function_pointer): New function.
* x86_64.cc (Scan::local_reloc_may_be_function_pointer): New function.
(Scan::global_reloc_may_be_function_pointer): New function.
(Scan::possible_function_pointer_reloc): New function.
(Target_x86_64::can_check_for_function_pointers): New function.
* gc.h (gc_process_relocs): Scan relocation types to determine if
function pointers were taken for targets that support it.
* icf.cc (Icf::find_identical_sections): Include functions for
folding in safe ICF whose pointer is not taken.
* icf.h (Secn_fptr_taken_set): New typedef.
(fptr_section_id_): New member.
(section_has_function_pointers): New function.
(set_section_has_function_pointers): New function.
(check_section_for_function_pointers): New function.
* options.h: Fix comment for safe ICF option.
* target.h (can_check_for_function_pointers): New function.
* testsuite/Makefile.am: Add icf_safe_so_test test case.
Modify icf_safe_test for X86-64.
* testsuite/Makefile.in: Regenerate.
* testsuite/icf_safe_so_test.cc: New file.
* testsuite/icf_safe_so_test.sh: New file.
* testsuite/icf_safe_test.cc (kept_func_3): New function.
(main): Change to take pointer to function kept_func_3.
* testsuite/icf_safe_test.sh (arch_specific_safe_fold): Check if safe
folding is done correctly for X86-64.
that takes two Output_data objects.
(Output_data_dynamic::Dynamic_entry): Create storage for secondary
entry param. Handle it in initializers.
* output.cc (Output_data_dynamic::Dynamic_entry::write): For
DYNAMIC_SECTION_SIZE, add in second object size if non-NULL.
* layout.h (Layout::add_target_dynamic_tags): Add dynrel_includes_plt
arg.
* layout.cc (Layout::add_target_dynamic_tags): If dynrel_includes_plt,
and .rela.plt exists, set DT_REL{,A}SZ to sum of .rela.dyn and .rela.plt
* arm.cc (Target_arm::do_finalize_sections): Update to pass false
for dynrel_includes_plt.
* i386.cc (Target_i386::do_finalize_sections): Likewise.
* x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
* sparc.cc (Target_sparc::make_plt_entry): Force .rela.dyn to be output
before .rela.plt
(Target_sparc::do_finalize_sections): Update to pass true for
dynrel_includes_plt.
* powerpc.cc (Target_powerpc::make_plt_entry): Force .rela.dyn to be
output before .rela.plt
(Target_powerpc::do_finalize_sections): Update to pass true for
dynrel_includes_plt when 32-bit.
* arm.cc: Remove comment about missing .ARM.exidx section symbols.
(Target_arm::do_finalize_sections): Add parameter for symbol table
pointer. Add __exidx_start and __exidx_end symbols as appropriate.
* i386.cc (Target_i386::do_finalize_sections): Add an additional
parameter for symbol table pointer.
* layout.cc (Layout::finalize): Call Target::finalize_sections with
an additional parameter for a pointer to symbol table.
* powerpc.cc (Target_powerpc::do_finalize_sections): Add an additional
parameter for a symbol table pointer.
* sparc.cc (Target_sparc::do_finalize_sections): Ditto.
* target.h (Target::finalize_sections, Target::do_finalize_sections):
Ditto.
* x86_64.cc (Target_x86_64::do_finalize_sections): Add an additional
parameter for a symbol table pointer.