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.
* target-reloc.h (issue_undefined_symbol_error): New inline
function, broken out of relocate_section.
(relocate_section): Call issue_undefined_symbol_error.
* i386.cc (Target_i386::Relocate::relocate_tls): Don't crash if
there is no TLS segment if we are about to issue an undefined
symbol error.
* x86_64.cc (Target_x86_64::relocate_tls): Likewise.
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.
global symbol map.
(Sized_incremental_binary::do_apply_incremental_relocs): New function.
(Sized_incr_relobj::do_add_symbols): Add symbols to global symbol map.
(Sized_incr_relobj::do_relocate): Remap section indices in incremental
relocations.
(Sized_incr_dynobj::do_add_symbols): Add symbols to global symbol map.
(Sized_incr_dynobj::do_for_all_global_symbols): Remove FIXME.
(Sized_incr_dynobj::do_for_all_local_got_entries): Likewise.
* incremental.h
(Incremental_inputs_reader::global_symbol_reader_at_offset): New
function.
(Incremental_binary::apply_incremental_relocs): New function.
(Incremental_binary::do_apply_incremental_relocs): New function.
(Sized_incremental_binary::Sized_incremental_binary): Initialize new
data member.
(Sized_incremental_binary::add_global_symbol): New function.
(Sized_incremental_binary::global_symbol): New function.
(Sized_incremental_binary::do_apply_incremental_relocs): New function.
(Sized_incremental_binary::symbol_map_): New data member.
* layout.cc (Layout_task_runner::run): Apply incremental relocations.
* target.h (Sized_target::apply_relocation): New function.
* target-reloc.h (apply_relocation): New function.
* x86_64.cc (Target_x86_64::apply_relocation): New function.
* i386.cc (class Output_data_plt_i386): Update declarations.
Define Global_ifunc and Local_ifunc types. Add global_ifuncs_ and
local_ifuncs_ fields.
(Target_i386::do_plt_section_for_global): New function.
(Target_i386::do_plt_section_for_local): New function.
(Output_data_plt_i386::Output_data_plt_i386): Add symtab
parameter; change all callers. Initialize global_ifuncs_ and
local_ifuncs_. If doing a static link define __rel_iplt_start and
__rel_iplt_end.
(Output_data_plt_i386::add_entry): Handle IFUNC symbols.
(Output_data_plt_i386::add_local_ifunc_entry): New function.
(Output_data_plt_i386::do_write): Fix GOT entries for IFUNC
symbols.
(Target_i386::make_plt_section): New function, broken out of
make_plt_entry. Set sh_info field of .rel.plt to point to .plt.
(Target_i386::make_plt_entry): Call make_plt_section.
(Target_i386::make_local_ifunc_plt_entry): New function.
(Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function.
(Target_i386::Scan::local): Handle IFUNC symbols. Add
R_386_IRELATIVE to switch.
(Target_i386::Scan::global): Likewise.
(Target_i386::Relocate::relocate): Likewise.
(Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to
switch.
* x86_64.cc (class Output_data_plt_x86_64): Update declarations.
(Target_x86_64::do_plt_section_for_global): New function.
(Target_x86_64::do_plt_section_for_local): New function.
(Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab
parameter; change all callers. If doing a static link define
__rela_iplt_start and __rela_iplt_end.
(Output_data_plt_x86_64::add_entry): Handle IFUNC symbols.
(Output_data_plt_x86_64::add_local_ifunc_entry): New function.
(Target_x86_64::make_plt_section): Set sh_info field of .rel.plt
to point to .plt.
(Target_x86_64::make_local_ifunc_plt_entry): New function.
(Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to
switch.
(Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function.
(Target_x86_64::Scan::local): Handle IFUNC symbols. Add
R_X86_64_IRELATIVE to switch.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
(Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to
switch.
* target.h (class Target): Add plt_section_for_global and
plt_section_for_local functions. Add do_plt_section_for_global
and do_plt_section_for_local virtual functions.
* symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol. Add
clarifying comments.
(Symbol::use_plt_offset): Handle IFUNC symbol.
* object.cc (Sized_relobj::Sized_relobj): Initialize
local_plt_offsets_.
(Sized_relobj::local_has_plt_offset): New function.
(Sized_relobj::local_plt_offset): New function.
(Sized_relobj::set_local_plt_offset): New function.
(Sized_relobj::do_count): Handle IFUNC symbol.
* object.h (class Symbol_value): Add is_ifunc_symbol_ field. Take
a bit away from input_shndx_ field. Add set_is_func_symbol and
is_ifunc_symbol functions.
(class Sized_relobj): Update declarations. Remove Tls_got_entry
and Local_tls_got_offsets. Define Local_plt_offsets. Add
local_plt_offsets_ field.
(Sized_relobj::clear_local_symbols): Clear local_plt_offsets_.
* output.h (class Output_section_data): Add non-const
output_section function.
(class Output_data_got): Update declarations.
(class Output_data_got::Got_entry): Add use_plt_offset_ field.
Add use_plt_offset parameter to global and local constructors.
Change all callers. Change local_sym_index_ field to 31 bits.
Change GSYM_CODE and CONSTANT_CODE accordingly.
* output.cc (Output_data_reloc_base::do_adjust_output_section): If
doing a static link don't set sh_link field.
(Output_data_got::Got_entry::write): Use PLT offset if
appropriate.
(Output_data_got::add_global_plt): New function.
(Output_data_got::add_local_plt): New function.
* target-reloc.h (relocate_section): Handle IFUNC symbol.
* defstd.cc (in_section): Remove entries for __rel_iplt_start,
__rel_iplt_end, __rela_iplt_start, and __rela_iplt_end.
* configure.ac: Set IFUNC automake conditional for glibc >= 2.11.
* testsuite/Makefile.am: Add a bunch of IFUNC tests, all within
IFUNC conditional.
* testsuite/ifunc-sel.h: New file.
* testsuite/ifuncmain1.c: New file.
* testsuite/ifuncmain1vis.c: New file.
* testsuite/ifuncmod1.c: New file.
* testsuite/ifuncdep2.c: New file.
* testsuite/ifuncmain2.c: New file.
* testsuite/ifuncmain3.c: New file.
* testsuite/ifuncmod3.c: New file.
* testsuite/ifuncmain4.c: New file.
* testsuite/ifuncmain5.c: New file.
* testsuite/ifuncmod5.c: New file.
* testsuite/ifuncmain6pie.c: New file.
* testsuite/ifuncmod6.c: New file.
* testsuite/ifuncmain7.c: New file.
* configure, testsuite/Makefile.in: Rebuild.
(Sized_relobj::do_layout_deferred_sections): Do layout for deferred
reloc sections.
* object.h (Sized_relobj::deferred_layout_relocs_): New data member.
PR 11683
* symtab.h (Symbol::is_placeholder): New member function.
* target-reloc.h (relocate_section): Check for placeholder symbols.
* testsuite/Makefile.am (plugin_test_8): New test.
(plugin_test_9): New test.
* testsuite/Makefile.in: Regenerate.
* icf.cc (get_section_contents): Check for preemptible functions.
Ignore addend when appropriate.
* symtab.cc (should_add_dynsym_entry): Add new parameter. Check for
section folded.
(add_from_relobj): Check for section folded.
(set_dynsym_indexes): Fix call to should_add_dynsym_entry.
* symtab.h (should_add_dynsym_entry): Add new parameter.
* target-reloc.h (scan_relocs): Check for section folded.
* x86_64.cc (Target_x86_64::Scan::possible_function_pointer_reloc):
Check reloc types for function pointers in shared objects.
* testsuite/Makefile.am (icf_virtual_function_folding_test): New test
case.
(icf_preemptible_functions_test): New test case.
(icf_string_merge_test): New test case.
* testsuite.Makefile.in: Regenerate.
* testsuite/icf_safe_so_test.sh: Change to not fold foo_glob and
bar_glob. Refactor code.
* testsuite/icf_preemptible_functions_test.cc: New file.
* testsuite/icf_preemptible_functions_test.sh: New file.
* testsuite/icf_string_merge_test.cc: New file.
* testsuite/icf_string_merge_test.sh: New file.
* testsuite/icf_virtual_function_folding_test.cc: New file.
* testsuite/icf_virtual_function_folding_test.sh: New file.
for -1U before setting the local symbol index.
(scan_relocatable_relocs): If copying the relocation, record that
the local symbol is required.
* object.h (Symbol_value::is_output_symtab_index_set): New
function.
(Symbol_value::may_be_discarded_from_output_symtab): New
function.
(Symbol_value::has_output_symtab_entry): New function.
(Symbol_value::needs_output_symtab_entry): Remove.
(Symbol_value::output_symtab_index): Make sure the symbol index is
set.
(Symbol_value::set_output_symtab_index): Make sure the symbol
index is not set. Make sure the new index is valid.
(Symbol_value::set_must_have_output_symtab_entry): New function.
(Symbol_value::has_output_dynsym_entry): New function.
(Symbol_value::set_output_dynsym_index): Make sure the new index
is valid.
(Sized_relobj::set_must_have_output_symtab_entry): New function.
* object.cc (Sized_relobj::do_count_local_symbols): Only discard a
local symbol if permitted.
(Sized_relobj::do_finalize_local_symbols): Call
is_output_symtab_index_set rather than needs_output_symtab_entry.
(Sized_relobj::write_local_symbols): Call has_output_symtab_entry
rather than needs_output_symtab_entry. Call
has_output_dynsym_entry rather than needs_output_dynsym_entry.
* arm.cc (Arm_relobj::update_output_local_symbol_count): Call
is_output_symtab_index_set rather than needs_output_symtab_entry.
* testsuite/discard_locals_relocatable_test.c: New file.
* testsuite/discard_locals_test.sh: Test -r.
* testsuite/Makefile.am (check_DATA): Add
discard_locals_relocatable_test1.syms,
discard_local_relocatable_test2.syms.
(MOSTLYCLEANFILES): Likewise. Also add
discard_locals_relocatable_test1.lout and
discard_locals_relocatable_test2.out.
(discard_locals_relocatable_test1.syms): New target.
(discard_locals_relocatable_test.o): New target.
(discard_locals_relocatable_test1.out): New target.
(discard_locals_relocatable_test2.syms): New target.
(discard_locals_relocatable_test2.out): New target.
(various): Add missing ../ld-new dependencies.
* testsuite/Makefile.in: Rebuild.
* symtab.h (class Symbol): Remove fields is_target_special_ and
has_plt_offset_. Add field is_defined_in_discarded_section_.
(Symbol::is_defined_in_discarded_section): New function.
(Symbol::set_is_defined_in_discarded_section): New function.
(Symbol::has_plt_offset): Rewrite.
(Symbol::set_plt_offset): Verify that new offset is not -1U.
* symtab.cc (Symbol::init_fields): Initialize plt_offset_ to -1U.
Don't initialize is_target_special_ or has_plt_offset_.
Initialize is_defined_in_discarded_section_.
(Symbol_table::add_from_relobj): If appropriate, set
is_defined_in_discarded_section.
* resolve.cc (Symbol::override_base_with_special): Don't test
is_target_special_. Change has_plt_offset_ to has_plt_offset().
* target-reloc.h (relocate_section): Do special handling for
symbols defined in discarded sections for global symbols as well
as local symbols.
* gold.h (gold_undefined_symbol): Change to take only a Symbol
pointer and to report location as the file name associated with
the symbol.
(gold_undefined_symbol_at_location): New function to replace the
old gold_undefined_symbol functionality.
* target-reloc.h (relocate_section): Update to use
gold_undefined_symbol_at_location.
* symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
Call gold_undefined_symbol function rather than gold_error.
* errors.h (Errors::undefined_symbol): Take location as a
string, rather than calculating it from a relocation.
* errors.cc (Errors::fatal): Print "fatal error:" before the
formatted message.
(Errors::error, Errors::error_at_location): Print "error: "
before the formatted message.
(Errors::undefined_symbol): Take location as a string, rather
than calculating it from a relocation.
(gold_undefined_symbol_at_location): New function akin to
old gold_undefined_symbol, calculates location from relocation.
(gold_undefined_symbol): Change to take only a Symbol pointer
and to report location as the file name associated with the symbol.
* testsuite/debug_msg.sh: Update for changed error messages.
* testsuite/undef_symbol.sh: Likewise.
r_type == 0 for a local symbol with r_sym == 0.
(scan_relocatable_relocs): Pass r_sym to
local_non_section_strategy.
* reloc.cc (Emit_relocs_strategy::local_non_section_strategy): Add
r_sym parameter.
* object.cc (Sized_relobj::do_layout): Use constant invalid_address
instead of -1U.
(Sized_relobj::do_finalize_local_symbols): Likewise.
(Sized_relobj::map_to_kept_section): Likewise.
* object.h (Sized_relobj::invalid_address): New constant.
(Sized_relobj::do_output_section_offset): Check for invalid_address
and return -1ULL.
* output.cc (Output_reloc::local_section_offset): Use constant
invalid_address instead of -1U.
(Output_reloc::get_address): Likewise.
(Output_section::output_address): Change -1U to -1ULL.
* output.h (Output_reloc::invalid_address): New constant.
* reloc.cc (Sized_relobj::write_sections): Use constant
invalid_address instead of -1U.
(Sized_relobj::relocate_sections): Likewise.
* symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
values for merge sections.
* target-reloc.h (relocate_for_relocatable): Use constant
invalid_address instead of -1U.
* object.h (class Relobj): Change map_to_output_ to
output_sections_, and just keep a section pointer. Change all
uses. Move comdat group support to Sized_relobj.
(Relobj::is_section_specially_mapped): Remove.
(Relobj::output_section): Remove poff parameter. Change all
callers.
(Relobj::output_section_offset): New function.
(Relobj::set_section_offset): Rewrite.
(Relobj::map_to_output): Remove.
(Relobj::output_sections): New function.
(Relobj::do_output_section_offset): New pure virtual function.
(Relobj::do_set_section_offset): Likewise.
(class Sized_relobj): Add section_offsets_ field. Add comdat
group support from Relobj. Update declarations.
(Sized_relobj::get_output_section_offset): New function.
(Sized_relobj::do_output_section_offset): New function.
(Sized_relobj::do_set_section_offset): New function.
* object.cc (Relobj::output_section_address): Remove.
(Sized_relobj::Sized_relobj): Initialize new fields.
(Sized_relobj::include_section_group): Cast find_kept_object to
Sized_relobj.
(Sized_relobj::include_linkonce_section): Likewise.
(Sized_relobj::do_layout): Use separate arrays for output section
and output offset.
(Sized_relobj::do_count_local_symbols): Change map_to_output to
output_sections.
(Sized_relobj::do_finalize_local_symbols): Change map_to_output to
output_sections and section_offsets.
(Sized_relobj::write_local_symbols): Likewise.
(map_to_kept_section): Compute output address directly.
* reloc.cc (Sized_relobj::do_read_relocs): Change map_to_output to
output_sections and section_offsets.
(Sized_relobj::write_sections): Likewise.
(Sized_relobj::relocate_sections): Likewise.
* symtab.cc (sized_finalize_symbol): Use output_section_offset.
* output.h (class Output_reloc): Update declarations. Change
u2_.relobj to Sized_relobj*.
(class Output_data_reloc): Change add functions to use
Sized_relobj*.
* output.cc (Output_reloc::Output_reloc): Change relobj to
Sized_relobj*.
(Output_reloc::local_section_offset): Change return type to
Elf_Addr. Use get_output_section_offset.
(Output_reloc::get_address): Likewise.
(Output_section::is_input_address_mapped): Don't call
is_section_specially_mapped.
(Output_section::output_offset): Likewise.
(Output_section::output_address): Likewise.
(Output_section::starting_output_address): Likewise.
* copy-relocs.cc (Copy_relocs::copy_reloc): Change object
parameter to Sized_relobj*.
(Copy_relocs::need_copy_reloc): Likewise.
(Copy_relocs::save): Likewise.
* copy-relocs.h (class Copy_relocs): Update declarations.
(class Copy_relocs::Copy_reloc_entry): Change constructor to use
Sized_relobj*. Change relobj_ field to Sized_relobj*.
* target-reloc.h (relocate_for_relocatable): Change
offset_in_output_section type to Elf_Addr. Change code that uses
it as well.
* layout.cc (Layout::layout): Always set *off.
* mapfile.cc (Mapfile::print_input_section): Use
output_section_offset.
* i386.cc (Target_i386::copy_reloc): Change object parameter to
Sized_relobj*.
* powerpc.cc (Target_powerpc::copy_reloc): Likewise.
* sparc.cc (Target_sparc::copy_reloc): Likewise.
* x86_64.cc (Target_x86_64::copy_reloc): Likewise.
info section.
(Layout::add_comdat): Add new parameters. Change type
of signature parameter. Add object and shndx to signatures table.
(Layout::find_kept_object): New function.
* layout.h: Include <cstring>.
(Layout::is_debug_info_section): New function.
(Layout::add_comdat): Add new parameters.
(Layout::find_kept_object): New function.
(Layout::Kept_section): New struct.
(Layout::Signatures): Change type of map range.
* object.cc (Relobj::output_section_address): New function.
(Sized_relobj::include_section_group): Add new parameters. Change
calls to Layout::add_comdat. Change to build table of kept comdat
groups and table mapping discarded sections to kept sections.
(Sized_relobj::include_linkonce_section): Likewise. Add new parameter.
(Sized_relobj::do_layout): Change calls to include_section_group and
include_linkonce_section.
(Sized_relobj::do_finalize_local_symbols): Do not set local symbol
value to zero when section is discarded.
(Sized_relobj::map_to_kept_section): New function.
* object.h (Relobj::output_section_address): New function.
(Relobj::Comdat_group): New type.
(Relobj::find_comdat_group): New function.
(Relobj::Comdat_group_table): New type.
(Relobj::Kept_comdat_section): New type.
(Relobj::Kept_comdat_section_table): New type.
(Relobj::add_comdat_group): New function.
(Relobj::set_kept_comdat_section): New function.
(Relobj::get_kept_comdat_section): New function.
(Relobj::comdat_groups_): New field.
(Relobj::kept_comdat_sections_): New field.
(Symbol_value::input_value): Update comment.
(Sized_relobj::map_to_kept_section) New function.
(Sized_relobj::include_linkonce_section): Add new parameter.
* target-reloc.h (Comdat_behavior): New type.
(get_comdat_behavior): New function.
(relocate_section): Add code to map a discarded section to the
corresponding kept section when applying a relocation.