* arm.cc (Arm_relobj): New class definition.
(Arm_relobj::scan_sections_for_stubs,
Arm_relobj::do_count_local_symbols, Arm_relobj::do_relocate_sections):
New method definitions.
(Plugin::cleanup_done_): New member.
(Plugin_manager::Plugin_manager): Remove cleanup_done_.
(Plugin_manager::cleanup_done_): Remove.
(Plugin_manager::add_input_file): Edit error message.
* plugin.cc (Plugin::cleanup): Test and set cleanup_done_.
(Plugin_manager::cleanup): Remove use of cleanup_done_.
data_ownership_ filed.
(File_read::~File_read): Dispose the new whole_file_view_.
(File_read::open): Mmap the whole file if needed.
(File_read::open): Use whole_file_view_ instead of contents_.
(File_read::find_view): Use whole_file_view_ if applicable.
(File_read::do_read): Use whole_file_view_ instead of contents_.
(File_read::make_view): Use whole_file_view_ instead of contents_,
update File_read::View::View call.
(File_read::find_or_make_view): Update File_read::View::View
call.
* fileread.h: (File_read::File_read): Initialize whole_file_view_,
remove contents_
(File_read::View::Data_ownership): New enum.
(File_read::View::View): Replace bool mapped_ with Data_ownership
argument.
(File_read::View::mapped_): Remove (replaced by data_ownership_).
(File_read::View::data_ownership_): New field.
(File_read::contents_): Remove (replaced by whole_file_view_).
(File_read::whole_file_view_): New field.
* options.h (class General_options): Add --keep-files-mapped.
* 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.
* 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.
* arm.cc (Arm_input_section): New class definition.
(Arm_input_section::init, Arm_input_section:do_write,
Arm_input_section::set_final_data_size,
Arm_input_section::do_reset_address_and_file_offset): New method
definitions.
* arm.cc (Stub_table, Arm_input_section): New forward class
declarations.
(Stub_table): New class defintion.
(Stub_table::add_reloc_stub, Stub_table::relocate_stubs
Stub_table::do_reset_address_and_file_offset, Stub_table::do_write):
New method definition.
* dynobj.cc (Versions::Versions): Initialize version_script_.
Only insert base version symbol definition for a shared object
if version script defines any version versions.
(Versions::define_base_version): New method definition.
(Versions::add_def): Check that base version is not needed.
(Versions::add_need): Define base version lazily.
* dynobj.h (Versions::define_base_version): New method declaration.
(Versions::needs_base_version_): New data member declaration.
* testsuite/Makefile.am (check_SCRIPTS): Add no_version_test.sh
(check_DATA): Add no_version_test.stdout.
(libno_version_test.so, no_version_test.o no_version_test.stdout):
New make rules.
* testsuite/Makefile.in: Regenerate.
* testsuite/no_version_test.c: New file.
* testsuite/no_version_test.sh: Ditto.
* expression.cc (class Segment_start_expression): New class definition.
(Segment_start_expression::value): New method definition.
(script_exp_function_segment_start): Return a new
Segment_start_expression.
* gold/script-c.h (script_saw_segment_start_expression): New function
prototype.
* script-sections.cc (Script_sections::Script_sections): Initialize
SAW_SEGMENT_START_EXPRESSION_ to false.
(Script_sections::set_section_addresses): Use -Ttext, -Tdata
and -Tbbs options to specify section addresses if given in
command line and no SEGMENT_START expression is seen in a script.
* script-sections.h (Script_sections::saw_segment_start_expression,
Script_sections::set_saw_segment_start_expression): New method
definition.
(Script_sections::saw_segment_start_expression_): New data member
declaration.
* script.cc (script_saw_segment_start_expression): New function.
* yyscript.y (SEGMENT_START): Call script_saw_segment_start_expression.
* testsuite/Makefile.am (check_SCRIPTS): Add script_test_6.sh,
script_test_7.sh and script_test_8.sh.
(check_DATA): Add script_test_6.stdout, script_test_7.stdout and
script_test_8.stdout.
(MOSTLYCLEANFILES): Add script_test_6, script_test_7 and script_test_8.
(script_test_6, script_test_6.stdout, script_test_7,
script_test_7.stdout, script_test_8, script_test_8.stdout): New rules.
* Makefile.in: Regenerate.
* testsuite/script_test_6.sh: New file.
* testsuite/script_test_6.t: Same.
* testsuite/script_test_7.sh: Same.
* testsuite/script_test_7.t: Same.
* testsuite/script_test_8.sh: Same.
to the segment aligment for -N or -n with no load segment.
* output.cc (Output_segment::add_output_section): Don't crash if
the first section is a TLS section.
(Output_segment::set_section_list_addresses): Print an error
message if the address moves backward in a linker script.
* script-sections.cc
(Output_section_element_input::set_section_addresses): Don't
increase *dot_value for a SHF_TLS/SHT_NOBITS section.
(Orphan_output_section::set_section_addresses): Likewise.
* layout.cc (Layout::finish_dynamic_section): Generate tags
DT_FINI_ARRAY, DT_FINI_ARRAYSZ, DT_INIT_ARRAY, DT_INIT_ARRAYSZ,
DT_PREINIT_ARRAY, DT_PREINIT_ARRAYSZ as needed. If -Bsymbolic is
used, add DT_SYMBOLIC and set DF_SYMBOLIC in DT_FLAGS.
* options.h (class General_options): Add -pie and
--pic-executable.
(General_options::output_is_position_independent): Test -pie.
(General_options::output_is_executable): Return true if not shared
and not relocatable.
(General_options::output_is_pie): Remove.
* options.cc (General_options::finalize): Reject incompatible uses
of -pie.
* gold.cc (queue_middle_tasks): A -pie link is not static.
* symtab.h (Symbol::needs_plt_entry): Return false if -pie.
* symtab.cc (Symbol::final_value_is_known): Return false if
output_is_position_independent.
* layout.cc (Layout::set_segment_offsets): Start at address 0 if
output_is_position_independent.
* output.cc (Output_file_header::do_sized_write): Use ET_DYN if
output_is_position_independent.
* i386.cc (Output_data_plt_i386::do_write): Use the PIC PLT if
output_is_position_independent.
* testsuite/Makefile.am (check_PROGRAMS): Add basic_pie_test and
two_file_pie_test.
(basic_pie_test.o, basic_pie_test): New targets.
(two_file_test_1_pie.o, two_file_test_1b_pie.o): New targets.
(two_file_test_2_pie.o, two_file_test_main_pie.o): New targets.
(two_file_pie_test): New target.
* testsuite/Makefile.in: Rebuild.
* README: Remove note saying that -pie is not supported.
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.
* fileread.cc (readv): Define if not HAVE_READV.
* fileread.h (File_read:: max_readv_entries): Set to 1 if readv
does not exist.
* config.in: Regenerate.
* configure: Regenerate.
* layout.cc (Layout::make_output_section): Call target hook to make
ordinary output section.
(Layout::finalize): Adjust parameter list of call the
Target::may_relax().
* layout.h (class Layout::section_list): New method.
* merge.h (Output_merge_base::entsize): Change visibility to public.
(Output_merge_base::is_string, Output_merge_base::do_is_string):
New methods.
(Output_merge_string::do_is_string): New method.
* object.cc (Sized_relobj::do_setup): renamed from
Sized_relobj::set_up.
* object.h (Sized_relobj::adjust_shndx,
Sized_relobj::initializ_input_to_output_maps,
Sized_relobj::free_input_to_output_maps): Change visibilities to
protected.
(Sized_relobj::setup): Virtualize.
(Sized_relobj::do_setup): New method declaration.
(Sized_relobj::invalidate_section_offset,
Sized_relobj::do_invalidate_section_offset): New method decfinitions.
(Sized_relobj::elf_file, Sized_relobj::local_values): New methods.
* options.cc (parse_int): New function.
* options.h (parse_int): New declaration.
(DEFINE_int): New macro.
(stub_group_size): New option.
* output.cc (Output_section::Output_section): Initialize memebers
merge_section_map_, merge_section_by_properties_map_,
relaxed_input_section_map_, is_relaxed_input_section_map_valid_.
(Output_section::add_input_section): Handled deferred code-fill
generation and remove an old comment.
(Output_section::add_relaxed_input_section): New method definition.
(Output_section::add_merge_input_section): Use merge section by
properties map to speed to search. Update merge section maps
as appropriate.
(Output_section::build_relaxation_map): New method definition.
(Output_section::convert_input_sections_in_list_to_relaxed_sections):
Same.
(Output_section::relax_input_section): Renamed to
Output_section::convert_input_sections_to_relaxed_sections and change
interface to take a vector of pointers to relaxed sections.
(Output_section::find_merge_section,
Output_section::find_relaxed_input_section): New method definitions.
(Output_section::is_input_address_mapped,
Output_section::output_offset, Output_section::output_address):
Use output section data maps to speed up searching.
(Output_section::find_starting_output_address): Add comments.
(Output_section::do_write,
Output_section::write_to_postprocessing_buffer): Do code-fill
generation as appropriate.
(Output_section::get_input_sections): Invalidate relaxed input section
map.
(Output_section::restore_states): Adjust type of checkpoint .
Invalidate relaxed input section map.
* output.h (Output_merge_base): New class declaration.
(Input_section_specifier): New class defintion.
(class Output_relaxed_input_section) Change base class to
Output_section_data_build.
(Output_relaxed_input_section::Output_relaxed_input_section): Adjust
base class initializer.
(Output_section::add_relaxed_input_section): New method declaration.
(Output_section::Input_section): Change visibility to protected.
(Output_section::Input_section::relobj,
Output_section::Input_section::shndx): Handle relaxed input sections.
Output_section::input_sections) Change visibility to protected. Also
define overload to return a non-const pointer.
(Output_section::Merge_section_properties): New class defintion.
(Output_section::Merge_section_by_properties_map,
Output_section::Output_section_data_by_input_section_map,
Output_section::Relaxation_map): New types.
(Output_section::relax_input_section): Rename method to
Output_section::convert_input_sections_to_relaxed_sections and change
interface to take a vector of relaxed section pointers.
(Output_section::find_merge_section,
Output_section::find_relaxed_input_section,
Output_section::build_relaxation_map,
Output_section::convert_input_sections_in_list_to_relaxed_sections):
New method declarations.
(Output_section::merge_section_map_
Output_section::merge_section_by_properties_map_,
Output_section::relaxed_input_section_map_,
Output_section::is_relaxed_input_section_map_valid_,
Output_section::generate_code_fills_at_write_): New data members.
* script-sections.cc
(Output_section_element_input::set_section_addresses): Call
current_data_size and addralign methods of relaxed input sections.
(Orphan_output_section::set_section_addresses): Call current_data_size
and addralign methods of relaxed input sections.
* symtab.cc (Symbol_table::compute_final_value): Extract template
from the body of Symbol_table::sized_finalize_symbol.
(Symbol_table::sized_finalized_symbol): Call
Symbol_table::compute_final_value.
* symtab.h (Symbol_table::Compute_final_value_status): New enum type.
(Symbol_table::compute_final_value): New templated method declaration.
* target.cc (Target::do_make_output_section): New method defintion.
* target.h (Target::make_output_section): New method declaration.
(Target::relax): Add more parameters for input objects, symbol table
and layout. Adjust call to do_relax.
(Target::do_make_output_section): New method declaration.
(Target::do_relax): Add parameters for input objects, symbol table
and layout.
Change read_shndx type to unsigned int.
(Sized_dwarf_line_info::read_lines): Change shndx type to unsigned
int.
(Sized_dwarf_line_info::read_line_mappings): Likewise.
* dwarf_reader.h (Sized_dwarf_line_info::Sized_dwarf_line_info):
Change read_shndx type to unsigned int.
(Sized_dwarf_line_info::read_lines): Change shndx type to unsigned
int.
(Sized_dwarf_line_info::read_line_mappings): Likewise.
* layout.cc (Layout::create_symtab_sections): Cast the result of
local_symcount * symsize to off_t in the gold_assert.
* elf_file.h: (class Elf_strtab): New class.
gold/:
* gold.cc: (queue_initial_tasks): Pass incremental_inputs to
Incremental_checker.
* incremental.cc: (INCREMENTAL_LINK_VERSION): Change type to
unsigned int.
(class Incremental_inputs_header): New class.
(Incremental_inputs_header_writer): Edit comment.
(Incremental_inputs_entry): New class.
(Incremental_inputs_entry_writer): Edit comment.
(Sized_incremental_binary::do_find_incremental_inputs_section):
Add *strtab_shndx parameter, fill it.
(Sized_incremental_binary::do_check_inputs): New method.
(Incremental_checker::can_incrementally_link_output_file): Use
Sized_incremental_binary::check_inputs.
(Incremental_inputs::report_command_line): Save command line in
command_line_.
* incremental.h:
(Incremental_binary::find_incremental_inputs_section): New
method.
(Incremental_binary::do_find_incremental_inputs_section): Add
strtab_shndx parameter.
(Incremental_binary::do_check_inputs): New pure virtual method.
(Sized_incremental_binary::do_check_inputs): Declare.
(Incremental_checker::Incremental_checker): Add incremental_inputs
parameter, use it to initialize incremental_inputs_.
(Incremental_checker::incremental_inputs_): New field.
(Incremental_checker::command_line): New method.
(Incremental_checker::inputs): New method.
(Incremental_checker::command_line_): New field.
* elfcpp_file.h: Fix header guard. Include <cstdio>.
(class Elf_recognizer): New class, code from gold/object.cc.
(Elf_file::find_section_by_type): New method.
gold/:
* incremental.cc: Include <cstdarg> and "target-select.h".
(vexplain_no_incremental): New function.
(explain_no_incremental): New function.
(Incremental_binary::error): New method.
(Sized_incremental_binary::do_find_incremental_inputs_section): New
method.
(make_sized_incremental_binary): New function.
(open_incremental_binary): New function.
(can_incrementally_link_file): Add checks if output is ELF and has
inputs section.
* incremental.h: Include "elfcpp_file.h" and "output.h".
(Incremental_binary): New class.
(Sized_incremental_binary): New class.
(open_incremental_binary): Declare.
* object.cc (is_elf_object): Use
elfcpp::Elf_recognizer::is_elf_file.
(make_elf_object): Use elfcpp::Elf_recognizer::is_valid_header.
* output.h (Output_file::filesize): New method.
New function.
(Arm_relocate_functions::insert_val_arm_movw_movt): New function.
(Arm_relocate_functions::extract_thumb_movw_movt_addend): New
function.
(Arm_relocate_functions::insert_val_thumb_movw_movt): New
function.
(Arm_relocate_functions::movw_abs_nc): New function.
(Arm_relocate_functions::movt_abs): New function.
(Arm_relocate_functions::thm_movw_abs_nc): New function.
(Arm_relocate_functions::thm_movt_abs): New function.
(Scan::local): Handle R_ARM_MOVW_ABS_NC, R_ARM_MOVT_ABS,
R_ARM_THM_MOVW_ABS_NC, R_ARM_THM_MOVT_ABS.
(Scan::global): Likewise.
(Relocate::relocate): Likewise.
(Relocatable_size_for_reloc::get_size_for_reloc): Likewise.
(Target_i386::Relocate::relocate_tls): Call fix_up_ldo before
changing local_dynamic_type_ from LOCAL_DYNAMIC_NONE. When
handling R_386_TLS_LDO_32, if local_dynamic_type_ is NONE, push
the address on ldo_addrs_.
(Target_i386::Relocate::fix_up_ldo): New function.
* arm.cc (Target_arm::may_need_copy_reloc): Check for THUMB function
symbol and call Symbol::may_need_copy_reloc to determine if
a copy reloc is needed.
* copy-relocs.cc (Copy_relocs::need_copy_reloc): Return false if -z
nocopyreloc is given in command line.
(Copy_relocs::emit_copy_reloc): Assert that -z nocopyreloc is not
given in command line.
* i386.cc (Target_i386::may_need_copy_reloc): Remove.
(Target_i386::Scan::global): Use Symbol::may_need_copy_reloc instead
of the removed Target_i386::may_need_copy_reloc.
* options.h (copyreloc): New option with default value false.
* powerpc.cc (Target_powerpc::may_need_copy_reloc): Remove.
(Target_powerpc::Scan::global): Use Symbol::may_need_copy_reloc
instead of the removed Target_powerpc::may_need_copy_reloc.
* sparc.cc (Target_powerpc::may_need_copy_reloc): Remove.
(Target_sparc::Scan::global): Use Symbol::may_need_copy_reloc
instead of the removed Target_sparc::may_need_copy_reloc.
* symtab.h (Symbol::may_need_copy_reloc): New method definition.
* x86_64.cc (Target_powerpc::may_need_copy_reloc): Remove.
(Target_x86_64::Scan::global): Use Symbol::may_need_copy_reloc
instead of the removed Target_x86_64::may_need_copy_reloc.
* options.cc: Include <cerrno> and <fstream>.
(General_options::finalize): Parse -retain-symbols-file tag.
* options.h: New flag.
(General_options): New method should_retain_symbol, new
variable symbols_to_retain.
* symtab.cc (Symbol_table::sized_finalize_symbol): Test
should_retain_symbol map.
* testsuite/Makefile.am (retain_symbols_file_test): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/retain_symbols_file_test.sh: New file.
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
(Command_line::pre_options): New member.
* options.cc (gold::options::ready_to_register): New variable.
(One_option::register_option): Do nothing if not registering options.
Assert if same short option registered twice.
(General_options::General_options): Turn off option registration when
done constructing.
(Command_line::Pre_options::Pre_options): New constructor.
ld/:
* Makefile.am (bin_PROGRAMS): Renamed from ...
(noinst_PROGRAMS): ... this.
(transform): Override, including the renaming of ld-new to ld.
(install-exec-local): Installation of ld in $(bindir) not needed
here any more.
(AM_CPPFLAGS): Renamed from ...
(INCLUDES): ... this.
(MAINTAINERCLEANFILES): Add ld.1.
* Makefile.in: Regenerate.
gold/:
* Makefile.am (AM_CPPFLAGS): Renamed from ...
(INCLUDES): ... this.
* testsuite/Makefile.am (AUTOMAKE_OPTIONS): Add -Wno-portability.
(AM_CPPFLAGS): Renamed from ...
(INCLUDE): ... this.
* Makefile.in, testsuite/Makefile.in: Regenerate.
bfd/:
* Makefile.am (libbfd_la_LDFLAGS): Initialize early, to allow
appending.
[INSTALL_LIBBFD] (bfdlib_LTLIBRARIES, bfdinclude_HEADERS): Set
only in this condition.
[!INSTALL_LIBBFD] (noinst_LTLIBRARIES, libbfd_la_LDFLAGS): New,
to build but not install libbfd.la in this condition.
(install-bfdlibLTLIBRARIES, uninstall-bfdlibLTLIBRARIES)
(install_libbfd, install_libbfd): Remove.
* Makefile.in: Regenerate.
binutils/:
* Makefile.am (AM_CPPFLAGS): Renamed from ...
(INCLUDES): ... this.
(bin2c$(EXEEXT_FOR_BUILD): Adjust rule.
(installcheck-local): Renamed from ...
(installcheck): ... this.
* Makefile.in: Regenerate.
gas/:
* Makefile.am (YFLAGS): Remove, not needed any more.
(AM_CPPFLAGS): Renamed from ...
(INCLUDES): ... this.
* Makefile.in: Regenerate.
gprof/:
* Makefile.am (AM_CPPFLAGS): Renamed from ...
(INCLUDES): ... this.
* Makefile.in: Regenerate.
opcodes/:
* Makefile.am (libopcodes_la_LDFLAGS): Initialize early.
[INSTALL_LIBBFD] (bfdlib_LTLIBRARIES): Set only in this condition.
[INSTALL_LIBBFD] (bfdinclude_DATA): New.
[!INSTALL_LIBBFD] (noinst_LTLIBRARIES): New.
[!INSTALL_LIBBFD] (libopcodes_la_LDFLAGS): Ensure libopcodes.la
is built shared even if it is not to be installed.
(install-bfdlibLTLIBRARIES,uninstall-bfdlibLTLIBRARIES)
(install_libopcodes, uninstall_libopcodes): Remove.
(AM_CPPFLAGS): Renamed from ...
(INCLUDES): ... this.
* Makefile.in: Regenerate.
* dynobj.cc (Sized_dynobj::setup): Take a Target object instead of
an elcpp::Ehdr as parameter. Adjust call to set_target.
* dynobj.h (Sized_dynobj::setup): Take a Target object instead of
an elfcpp::Ehdr as parameter.
* object.cc (Object::set_target): Remove the version that looks up
a target and sets it.
(Sized_relobj::setup): Take a Target object instead of
an elfcpp::Ehdr as parameter. Adjust call to set_target.
(make_elf_sized_object): Find target and ask target to
make an ELF object.
* object.h: (Object::set_target): Remove the version that looks up
a target and sets it.
(Sized_relobj::setup): Take a Target object instead of
an elfcpp:Ehdr as parameter.
* target.cc: Include dynobj.h.
(Target::do_make_elf_object_implementation): New.
(Target::do_make_elf_object): New.
* target.h (Target::make_elf_object): New template declaration.
(Target::do_make_elf_object): New method declarations.
(Target::do_make_elf_object_implementation): New template declaration.
* 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.
* resolve.cc (Symbol_table::resolve): Check for references from
dynamic objects to hidden and internal symbols.
* testsuite/Makefile.am (hidden_test.sh): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/hidden_test.sh: New script.
* testsuite/hidden_test_1.c: New test source.
* testsuite/hidden_test_main.c: New test source.
* layout.h: #include <map>.
(class Kept_section): Change from struct to class. Add accessors
and setters. Add section size to Comdat_group mapping. Change
Comdat_group to std::map. Add is_comdat_ field. Add
linkonce_size field in union.
(class Layout): Update declaration of find_or_add_kept_section.
Don't declare find_kept_object.
* layout.cc (Layout::find_or_add_kept_section): Remove candidate
parameter. Add object, shndx, is_comdat, and is_group_name
parameters. Change all callers. Adjust for new Kept_section.
(Layout::find_kept_object): Remove.
* object.cc (Sized_relobj::include_section_group): Update use of
Kept_section. Rename secnum to shndx. Only record
Kept_comdat_section if sections are the same size.
(Sized_relobj::include_linkonce_section): Update use of
Kept_section. Only record Kept_comdat_section if sections are the
same size. Set size of linkonce section.
(Sized_relobj::map_to_kept_section): Update call to
get_kept_comdat_section.
* object.h (class Sized_relobj): Rename fields in
Kept_comdat_section to drop trailing underscores; change object
field to Relobj*. Change Kept_comdat_section_table to store
struct rather than pointer.
(Sized_relobj::set_kept_comdat_section): Remove kept parameter.
Add kept_object and kept_shndx parameters. Change all callers.
(Sized_relobj::get_kept_comdat_section): Change return type to
bool. Add kept_object and kept_shndx parameters. Change all
callers.
* plugin.cc (Pluginobj::include_comdat_group): Update call to
Layout::find_or_add_kept_section.
* layout.cc (Layout::choose_output_section): If we find an
existing section, update the flags.
(Layout::create_notes): New function, broken out of
Layout::finalize.
(Layout::finalize): Don't create note sections.
(Layout::create_note): Don't crash if linker script discards
section.
(Layout::create_gold_note): Likewise.
(Layout::create_build_id): Likewise. Don't set
after_input_sections on the section.
(Layout::create_executable_stack_info): Remove target parameter.
Change caller.
* layout.h (class Layout): Declare create_notes. Update
declaration of create_executable_stack_info.
* gold.cc (queue_middle_tasks): Call create_notes.
* output.cc (Output_section::update_flags_for_input_section): Move
here from output.h. If SHF_ALLOC flag is newly set, mark address
invalid.
* output.h (Output_data::mark_address_invalid): New function.
(class Output_section): Only declare, not define,
update_flags_for_input_section. Remove set_flags.
* options.cc (General_options::parse_V): Set printed_version_.
(General_options::General_options): Initialize printed_version_.
* options.h (class General_options): Add printed_version_ field.
* gold.cc (queue_initial_tasks): If there are no input files,
don't give a fatal error if we printed the version information.
(queue_middle_tasks): If using -r with a shared object, give a
fatal error rather than an ordinary error.
* layout.cc (Layout::Layout): Initialize have_stabstr_section_.
(Layout::make_output_section): Set have_stabstr_section_ if we see
a .stab*str section.
(Layout::finalize): Call link_stabs_sections.
(Layout::link_stabs_sections): New file.
* layout.h (class Layout): Add have_stabstr_section_ field.
Declare link_stabs_sections.
* object.cc (Object::section_contents): Don't try to get a view if
the section has length zero.
(Object::handle_gnu_warning_section): If the section is empty, use
the name of the section as the warning.
* stringpool.h (class Stringpool_template): Add optimize_ field.
(Stringpool_template::set_optimize): New function.
* stringpool.cc (Stringpool_template::Stringpool_template):
Initialize optimize_ field.
(Stringpool_template::set_string_offsets): Test local optimize
fild rather than parameter.
* layout.cc (Layout::Layout): Call set_optimize on the section
name stringpool.
Target::new_output_section.
(Layout::attach_allocated_section_to_segment): Put large section
sections in a separate load segment with the large segment flag
set.
(Layout::segment_precedes): Sort large data segments after other
load segments.
(align_file_offset): New static function.
(Layout::set_segment_offsets): Use align_file_offset.
* output.h (class Output_section): Add is_small_section_ and
is_large_section_ fields.
(Output_section::is_small_section): New function.
(Output_section::set_is_small_section): New function.
(Output_section::is_large_section): New function.
(Output_section::set_is_large_section): New function.
(Output_section::is_large_data_section): New function.
(class Output_segment): Add is_large_data_segment_ field.
(Output_segment::is_large_data_segment): New function.
(Output_segment::set_is_large_data_segment): New function.
* output.cc (Output_section::Output_section): Initialize new
fields.
(Output_segment::Output_segment): Likewise.
(Output_segment::add_output_section): Add assertion that large
data sections always go in large data segments. Force small data
sections to the end of the list of data sections. Force small BSS
sections to the start of the list of BSS sections. For large BSS
sections to the end of the list of BSS sections.
* symtab.h (class Symbol): Declare is_common_shndx.
(Symbol::is_defined): Check Symbol::is_common_shndx.
(Symbol::is_common): Likewise.
(class Symbol_table): Define enum Commons_section_type. Update
declarations. Add small_commons_ and large_commons_ fields.
* symtab.cc (Symbol::is_common_shndx): New function.
(Symbol_table::Symbol_table): Initialize new fields.
(Symbol_table::add_from_object): Put small and large common
symbols in the right list.
(Symbol_table::sized_finalized_symbol): Check
Symbol::is_common_shndx.
(Symbol_table::sized_write_globals): Likewise.
* common.cc (Symbol_table::do_allocate_commons): Allocate new
common symbol lists. Don't call do_allocate_commons_list if the
list is empty.
(Symbol_table::do_allocate_commons_list): Remove is_tls
parameter. Add comons_section_type parameter. Change all
callers. Handle small and large common symbols.
* object.cc (Sized_relobj::do_finalize_local_symbols): Check
Symbol::is_common_shndx.
* resolve.cc (symbol_to_bits): Likewise.
* target.h (Target::small_common_shndx): New function.
(Target::small_common_section_flags): New function.
(Target::large_common_shndx): New function.
(Target::large_common_section_flags): New function.
(Target::new_output_section): New function.
(Target::Target_info): Add small_common_shndx, large_common_shndx,
small_common_section_flags, and large_common_section_flags
fields.
(Target::do_new_output_section): New virtual function.
* arm.cc (Target_arm::arm_info): Initialize new fields.
* i386.cc (Target_i386::i386_info): Likewise.
* powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
Likewise.
* sparc.c (Target_sparc::sparc_info) [all versions]: Likewise.
* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
(Target_x86_64::do_new_output_section): New function.
* configure.ac: Define conditional MCMODEL_MEDIUM.
* testsuite/Makefile.am (check_PROGRAMS): Add large.
(large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define.
(large_LDFLAGS): Define.
* testsuite/large.c: New file.
* testsuite/testfile.cc (Target_test::test_target_info):
Initialize new fields.
* configure, testsuite/Makefile.in: Rebuild.
* object.cc (Sized_relobj::Sized_relobj): Initialize
discarded_eh_frame_shndx_ to -1U.
(Sized_relobj::do_layout): Record index of a discard .eh_frame
section.
(Sized_relobj::do_count_local_symbols): Skip local symbols in
a discarded .eh_frame section.
(Sized_relobj::do_finalize_local_symbols): Ditto.
* object.h (class Sized_relobj): Declare new member
discarded_eh_frame_shndx_.
* testsuite/Makefile.am (check_PROGRAMS): Add local_labels_test.
(local_labels_test.o, local_labels_test): New rules.
* testsuite/Makefile.in: Regenerate.
* gold/arm.cc (Output_data_plt_arm): Forward declaration for new
template class.
(class Target_arm): Update comment.
(Target_arm::Target_arm): Initialize new data members GOT_,
PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_ and DYNBSS_.
Declare new methods Target_arm::got_section, Target_arm::make_plt_entry
and Target_arm::rel_dyn_section.
Declare new_enum Target_arm::Got_type.
Declare new data members GOT_, PLT_, GOT_PLT_, REL_DYN_, COPY_RELOCS_
and DYNBSS_.
Update commments for member do_dynsym_value.
(Target_arm::got_size, Target_arm::plt_section,
Target_arm::may_need_copy_reloc and Target_arm::copy_reloc): Define
new methods inside class defintion.
(Target_arm::got_section): Define new method.
(Target_arm::rel_dyn_section): Same.
(Output_data_plt_arm): New template class.
(Output_data_plt_arm::Output_data_plt_arm): Define constructor.
(Output_data_plt_arm:do_adjust_output_section): Define new method.
(Output_data_plt_arm::add_entry): Same.
(Output_data_plt_arm::first_plt_entry): Define new
static data member for PLT instruction template.
(Output_data_plt_arm::plt_entry): Same.
(Output_data_plt_arm::do_write): Define new method.
(Target_arm::make_plt_entry): Same.
(Target_arm::do_finalize_sections): Same.
(Target_arm::do_dynsym_value): Same.
* archive.cc (Archive::Archive): Move constructor from archive.h
to here. Initialize no_export_.
(Archive::get_elf_object_for_member): Set no_export flag of object.
* archive.h (Archive::Archive): Move constructor body to
archive.cc.
(Archive::no_export): New method.
(Archive::no_export_): New field.
* object.h (Object::Object): Initialize no_export_ to false.
(Object::no_export, Object::set_no_export): New methods.
(Object::no_export_): New field.
* options.cc (General_options::parse_exclude_libs): New method.
(General_options::check_excluded_libs) Same.
* options.h (exclude_libs): New option.
(General_options::check_excluded_libs): New method declaration.
(General_options::excluded_libs_): New field.
* symtab.cc (Symbol_table::add_from_relobj): Hide symbols with
default or protected visibility if an object has no-export flag set.
testsuite/Makefile.am (check_PROGRAMS): Add exclude_libs_test.
(check_SCRIPTS): Add exclude_libs_test.sh.
(check_DATA): Add exclude_libs_test.syms.
(MOSTLYCLEANFILES): Add exclude_libs_test.syms,
libexclude_libs_test_1.a and libexclude_libs_test_2.a.
(exclude_libs_test_SOURCES, exclude_libs_test_DEPENDENCIES,
exclude_libs_test_LDFLAGS and exclude_libs_test_LDADD): Define.
(exclude_libs_test.syms, libexclude_libs_test_1.a,
libexclude_libs_test_2.a): New rules.
* testsuite/Makefile.in: Regenerate.
* testsuite/exclude_libs_test.c: New file.
* testsuite/exclude_libs_test.sh: Ditto.
* testsuite/exclude_libs_test_1.c: Ditto.
* testsuite/exclude_libs_test_2.c: Ditto.
declaration.
* incremental.cc (Incremental_inputs::report_achive): New method.
(Incremental_inputs::report_object): New method.
(Incremental_inputs::report_script): New method.
(Incremental_inputs::finalize_inputs): New method.
(Incremental_inputs::finalize): Call finalize_inputs().
(Incremental_inputs::sized_create_incremental_inputs_section_data):
Create inputs entries.
* incremental.h (Incremental_input_type): New enum.
(Incremental_inputs::Incremental_input): Initialize new fields.
(Incremental_inputs::report_inputs): New method.
(Incremental_inputs::report_achive): New method.
(Incremental_inputs::report_object): New method.
(Incremental_inputs::report_script): New method.
(Incremental_inputs::finalize_inputs): New method.
(Incremental_inputs::Input_info): New struct.
(Incremental_inputs::Input_info_map): New typedef.
(Incremental_inputs::lock_): New field.
(Incremental_inputs::Inputs_): New field.
(Incremental_inputs::Inputs_map): New field.
* main.cc (main): Call Incremental_input::report_inputs.
* options.h (Input_argument_list): Typedef moved from
Input_arguments.
(Input_file_group::Files): Remove, use ::Input_argument_list.
(Input_file_group::Input_argument_list): Remove, use
::Input_argument_list.
* plugin.cc (Plugin_manager::add_input_file): Add error in
incremental build.
* read_syms.cc (do_read_syms): Call Incremental_input::report_*
functions.
* script.cc (read_input_script): Call
Incremental_input::report_script.
* script.h (Script_info): New class.
* configure.ac (HAVE_TR1_UNORDERED_MAP_REHASH): New define.
* configure: Regenerate.
* config.in: Regenerate.
* gold.h: Avoid std::tr1::unordered_map and std::tr1::unordered_set
if HAVE_TR1_UNORDERED_MAP_REHASH is not defined.
Incremental_input_header_data.
(Incremental_inputs_header_data::data_size): New field.
(Incremental_inputs_header_data::put_input_file_count): Renamed
from input_file_count.
(Incremental_inputs_header_data::put_command_line_offset): Renamed
from command_line_offset.
(Incremental_inputs_header_data::put_reserved): Renamed from
put_reserved.
(Incremental_inputs_entry_data): Renamed from
Incremental_input_entry_data.
(Incremental_inputs_entry_data::data_size): New field.
(Incremental_inputs::report_command_line): New method.
(Incremental_inputs::finalize): New method.
(Incremental_inputs::create_incremental_inputs_data): New method.
(Incremental_inputs::sized_create_incremental_inputs_data): New method.
* incremental.h: New file.
* layout.cc (Layout::Layout): Handle new incremental_inputs_.
(Layout::finalize): Create incremental inputs section in
incremental builds.
(Layout::create_incremental_info_sections): New method.
* layout.h (Layout::incremental_inputs): New method.
(Layout::create_incremental_info_sections): New method.
(Layout::incremental_inputs_): New field.
* main.cc (main): Notify Incremental_input of the command line.
each version of Unordered_map.
* layout.cc (Layout::Layout): Remove options parameter. Add
number_of_input_files parameter. Don't initialize options_.
Initialize number_of_input_files_ and resized_signatures_. Move
sections_are_attached_.
(Layout::layout_group): Reserve space for group_signatures_.
(Layout::find_or_add_kept_section): Change name parameter to be a
reference. Resize signatures_ map when it gets large enough.
(Layout::layout_eh_frame): Use parameters->options() instead of
this->options_.
(Layout::make_output_section): Likewise.
(Layout::attach_allocated_section_to_segment): Likewise.
(Layout::finalize, Layout::create_executable_stack): Likewise.
(Layout::set_segment_offsets, Layout::create_interp): Likewise.
(Layout::finish_dynamic_section, Layout::write_binary): Likewise.
* layout.h (class Layout): Update declarations. Remove options_
field. Add number_of_input_files_ and resized_signatures_
fields. Move sections_are_attached_ field.
* main.cc (main): Pass number of input files to Layout
constructor. Don't pass options.
* configure.ac: Call AC_REPLACE_FUNCS on mremap.
* gold.h (MREMAP_MAYMOVE): Define if HAVE_MREMAP is not defined.
(mremap): Declare if HAVE_MREMAP is not defined.
* configure, Makefile.in, config.in: Rebuild.
(Output_file::map): Use map_anonymous. If the regular mmap fails,
try an anonymous one. Report the size if the mmap fails.
* output.h (class Output_file): Declare map_anonymous.
* freebsd.h: New file.
* i386.cc: Include "freebsd.h".
(Target_i386): Derive from Target_freebsd rather than
Sized_target.
(Target_selector_i386): Derive from Target_selector_freebsd rather
than Target_selector.
* x86_64.cc: Include "freebsd.h".
(Target_x86_64): Derive from Target_freebsd rather than
Sized_target.
(Target_selector_x86_64): Derive from Target_selector_freebsd
rather than Target_selector.
* target.h (class Target): Add adjust_elf_header and
do_adjust_elf_header.
* output.cc (Output_file_header:: do_sized_write): Call target
adjust_elf_header routine.
* configure.tgt: Set targ_osabi.
* configure.ac: Define GOLD_DEFAULT_OSABI.
* parameters.cc (Parameters::default_target): Pass
GOLD_DEFAULT_OSABI to select_target.
* target-select.h (class Target_selector): Make instantiate_target
protected rather than private.
* Makefile.am (HFILES): Add freebsd.h.
* configure, Makefile.in, config.in: Rebuild.
(class Script_sections): Change Sections_elements from std::vector
to std::list. Typedef public Elements_iterator. Add
orphan_section_placement_, data_segment_align_start_, and
saw_data_segment_align_ fields. Remove data_segment_align_index_
field.
* script-sections.cc (class Orphan_section_placement): New class.
(class Sections_element): Add virtual functions is_relro and
orphan_section_init. Remove virtual function place_orphan_here.
(class Output_section_definition): Add is_relro and
orphan_section_init. Remove place_orphan_here.
(class Orphan_output_section): Likewise.
(Script_sections::Script_sections): Update for field changes.
(Script_sections::data_segment_align): Set saw_data_segment_align_
and data_segment_align_start_, not data_segment_align_index.
(Script_sections::data_segment_relro_end): Check
saw_data_segment_align_. Use data_segment_align_start_ rather
than data_segment_align_index_.
(Script_sections::place_orphan): Rewrite to use
Orphan_section_placement.
to the symbol name in the archive map.
* testsuite/Makefile.am (check_PROGRAMS): Add ver_test_11.
(ver_test_11_SOURCES, ver_test_11_DEPENDENCIES): Define.
(ver_test_11_LDFLAGS, ver_test_11_LDADD): Define.
(ver_test_11.a): New target.
* testsuite/Makefile.in: Rebuild.
ftruncate.
* ftruncate.c: New file, from gnulib.
* output.cc (posix_fallocate): Define dummy version if not
HAVE_POSIX_FALLOCATE.
(Output_file::map): Call posix_fallocate rather than lseek and
write.
* gold.h (ftruncate): Declare if not HAVE_FTRUNCATE.
* configure, Makefile.in, config.in: Rebuild.
(FD_CLOEXEC, O_CLOEXEC): Define if not defined.
(Descriptors::open): Always use O_CLOEXEC when opening a new
descriptor. If we have a plugin, and O_CLOEXEC was not defined,
then set FD_CLOEXEC.
(Target_sparc::Scan::global): If we see _GLOBAL_OFFSET_TABLE_,
make sure we have a GOT section.
* sparc.cc (optimize_tls_reloc): Recognize R_SPARC_TLS_IE_ADD.
(Target_sparc::Scan::local): Likewise.
(Target_sparc::Scan::global): Likewise.
(Target_sparc::Relocate::relocate): Likewise.
(Target_sparc::Relocate::relocate_tls): Likewise.
broken out of add_from_object.
(Symbol_table::add_from_object): Call define_default_version.
(Symbol_table::define_special_symbol): Add resolve_oldsym
parameter. Change all callers. If the version for a symbol comes
from a version script, resolve it with the symbol with the same
name with no version. Also add the symbol without a version if
appropriate.
(do_define_in_output_data): If resolving with oldsym, don't delete
sym.
(do_define_in_output_segment): Likewise.
(do_define_as_constant): Likewise.
* symtab.h (class Symbol_table): Update declarations.
(Read_symbols::requeue): New function.
(Read_symbols::do_read_symbols): If make_elf_object fails because
the target type is not configured, and the file was searched for,
issue a warning and retry with the next directory.
(Add_symbols::run): If the file has an incompatible format, and
it was searched for, requeue the Read_symbols task. On error,
release the object.
* readsyms.h (class Read_symbols): Add dirindex_ field. Add
dirindex parameter to constructor. Change all callers. Declare
incompatible_warning and requeue.
(class Add_symbols): Add dirpath_, dirindex_, mapfile_,
input_argument_ and input_group_ fields. Add them to
constructor. Change all callers.
(class Read_script): Add dirindex_ field. Add it to constructor.
Change all callers.
* archive.cc (Archive::setup): Remove input_objects parameter.
Change all callers.
(Archive::get_file_and_offset): Likewise.
(Archive::read_all_symbols): Likewise.
(Archive::read_symbols): Likewise.
(Archive::get_elf_object_for_member): Remove input_objects
parameter. Add punconfigured parameter. Change all callers.
(Archive::add_symbols): Change return type to bool. Check return
value of include_member.
(Archive::include_all_members): Likewise.
(Archive::include_member): Change return type to bool. Return
false if first included object has incompatible target. Set
included_member_ field.
(Add_archive_symbols::run): If add_symbols returns false, requeue
Read_symbols task.
* archive.h (class Archive): Add included_member_ field.
Initialize it in constructor. Add input_file and searched_for
methods. Update declarations.
(class Add_archive_symbols): Add dirpath_, dirindex_, and
input_argument_ fields. Add them to constructor. Change all
callers.
* script.cc: Include "target-select.h".
(class Parser_closure): Add skip_on_incompatible_target_ and
found_incompatible_target_ fields. Add
skip_on_incompatible_target parameter to constructor. Change all
callers. Add methods skip_on_incompatible_target,
clear_skip_on_incompatible_target, found_incompatible_target, and
set_found_incompatible_target.
(read_input_script): Add dirindex parameter. Change all callers.
If parser finds an incompatible target, requeue Read_symbols
task.
(script_set_symbol): Clear skip_on_incompatible_target in
closure.
(script_add_assertion, script_parse_option): Likewise.
(script_start_sections, script_add_phdr): Likewise.
(script_check_output_format): New function.
* script.h (read_input_script): Update declaration.
* script-c.h (script_check_output_format): Declare.
* yyscript.y (file_cmd): Handle OUTPUT_FORMAT.
(ignore_cmd): Remove OUTPUT_FORMAT.
* fileread.cc (Input_file::Input_file): Add explicit this.
(Input_file::will_search_for): New function.
(Input_file::open): Add pindex parameter. Change all callers.
* fileread.h (class Input_file): Add input_file_argument method.
Declare will_search_for. Update declarations.
* object.cc (make_elf_object): Add punconfigured parameter.
Change all callers.
* object.h (class Object): Make input_file public. Add
searched_for method.
(make_elf_object): Update declaration.
* dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to
restart search.
* dirsearch.h (class Dirsearch): Update declaration.
* options.h (class General_options): Add --warn-search-mismatch.
* parameters.cc (Parameters::is_compatible_target): New function.
* parameters.h (class Parameters): Declare is_compatible_target.
* workqueue.cc (Workqueue::add_blocker): New function.
* workqueue.h (class Workqueue): Declare add_blocker.
* elfcpp_swap.h: #include "config.h". Only #include <byteswap.h>
if HAVE_BYTESWAP_H is defined; if not, provide definitions for
bswap_{16,32,64}. For gcc 4.3 and later, use the builtin bswap
functions. Check WORDS_BIGENDIAN rather than __BYTE_ORDER.
gold:/
* configure.ac: Check for byteswap.h.
* configure: Rebuild.
* config.in: Rebuild.
(Layout::add_comdat): Removed.
* layout.h (struct Kept_section): Move out of class Layout.
Remove trailing underscores from field names. Add group_sections
field. Rename group_ field to is_group. Change all uses.
(class Layout): Declare find_or_add_kept_section, not add_comdat.
* object.cc (Sized_relobj::Sized_relobj): Don't initialize
comdat_groups_ field.
(Sized_relobj::include_section_group): Use
find_or_add_kept_section and Kept_section::group_sections.
(Sized_relobj::include_linkonce_section): Likewise.
* object.cc (class Sized_relobj): Don't define Comdat_group or
Comdat_group_table. Remove find_comdat_group and
add_comdat_group. Remove comdat_groups_ field.
* plugin.cc (include_comdat_group): Use
Layout::find_or_add_kept_section.
* symtab.cc (Symbol_table::sized_write_section_symbol): In a
relocatable link set the value of the section symbol to zero.
* object.cc (Sized_relobj::do_finalize_local_symbols): In a
relocatable link don't include the section address in the local
symbol value.
* descriptors.h (Open_descriptor): Add is_on_stack field.
* descriptors.cc (Descriptors::open): If the descriptor is on the
top of the stack, remove it. Initialize is_on_stack field.
(Descriptors::release): Only add pod to stack if it is not on the
stack already.
(Descriptors::close_some_descriptor): Clear stack_next and
is_on_stack fields.
* output.cc (Output_section::find_starting_output_address): Rename
from starting_output_address; add PADDR parameter; change return
type.
* output.h (class Output_section): Declare
find_starting_output_address instead of starting_output_address.
* object.cc (Sized_relobj::do_finalize_local_symbols): Handle a
section symbol for which we can't find a merge section.
* symtab.cc (Symbol_table::add_from_object): If the visibility is
hidden or internal, force the symbol to be local.
* resolve.cc (Symbol::override_visibility): Define.
(Symbol::override_base): Use override_visibility.
(Symbol_table::resolve): Likewise.
(Symbol::override_base_with_special): Likewise.
(Symbol_table::override_with_special): If the visibility is hidden
or internal, force the symbol to be local.
* symtab.h (class Symbol): Add set_visibility and
override_visibility.
* testsuite/ver_test_1.sh: New file.
* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh.
(check_DATA): Add ver_test_1.syms.
(ver_test_1.syms): New target.
* testsuite/Makefile.in: Rebuild.
when using a linker script that has a SECTIONS clause.
* Makefile.in: Regenerate.
* testsuite/Makefile.am (script_test_5.sh): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/script_test_5.cc: New file.
* testsuite/script_test_5.sh: New file.
* testsuite/script_test_5.t: New file.
* archive.cc (Archive::include_member): Update calls to add_symbols.
* dynobj.cc (Sized_dynobj<size, big_endian>::make_version_map): Add
the Layout argument.
* dynobj.h (do_add_symbols): Add the Layout argument.
* object.cc (Sized_relobj<size, big_endian>::do_add_symbols): Add the
Layout argument.
* object.h (Object::add_symbols): Add the Layout argument.
(Object::do_add_symbols): Add the Layout argument.
(Sized_relobj::do_add_symbols): Add the Layout argument.
* plugin.cc (Sized_pluginobj<size, big_endian>::do_add_symbols):
Unify the two versions.
(Add_plugin_symbols): Remove.
* plugin.h (Pluginobj::add_symbols, Pluginobj::do_add_symbols): Remove.
(Sized_pluginobj::do_add_symbols): Unify the two versions.
(Add_plugin_symbols): Remove.
* readsyms.cc (Read_symbols::do_read_symbols): Update call to
Add_symbols. Use Add_symbols instead of Add_plugin_symbols.
(Add_symbols::run): Make it work with Pulginobj.
(class General_options): Add new options: --incremental,
--incremental_changed, --incremental_unchanged,
--incremental_unknown. Add incremental_disposition_ and
implicit_incremental_ fields.
(General_options::incremental_disposition): New function.
(class Position_dependent_options): Add incremental_disposition
option.
(Position_dependent_options::copy_from_options): Set incremental
dispositions.
* options.cc (General_options::parse_incremental_changed): New
function.
(General_options::parse_incremental_unchanged): New function.
(General_options::parse_incremental_unknown): New function.
(General_options::General_options): Initialize new fields
incremental_disposition_ and implicit_incremental_.
(General_options::finalize): Check for uasge of --incremental-*
without --incremental.
* 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.
* reduced_debug_output.h
(Output_reduced_debug_abbrev_section::failed): Use format for
gold_warning.
(Output_reduced_debug_info_section::faild): Likewise.
* version.cc: Include <cstdio>.
* object.cc (Sized_relobj::do_layout): Initialize gc_sd to avoid a
warning.
* reduced_debug_output.cc (insert_into_vector): Rename from
Insert_into_vector; change all callers. Use Swap_unaligned to
avoid aliasing issue; remove union since it is unnecessary.
* 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.
to File_read::claim_for_plugin.
* descriptors.cc (Descriptors::open): Remove reference to
is_claimed.
(Descriptors::claim_for_plugin): Remove.
* descriptors.h (Descriptors::claim_for_plugin): Remove.
(Descriptors::is_claimed): Remove.
(claim_descriptor_for_plugin): Remove.
* fileread.cc (File_read::claim_for_plugin): Remove.
* fileread.h (File_read::claim_for_plugin): Remove.
(File_read::descriptor): Reopen descriptor if necessary.
* plugin.cc (Plugin::load): Add two new APIs to transfer vector.
(Plugin_manager::all_symbols_read): Add task parameter. Change
all callers.
(Plugin_manager::get_input_file): New function.
(Plugin_manager::release_input_file): New function.
(Pluginobj::Pluginobj): Add filesize parameter and initialize
corresponding data member.
(Sized_pluginobj::Sized_pluginobj): Add filesize parameter
and pass to base constructor. Change all callers.
(get_input_file, release_input_file): New functions.
(make_sized_plugin_object): Add filesize parameter. Change all callers.
* plugin.h (Plugin_manager::Plugin_manager): Initialize task_ member.
(Plugin_manager::all_symbols_read): Add task parameter.
(Plugin_manager::get_input_file): New function.
(Plugin_manager::release_input_file): New function.
(Plugin_manager::task_): New data member.
(Pluginobj::Pluginobj): Add filesize parameter.
(Pluginobj::filename): New function.
(Pluginobj::descriptor): New function.
(Pluginobj::filesize): New function.
(Pluginobj::filesize_): New data member.
(Sized_pluginobj::Sized_pluginobj): Add filesize parameter.
* readsyms.cc (Read_symbols::do_read_symbols): Remove call to
File_read::claim_for_plugin; use Object::unlock to unlock the file.
* testsuite/Makefile.am (plugin_test_4): New test case for plugins
with archive libraries.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_test.c (struct sym_info): New type.
(get_input_file, release_input_file): New static variables.
(onload): Capture new transfer vector entries.
(claim_file_hook): Stop reading at end of file according to filesize.
Factor out parsing of readelf output into separate function.
(all_symbols_read_hook): Exercise get_input_file and release_input_file
APIs and get the source file name from the symbol table. Convert
source file name to corresponding object file name. Print info
message when adding new input files.
(parse_readelf_line): New function.
* testsuite/plugin_test_1.sh: Add checks for new info messages.
* testsuite/plugin_test_2.sh: Likewise.
* testsuite/plugin_test_3.sh: Likewise.
* testsuite/plugin_test_4.sh: New test case.
* plugin.cc (Plugin_manager::finish): Rename as
layout_deferred_objects. Move cleanup to separate function.
(Plugin_manager::cleanup): New function.
(Plugin_finish::run): Call layout_deferred_objects and cleanup
separately.
* plugin.h (Plugin_manager::finish): Rename as
layout_deferred_objects.
(Plugin_manager::cleanup): New function.
(Plugin_manager::cleanup_done): New field.
(Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside
so we don't return "IR only" status for exported symbols or -r links.
* testsuite/Makefile.am (plugin_test_3): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_test_3.sh: New file.
(Sized_relobj::do_layout): Defer layout of input sections until after
plugin has provided replacement files.
(Sized_relobj::do_layout_deferred_sections): New function.
* object.h (Relobj::set_section_offset): Remove virtual keyword.
(Relobj::layout_deferred_sections): New function.
(Relobj::do_layout_deferred_sections): New function.
(Sized_relobj::do_layout_deferred_sections): New function.
(Sized_relobj::layout_section): New function.
(Sized_relobj::Deferred_layout): New structure.
(Sized_relobj::deferred_layout_): New field.
* plugin.cc (Plugin_manager::finish): Renamed, was cleanup.
Change all callers. Layout deferred sections.
(class Plugin_finish): Renamed, was Plugin_cleanup. Change all
references.
(Plugin_hook::run): Move code from do_plugin_hook inline.
(Plugin_hook::do_plugin_hook): Remove.
* plugin.h (Plugin_manager::Plugin_manager): Add missing initializers.
(Plugin_manager::finish): Renamed, was cleanup.
(Plugin_manager::should_defer_layout): New function.
(Plugin_manager::add_deferred_layout_object): New function.
(Plugin_manager::Deferred_layout_list): New type.
(Plugin_manager::deferred_layout_objects_): New field.
(Plugin_hook::do_plugin_hook): Remove.
vector.
(Plugin_manager::claim_file): Create plugin object even if
plugin did not call the add_symbols callback.
(Plugin_obj::get_symbol_resolution_info): Guard against plugin
asking for more symbols than were added.
* testsuite/Makefile.am (plugin_test_1): Add test case with
no global symbols.
(empty.syms): New target.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_test.c (claim_file_hook): Add new debug
message. Don't call add_symbols if no globals.
(all_symbols_read_hook): Don't provide replacement for empty
claimed file.
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.
* plugin.cc (ld_plugin_message): Change format parameter to const.
Fix mismatch between new[] and delete.
include/ChangeLog:
* plugin-api.h (ld_plugin_message): Change format parameter to const.
* options.h (General_options): New flags dynamic_list,
dynamic_list_data, dynamic_list_cpp_new, and
dynamic_list_cpp_typeinfo. New variable dynamic_list_.
(General_options::in_dynamic_list): New function.
* script.cc (Lex::Mode): New enum DYNAMIC_LIST.
(Lex::can_start_name): Add support for DYNAMIC_LIST mode.
(Lex::can_continue_name): Likewise.
(yylex): Likewise.
(read_script_file): New parameter script_options.
(read_dynamic_list): New function.
(Script_options::define_dynamic_list): New function.
(dynamic_list_keyword_parsecodes): New variable.
(dynamic_list_keywords): New variable.
* script.h (Script_options::define_dynamic_list): New function
prototype.
(read_dynamic_list): New function prototype.
* symtab.cc (strprefix): New macro.
(Symbol::should_add_dynsym_entry): Support dynamic_list,
dynamic_list_data, dynamic_list_cpp_new, and
dynamic_list_cpp_typeinfo.
* yyscript.y (PARSING_DYNAMIC_LIST): New token.
(dynamic_list_expr): New rule.
(dynamic_list_nodes): Likewise.
(dynamic_list_node): Likewise.
* testsuite/Makefile.am (dynamic_list): New test.
* testsuite/Makefile.in: Regenerated.
* testsuite/dynamic_list.t: New file.
* testsuite/dynamic_list.sh: New file.
of name to get library path.
(Archive::include_member): Unlock external member of a thin archive.
* testsuite/Makefile.am (TEST_AR): New variable.
(thin_archive_test_1): New test.
(thin_archive_test_2): New test.
* 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.
include/:
* plugin-api.h: New file.
gold/:
* configure.ac (plugins): Add --enable-plugins option.
* configure: Regenerate.
* config.in: Regenerate.
* Makefile.am (LIBDL): New variable.
(CCFILES): Add plugin.cc.
(HFILES): Add plugin.h.
(ldadd_var): Add LIBDL.
* Makefile.in: Regenerate.
* archive.cc: Include "plugin.h".
(Archive::setup): Don't preread archive symbols when using a plugin.
(Archive::get_file_and_offset): Add memsize parameter. Change callers.
(Archive::get_elf_object_for_member): Call plugin hooks for claiming
files.
(Archive::include_member): Add symbols from plugin objects.
* archive.h (Archive::get_file_and_offset): Add memsize parameter.
* descriptors.cc (Descriptors::open): Check for file descriptors
abandoned by plugins.
(Descriptors::claim_for_plugin): New function.
* descriptors.h (Descriptors::claim_for_plugin): New function.
(Open_descriptor::is_claimed): New field.
(claim_descriptor_for_plugin): New function.
* fileread.cc (File_read::claim_for_plugin): New function.
* fileread.h (File_read::claim_for_plugin): New function.
(File_read::descriptor): New function.
* gold.cc: Include "plugin.h".
(queue_initial_tasks): Add task to call plugin hooks for generating
new object files.
* main.cc: Include "plugin.h".
(main): Load plugin libraries.
* object.h (Pluginobj): Declare.
(Object::pluginobj): New function.
(Object::do_pluginobj): New function.
(Object::set_target): New function.
* options.cc: Include "plugin.h".
(General_options::parse_plugin): New function.
(General_options::General_options): Initialize plugins_ field.
(General_options::add_plugin): New function.
* options.h (Plugin_manager): Declare.
(General_options): Add --plugin option.
(General_options::has_plugins): New function.
(General_options::plugins): New function.
(General_options::add_plugin): New function.
(General_options::plugins_): New field.
* plugin.cc: New file.
* plugin.h: New file.
* readsyms.cc: Include "plugin.h".
(Read_symbols::do_read_symbols): Check for archive before checking
for ELF file. Call plugin hooks to claim files.
* resolve.cc (Symbol_table::resolve): Record when symbol is referenced
from a real object file; force override when processing replacement
files.
* symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field.
(Symbol::init_base_object): Likewise.
(Symbol::init_base_output_data): Likewise.
(Symbol::init_base_output_segment): Likewise.
(Symbol::init_base_constant): Likewise.
(Symbol::init_base_undefined): Likewise.
(Symbol::output_section): Assert that object is not a plugin.
(Symbol_table::add_from_pluginobj): New function.
(Symbol_table::sized_finalize_symbol): Treat symbols from plugins as
undefined.
(Symbol_table::sized_write_globals): Likewise.
(Symbol_table::add_from_pluginobj): Instantiate template.
* symtab.h (Sized_pluginobj): Declare.
(Symbol::in_real_elf): New function.
(Symbol::set_in_real_elf): New function.
(Symbol::in_real_elf_): New field.
(Symbol_table::add_from_pluginobj): New function.
* testsuite/Makefile.am (AM_CFLAGS): New variable.
(LIBDL): New variable.
(LDADD): Add LIBDL.
(check_PROGRAMS): Add plugin_test_1 and plugin_test_2.
(check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh.
(check_DATA): Add plugin_test_1.err and plugin_test_2.err.
(MOSTLYCLEANFILES): Likewise.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_test.c: New file.
* testsuite/plugin_test_1.sh: New file.
* testsuite/plugin_test_2.sh: New file.
* options.h (origin): New -z option.
* layout.cc (Layout:finish_dynamic_section): If "-z origin"
is specified, set DF_ORIGIN in DT_FLAGS and set DF_1_ORIGIN
in DT_FLAGS_1.
PR gold/6858
* options.cc (General_options::finalize): Allow undefined symbols
in shlibs if linking -shared.
PR gold/6859
* symtab.cc (Symbol::init_base_undefined): Mark explicitly undefined
symbols as not needing a dynsym entry.
* x86_64.cc (Target_x86_64::Relocate::relocat_tls):
Use addend for DTPOFF32, DTPOFF64, and TPOFF32 relocs.
* testsuite/tls_test.cc (struct int128): 128-bit struct
for testing TLS relocs with non-zero addend.
(v12): New TLS variable.
(t12): New test.
(t_last): Add check for v12.
* testsuite/tls_test.h (t12): New function.
* testsuite/tls_test_main.cc (thread_routine): Call new test.
set tls_segment_ or relro_segment_.
(Layout::make_output_segment): Set tls_segment_ and relro_segment_
when appropriate.
* output.h (Output_section::clear_is_relro): New function.
* output.cc (Output_segment::add_output_section): Handle SHF_TLS
sections specially even when output_data_ is empty.
(Output_segment::maximum_alignment): When first section is relro,
only force alignment for PT_LOAD segments.
* script.cc (script_data_segment_align): New function.
(script_data_segment_relro_end): New function.
* script-c.h (script_data_segment_align): Declare.
(script_data_segment_relro_end): Declare.
* script-sections.h (class Script_sections): Declare
data_segment_align and data_segment_relro_end. Add fields
segment_align_index_ and saw_relro_end_.
* script-sections.cc (class Sections_element): Add set_is_relro
virtual function. Add new bool* parameter to place_orphan_here.
Add get_output_section virtual function.
(class Output_section_definition): Add set_is_relro. Add new
bool* parameter to place_orphan_here. Add get_output_section.
Add is_relro_ field.
(Output_section_definition::Output_section_definition): Initialize
evaluated_address_, evaluated_load_address, evaluated_addralign_,
and is_relro_ fields.
(Output_section_definition::place_orphan_here): Add is_relro
parameter.
(Output_section_definition::set_section_addresses): Set relro for
output section.
(Output_section_definition::alternate_constraint): Likewise.
(class Orphan_output_section): Add new bool* parameter to
place_orphan_here. Add get_output_section.
(Orphan_output_section::place_orphan_here): Add is_relro
parameter.
(Script_sections::Script_sections): Initialize
data_segment_align_index_ and saw_relro_end_.
(Script_sections::data_segment_align): New function.
(Script_sections::data_segment_relro_end): New function.
(Script_sections::place_orphan): Set or clear is_relro.
(Script_sections::set_section_addresses): Force alignment of first
TLS section.
* yyscript.y (exp): Call script_data_segment_align and
script_data_segment_relro_end.
* testsuite/relro_script_test.t: New file.
* testsuite/relro_test.cc (using_script): Declare.
(t1, t2): Test using_script.
* testsuite/Makefile.am (check_PROGRAMS): Add relro_script_test.
(relro_script_test_SOURCES): Define.
(relro_script_test_DEPENDENCIES): Define.
(relro_script_test_LDFLAGS): Define.
(relro_script_test_LDADD): Define.
(relro_script_test.so): New target.
* testsuite/Makefile.in: Rebuild.
* archive.cc (Archive::total_archives, Archive::total_members)
(Archive::total_members_loaded): New variables.
(Archive::setup): Add parameter. Add option to preread
archive symbols.
(Archive::read_armap): Add counter.
(Archive::get_file_and_offset): New function.
(Archive::get_elf_object_for_member): New function.
(Archive::read_all_symbols): New function.
(Archive::read_symbols): New function.
(Archive::add_symbols): Add counters.
(Archive::include_all_members): Use armap to find members if it's
already built.
(Archive::include_member): Skip reading symbols if already read.
Factored code into Archive::get_file_and_offset and
Archive::get_elf_object_for_member. Changed call to
Mapfile::report_include_archive_member.
(Archive::print_stats): New function.
* archive.h: Declare Object and Read_symbols_data classes.
(Archive::Archive): Add initializers for new members.
(Archive::setup): Add parameter.
(Archive::print_stats): New function.
(Archive::total_archives, Archive::total_members)
(Archive::total_members_loaded): New variables.
(Archive::get_file_and_offset): New function.
(Archive::get_elf_object_for_member): New function.
(Archive::read_all_symbols): New function.
(Archive::read_symbols): New function.
(Archive::Archive_member): New class.
(Archive::members_): New member.
(Archive::num_members_): New member.
* main.cc: Include archive.h.
(main): Call Archive::print_stats.
* mapfile.cc (Mapfile::report_include_archive_member): Delete
archive parameter; member_name is now the fully-decorated name.
* mapfile.h (Mapfile::report_include_archive_member): Likewise.
* options.h: (General_options): Add --preread-archive-symbols option.
* readsyms.cc (Read_symbols::do_read_symbols): Change call to
Archive::setup.
symbols before other symbols.
* testsuite/script_test_2.cc (test_addr): Declare.
(test_addr_alias): Declare.
(main): Check that test_addr and test_addr_alias have the right
values.
* testsuite/script_test_2.t: Define test_addr_alias and
test_addr.
* descriptors.cc: New file.
* descriptors.h: New file.
* gold-threads.h (class Hold_optional_lock): New class.
* fileread.cc: Include "descriptors.h".
(File_read::~File_read): Release descriptor rather than closing
it.
(File_read::open) [file]: Call open_descriptor rather than open.
Set is_descriptor_opened_.
(File_read::open) [memory]: Assert that descriptor is not open.
(File_read::reopen_descriptor): New function.
(File_read::release): Release descriptor.
(File_read::do_read): Make non-const. Reopen descriptor.
(File_read::read): Make non-const.
(File_read::make_view): Reopen descriptor.
(File_read::do_readv): Likewise.
* fileread.h (class File_read): Add is_descriptor_opened_ field.
Update declarations.
* layout.cc: Include "descriptors.h".
(Layout::create_build_id): Use open_descriptor rather than open.
* output.cc: Include "descriptors.h".
(Output_file::open): Use open_descriptor rather than open.
* archive.cc (Archive::const_iterator): Change Archive to be
non-const.
(Archive::begin, Archive::end): Make non-const.
(Archive::count_members): Likewise.
* archive.h (class Archive): Update declarations.
* object.h (Object::read): Make non-const.
* Makefile.am (CCFILES): Add descriptors.cc.
(HFILES): Add descriptors.h.
* Makefile.in: Rebuild.
array size plus one.
(Stringpool_template::set_string_offsets): Subtract one from key
before using it as an array index.
(Stringpool_template::get_offset_with_length): Likewise.
(Stringpool_template::write_to_buffer): Likewise.
* stringpool.h (Stringpool_template::get_offset_from_key):
Likewise.
* script.cc (Version_script_info::get_versions): Don't add empty
version tag to return value.
(Version_script_info::get_symbol_version_helper): Change return
type to bool. Add pversion parameter. Change all callers.
(script_register_vers_node): Don't require a non-NULL tag.
* script.h (class Version_script_info): Update declarations.
(Version_script_info::get_symbol_version): Change return type to
bool. Add version parameter. Change all callers.
* symtab.cc (Sized_symbol::add_from_relobj): Rework version
handling. Handle an empty version from a version script.
(Symbol_table::define_special_symbol): Likewise.
* testsuite/ver_test_10.script: New file.
* testsuite/ver_test_10.sh: New file.
* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_10.sh.
(check_DATA): Add ver_test_10.syms.
(ver_test_10.syms, ver_test_10.so): New target.
* testsuite/Makefile.in: Rebuild.
-N/--omagic.
* options.cc (General_options::finalize): For -n/--nmagic or
-N/--omagic, set -static.
* layout.cc (Layout::attach_allocated_section_to_segment): If
-N/--omagic, don't put read-only and read-write sections in
different segments.
(Layout::find_first_load_seg): If -N/--omagic, don't insist on
finding a read-only segment.
(Layout::set_segment_offsets): If -N/--omagic or -n/--nmagic,
don't set the minimum segment alignment to the common page size,
and don't set the file offset to the address modulo the page size.
* script-sections.cc (Script_sections::create_segments): If
-n/--omagic, don't put read-only and read-write sections in
different segments.
where we see NAME/NULL and NAME/VERSION as separate symbols.
* testsuite/ver_test_main.cc (main): Call t4.
(t4, t4_2a): Define.
* testsuite/ver_test_2.cc (t4_2): Define.
* testsuite/ver_test_2.script: Put t4_2a in VER2.
* testsuite/ver_test_4.cc (t4_2a): Define.
* testsuite/ver_test_4.script: Put t4_2a in VER2.
* testsuite/ver_test.h (t4, t4_2, t4_2a): Declare.
* 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.
PR 6682
* powerpc.cc (Powerpc_relocate_functions::addr16_ha) [both
versions]: Don't try to read the value in the contents, since we
don't use it. Use the template endianness when writing.
* fileread.cc (File_read::make_view): Assert on zero-length view.
* object.cc (Sized_relobj::do_read_symbols): Don't try to read
symbol table when there are no symbols to read.
zero for Output_section_data constructors.
(Output_section::Input_section::addralign): If not an input
section, return the alignment of the Output_section_data.
* testsuite/copy_test.cc: New file.
* testsuite/copy_test_1.cc: New file.
* testsuite/copy_test_2.cc: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add copy_test.
(copy_test_SOURCES, copy_test_DEPENDENCIES): New variables.
(copy_test_LDFLAGS, copy_test_LDADD): New variables.
(copy_test_1_pic.o, copy_test_1.so): New targets.
(copy_test_2_pic.o, copy_test_2.so): New targets.
* testsuite/Makefile.in: Rebuild.
David S. Miller <davem@davemloft.net>
* powerpc.cc: New file.
* Makefile.am (TARGETSOURCES): Add powerpc.cc
(ALL_TARGETOBJS): Add powerpc.$(OBJEXT)
* configure.tgt: Add entries for powerpc-* and powerpc64-*.
* Makefile.in: Rebuild.
* layout.cc (Layout::Layout): Initialize relro_segment_.
(Layout::add_output_section_data): Return the output section.
(Layout::make_output_section): Rcognize relro sections and mark
them appropriately.
(Layout::attach_allocated_section_to_segment): Put relro sections
in a PT_GNU_RELRO segment.
(Layout::create_initial_dynamic_sections): Mark the .dynamic
section as relro.
(Layout::segment_precedes): Sort PT_GNU_RELRO segments after
PT_TLS segments.
(Layout::linkonce_mapping): Map d.rel.ro.local to
.data.rel.ro.local.
(Layout::output_section_name): Us .data.rel.ro.local for any
section which begins with that.
* layout.h (class Layout): Update add_output_section_data
declaration. Add relro_segment_ field.
* output.cc (Output_section::Output_section): Initialize is_relro_
and is_relro_local_ fields.
(Output_segment::add_output_section): Group relro sections.
(Output_segment::is_first_section_relro): New function.
(Output_segment::maximum_alignment): If there is a relro section,
align the segment to the common page size.
(Output_segment::set_section_addresses): Track whether we are
looking at relro sections. If the last section is a relro
section, align to the common page size.
(Output_segment::set_section_list_addresses): Add in_relro
parameter. Change all callers. Align to the page size when
moving from relro to non-relro section.
(Output_segment::set_offset): Align memsz of a PT_GNU_RELRO
segment.
* output.h (class Output_section): Add is_relro_ and
is_relro_local_ fields.
(Output_section::is_relro): New function.
(Output_section::set_is_relro): New function.
(Output_section::is_relro_local): New function.
(Output_section::set_is_relro_local): New function.
(class Output_segment): Update declarations.
* i386.cc (Target_i386::got_section): Mark .got section as relro.
* sparc.cc (Target_sparc::got_section): Likewise.
* x86_64.cc (Target_x86_64::got_section): Likewise.
* testsuite/relro_test_main.cc: New file.
* testsuite/relro_test.cc: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add relro_test.
(relro_test_SOURCES, relro_test_DEPENDENCIES): New variables.
(relro_test_LDFLAGS, relro_test_LDADD): New variables.
(relro_test.so, relro_test_pic.o): New targets.
* testsuite/Makefile.in: Rebuild.