target to ask whether a reference to a symbol requires a stack
split.
* target.h (Target::is_call_to_non_split): New function.
(Target::do_is_call_to_non_split): Declare virtual function.
* target.cc: Include "symtab.h".
(Target::do_is_call_to_non_split): New function.
* i386.cc (Target_i386::do_is_call_to_non_split): New function.
(File_read::open[1]): Remove initial mapping of whole_file_view_.
(File_read::open[2]): Add whole_file_view_ to list of views.
(File_read::make_view): Remove test of whole_file_view_.
(File_read::find_or_make_view): Create whole_file_view_ if
necessary.
(File_read::clear_views): Replace bool parameter with enum;
adjust all callers. Don't delete views with permanent data;
do delete cached views and views from archives if
--no-keep-files-mapped is set. Set whole_file_view_ to NULL
if clearing the corresponding view.
* fileread.h (File_read::Clear_views_mode): New enum.
(File_read::View::is_permanent_view): New method.
(File_read::clear_views): Replace bool parameter
with enum; adjust all callers.
* options.h (General_options): Change keep_files_mapped option;
add map_whole_files.
* readsyms.cc (Add_symbols::run): Delete sd_ object before
releasing the file.
* reloc.cc (Scan_relocs::run): Delete rd_ object before releasing
the file.
Read_relocs task.
(queue_middle_tasks): Likewise, and also for Scan_relocs. Run
Allocate_commons_task first.
* reloc.cc (Read_relocs::run): Pass next_blocker_ down to next
task, rather than symtab_lock_.
(Gc_process_relocs::~Gc_process_relocs): New function.
(Gc_process_relocs::is_runnable): Check this_blocker_.
(Gc_process_relocs::locks): Use next_blocker_ rather than
blocker_.
(Scan_relocs::~Scan_relocs): New function.
(Scan_relocs::is_runnable): Check this_blocker_ rather than
symtab_lock_.
(Scan_relocs::locks): Drop symtab_lock_ and blocker_. Add
next_blocker_.
* reloc.h (class Read_relocs): Drop symtab_lock_ and blocker_
fields. Add this_blocker_ and next_blocker_ fields. Adjust
constructor accordingly.
(class Gc_process_relocs): Likewise.
(class Scan_relocs): Likewise.
* common.h (class Allocate_commons_task): Remove symtab_lock_
field, and corresponding constructor parameter.
* common.cc (Allocate_commons_tasK::is_runnable): Remove use of
symtab_lock_.
(Allocate_commons_task::locks): Likewise.
* arm.cc (Arm_output_section, Arm_relobj): Forward class declarations.
(Arm_input_section::as_arm_input_section): New method.
(Arm_output_section): New class definition.
(Arm_output_section::create_stub_group,
Arm_output_section::group_sections): New method definitions.
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.
* Makefile.am (CCFILES): Add gc.cc.
(HFILES): Add gc.h.
* Makefile.in: Regenerate.
* gold.cc (Gc_runner): New class.
(queue_initial_tasks): Call garbage collection related tasks
when corresponding options are invoked.
(queue_middle_gc_tasks): New function.
(queue_middle_tasks): Reorder tasks to allow relocs to be read and
processed early before laying out sections during garbage collection.
* gold.h (queue_middle_gc_tasks): New function.
(is_prefix_of): Move from "layout.cc".
* i386.cc (Target_i386::gc_process_relocs): New function.
* layout.cc (is_prefix_of): Remove. Move to "gold.h"
* main.cc (main): Create object of class "Garbage_collection".
* object.cc (Relobj::copy_symbols_data): New function.
(Relobj::is_section_name_included): New function.
(Sized_relobj::do_layout): Allow this function to be called twice
during garbage collection and defer layout of section during the
first call.
* object.h (Relobj::get_symbols_data): New function.
(Relobj::is_section_name_included): New function.
(Relobj::copy_symbols_data): New function.
(Relobj::set_symbols_data): New function.
(Relobj::get_relocs_data): New function.
(Relobj::set_relocs_data): New function.
(Relobj::is_output_section_offset_invalid): New pure virtual function.
(Relobj::gc_process_relocs): New function.
(Relobj::do_gc_process_relocs): New pure virtual function.
(Relobj::sd_): New data member.
(Sized_relobj::is_output_section_offset_invalid): New function.
(Sized_relobj::do_gc_process_relocs): New function.
* options.h (General_options::gc_sections): Modify to not be a no-op.
(General_options::print_gc_sections): New option.
* plugin.cc (Plugin_finish::run): Remove function call to
Plugin_manager::layout_deferred_objects. Move it to "gold.cc".
* powerpc.cc (Target_powerpc::gc_process_relocs): New function.
* reloc.cc (Read_relocs::run): Add task to process relocs and
determine unreferenced sections when doing garbage collection.
(Gc_process_relocs): New class.
(Sized_relobj::do_gc_process_relocs): New function.
(Sized_relobj::do_scan_relocs): Don't try to scan the relocs for
sections that are garbage collected.
* reloc.h (Gc_process_relocs): New class.
* sparc.cc (Target_sparc::gc_process_relocs): New function.
* symtab.cc (Symbol::should_add_dynsym_entry): Do not add entries for
symbols whose corresponding sections are garbage collected.
(Symbol_table::Symbol_table): Add new parameter for the garbage
collection object.
(Symbol_table::gc_mark_undef_symbols): New function.
(Symbol_table::gc_mark_symbol_for_shlib): New function.
(Symbol_table::gc_mark_dyn_syms): New function.
(Symbol_table::resolve): Do not treat symbols seen in dynamic objects
as garbage.
(Symbol_table::add_from_object): Likewise.
(Symbol_table::add_from_relobj): When building shared objects, do not
treat externally visible symbols as garbage.
(Symbol_table::sized_finalize_symbol): Do not check dynamic symbol
table information for static and relocatable links.
* symtab.h (Symbol_table::set_gc): New function.
(Symbol_table::gc): New function.
(Symbol_table::gc_mark_undef_symbols): New function.
(Symbol_table::gc_mark_symbol_for_shlib): New function.
(Symbol_table::gc_mark_dyn_syms): New function.
(Symbol_table::gc_): New data member.
* target.h (Sized_target::gc_process_relocs): New pure virtual
function.
* x86_64.cc (Target_x86_64::gc_process_relocs): New function.
* testsuite/testfile.cc (Target_test::gc_process_relocs): New function.
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.
* copy-relocs.h: New file.
* reloc.cc: Remove Copy_relocs code.
* reloc.h: Likewise.
* reloc-types.h (struct Reloc_types) [both versions]: Add
get_reloc_addend_noerror.
* output.h (class Output_data_reloc<elfcpp::SHT_REL>): Add
variants of add_global which take an addend which must be zero.
* i386.cc: Include "copy-relocs.h".
(class Target_i386): Change type of copy_relocs_ to variable,
update initializer.
(Target_i386::copy_reloc): Rewrite to pass to Copy_relocs class.
Change all callers.
(Target_i386::do_finalize_sections): Change handling of
copy_relocs_.
* sparc.cc: Include "copy-relocs.h".
(class Target_sparc): Change type of copy_relocs_ to variable,
update initializer.
(Target_sparc::copy_reloc): Rewrite to pass to Copy_relocs class.
Change all callers.
(Target_sparc::do_finalize_sections): Change handling of
copy_relocs_.
* x86_64.cc: Include "copy-relocs.h".
(class Target_x86_64): Change type of copy_relocs_ to variable,
update initializer.
(Target_x86_64::copy_reloc): Rewrite to pass to Copy_relocs
class. Change all callers.
(Target_x86_64::do_finalize_sections): Change handling of
copy_relocs_.
* Makefile.am (CCFILES): Add copy-relocs.cc.
(HFILES): Add copy-relocs.h.
parameters. Update for new key type to views_. Change all
callers.
(File_read::read): Adjust for byteshift in returned view.
(File_read::add_view): New function, broken out of
find_and_make_view.
(File_read::make_view): New function, broken out of
find_and_make_view.
(File_read::find_or_make_view): Add offset and aligned
parameters. Rewrite accordingly. Change all callers.
(File_read::get_view): Add offset and aligned parameters. Adjust
for byteshift in return value.
(File_read::get_lasting_view): Likewise.
* fileread.h (class File_read): Update declarations.
(class File_read::View): Add byteshift_ field. Add byteshift to
constructor. Add byteshift method.
* archive.h (Archive::clear_uncached_views): New function.
(Archive::get_view): Add aligned parameter. Change all callers.
* object.h (Object::get_view): Add aligned parameter. Change all
callers.
(Object::get_lasting_view): Likewise.
* fileread.cc (File_read::release): Don't call clear_views if
there are multiple objects.
* fileread.h (File_read::clear_uncached_views): New function.
* archive.cc (Add_archive_symbols::run): Call clear_uncached_views
on the archive.