* icf.h (is_section_foldable_candidate): Change type of parameter
to std::string.
* icf.cc (Icf::find_identical_sections): Change type of local variable
section_name to be std::string.
(is_function_ctor_or_dtor): Change type of parameter to std::string.
* copy-relocs.cc (Copy_relocs::emit_copy_reloc): Hold a lock on the
object when reading from the file.
* gold.cc (queue_middle_tasks): Hold a lock on the object when doing
second layout pass.
* icf.cc (preprocess_for_unique_sections): Hold a lock on the object
when reading section contents.
(get_section_contents): Likewise.
(icf::find_identical_sections): Likewise.
* mapfile.cc (Mapfile::print_discarded_sections): Hold a lock on the
object when reading from the file.
* plugin.cc (Plugin_manager::layout_deferred_objects): Hold a lock on
the object when doing deferred section layout.
* target.h (Target::can_icf_inline_merge_sections): New virtual
function.
* x86_64.cc (Target__x86_64::can_icf_inline_merge_sections): New
virtual function.
* i386.cc (Target_i386::can_icf_inline_merge_sections): New
virtual function.
* icf.cc (get_section_contents): Inline merge sections only when
target allows it.
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.
* gc.h (gc_process_relocs): Pass information on relocs pointing to
sections that are not ordinary to icf.
* icf.cc (get_section_contents): Handle relocation pointing to section
with no object or shndx information.
* testsuite/Makefile.am: Remove icf_virtual_function_folding_test.sh
* testsuite/Makefile.in: Regenerate.
* testsuite/icf_virtual_function_folding_test.cc: Remove printf.
* testsuite/icf_virtual_function_folding_test.sh: Delete file.
* 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.
* gold-threads.h (Once::~Once): Explicitly define virtual destructor.
* icf.cc (get_section_contents): Cast snprintf arguments to long long
types to avoid warnings due to different uint64_t implementations
on different hosts.
* gc.h (gc_process_relocs): Change vectors to point to the new list.
Add reloc offset information.
* icf.cc (get_section_contents): Change iterators to point to the new
vectors. Add reloc offset information to the contents.
* icf.h (Icf::Sections_reachable_info): New typedef.
(Icf::Sections_reachable_list): New typedef.
(Icf::Offset_info): New typedef.
(Icf::Reloc_info): New struct typedef.
(Icf::Reloc_info_list): New typedef.
(Icf::symbol_reloc_list): Delete method.
(Icf::addend_reloc_list): Delete method.
(Icf::section_reloc_list): Delete method.
(Icf::reloc_info_list): New method.
(Icf::reloc_info_list_): New member.
* 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.
check for .text or .gnu.linkonce.t sections.
* icf.cc (Icf::find_identical_sections): Ditto.
Change the detection for mangled function name within the section
name.
* icf.h (is_section_foldable_candidate): New function.
function.
* gold.cc (queue_initial_tasks): Likewise.
(queue_middle_tasks): Likewise.
* object.cc (do_layout): Likewise.
* symtab.cc (is_section_folded): Likewise.
* main.cc (main): Likewise.
* reloc.cc (Read_relocs::run): Likewise.
(Sized_relobj::do_scan_relocs): Likewise.
* icf.cc (is_function_ctor_or_dtor): New function.
(Icf::find_identical_sections): Check if function is ctor or dtor when
safe icf is chosen.
* options.h (General_options::icf): Change option to be an enum.
(Icf_status): New enum.
(icf_enabled): New method.
(icf_safe_folding): New method.
(set_icf_status): New method.
(icf_status_): New variable.
* (options.cc) (General_options::finalize): Set icf_status_.
* testsuite/Makefile.am: Add commands to build icf_safe_test. Modify
icf_test and icf_keep_unique_test to use the --icf enum flag.
* testsuite/icf_safe_test.sh: New file.
* testsuite/icf_safe_test.cc: New file.
* icf.cc (Icf::find_identical_sections): Unfold symbols that have
been maked as --keep-unique.
(Icf::unfold_section): New function.
* icf.h (Icf::unfold_section): New function.
* options.h (General_options::keep_unique): New option.
* testsuite/Makefile.am: Add commands to build icf_keep_unique_test.
* testsuite/Makefile.in: Regenerate.
* testsuite/icf_keep_unique_test.sh: New file.
* testsuite/icf_keep_unique_test.cc: New file.