* arm.cc (Insn_template::Type): New enum value THUMB16_SPECIAL_TYPE.
(Insn_template::thumb16_bcond_insn): New method declaration.
(Insn_template): Fix spelling.
(Stub::thumb16_special): New method declaration.
(Stub::do_write): Define virtual method which was previously pure
virtual.
(Stub::do_thumb16_special): New method declaration.
(Stub::do_fixed_endian_write): New template member.
(Reloc_stub::do_write): Remove.
(Reloc_stub::do_fixed_endian_write): Remove.
(Cortex_a8_stub): New class definition.
(Stub_factory::make_cortex_a8_stub): New method definition.
(Stub_factory::Stub_factory): Add missing static storage class
qualifier for elf32_arm_stub_a8_veneer_blx.
(Garbage_collection::cident_sections): New function.
(Garbage_collection::add_cident_section): New function.
(Garbage_collection::cident_sections_): New member.
(gc_process_relocs): Add references to sections whose names are C
identifiers.
* gold.h (cident_section_start_prefix): New constant.
(cident_section_stop_prefix): New constant.
(is_cident): New function.
* layout.cc (Layout::define_section_symbols): Replace string constants
with the newly defined constants.
* object.cc (Sized_relobj::do_layout): Track sections whose names are
C identifiers.
* testsuite/Makefile.am: Add gc_orphan_section_test.
* testsuite/Makefile.in: Regenerate.
* testsuite/gc_orphan_section_test.cc: New file.
* testsuite/gc_orphan_section_test.sh: New file.
* options.cc (General_options::parse_section_start): New function.
(General_options::section_start): New function.
(General_options::General_options): Initialize all members.
* options.h: Include <map>
(class General_options): Add --section-start. Add section_starts_
member.
* layout.cc (Layout::attach_allocated_section_to_segment): If
--section-start was used, set the address of the segment. Remove
local sort_sections.
(Layout::relaxation_loop_body): If the address of the load segment
has been set by --section-start, don't use it.
* output.h (Output_segment::update_flags_for_output_section): New
function.
* output.cc (Output_segment::add_output_section): Call
update_flags_for_output_section.
to is_default_version. Rename insdef to insdefault.
(Symbol_table::add_from_relobj): Rename def to is_default_version
and local to is_forced_local.
(Symbol_table::add_from_pluginobj): Likewise.
(Symbol_table::add_from_dynobj): Likewise.
(Symbol_table::define_special_symbol): Rename insdef to
insdefault.
* options.h (class General_options): Add
--allow-multiple-definition and -z muldefs.
* resolve.cc (Symbol_table::should_override): Don't warn about a
multiple symbol definition if --allow-multiple-definition or -z
muldefs.
* options.h (class General_options): Add --add-needed and
--copy-dt-needed-entries. Tweak --as-needed help entry.
* object.cc (Input_objects::check_dynamic_dependencies): Give an
error if --copy-dt-needed-entries aka --add-needed is used and
would cause a change in behaviour.
check for .text or .gnu.linkonce.t sections.
* icf.cc (Icf::find_identical_sections): Ditto.
Change the detection for mangled function name within the section
name.
* icf.h (is_section_foldable_candidate): New function.
* common.cc (Sort_commons::operator()): Stabilize sort when both
entries are NULL.
(Symbol_table::do_allocate_commons_list): When allocating common
symbols, skip a symbol which is no longer common.
* symtab.h (Symbol::is_common): Test whether the symbol comes from
an object before checking its type.
* testsuite/common_test_2.c: New file.
* testsuite/common_test_3.c: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add common_test_2.
(common_test_2_SOURCES, common_test_2_DEPENDENCIES): Define.
(common_test_2_LDFLAGS, common_test_2_LDADD): Define.
(common_test_2_pic.o, common_test_2.so): New targets.
(common_test_3_pic.o, common_test_3.so): New targets.
* testsuite/Makefile.in: Rebuild.
* script.cc (read_input_script): If we see a new SECTIONS clause,
and we have added an input section, give an error.
* layout.h (class Layout): Add have_added_input_section function.
Add have_added_input_section_ field.
* layout.cc (Layout::Layout): Initialize
have_added_input_section_.
(Layout::layout): Set have_added_input_section_.
(Layout::layout_eh_frame): Likewise.
* symtab.cc (Symbol_table::add_from_relobj): When not exporting
symbols from this object, don't change the visibility of an
undefined symbol.
* testsuite/exclude_libs_test_1.c (lib1_ref): New function.
* script.h (class Version_script_info): Define Language enum.
Update declarations. Define Glob, Exact, and Lookup types. Add
new fields globals_, locals_, and is_finalized_.
* script.cc: Various formatting fixes.
(class Parser_closure): Change language_stack_ from a vector of
std::string to one of Version_script_info::Language. Adjust all
uses accordingly.
(class Lazy_demangler): Remove.
(struct Version_expression): Change language from std::string to
Version_script_info::Language.
(Version_script_info::Version_script_info): New function.
(Version_script_info::~Version_script_info): Don't call clear.
(Version_script_info::finalize): New function.
(Version_script_info::build_lookup_tables): New function.
(Version_script_info::build_expression_list_lookup): New
function.
(Version_script_info::get_symbol_version_helper): Rewrite to use
lookup tables.
(Version_script_info::print_expression_list): Adjust to use
Version_script_info::Language.
(script_push_lex_into_version_mode): Check that the version script
has not been finalized.
(version_script_push_lang): Change language string to
Version_script_info::Language.
* options.cc (Command_line::version_script): New function.
* options.h (class General_options): Add finalize_dynamic_list
function. Change version_script from declaration to definition.
* testsuite/ver_test_4.script: Remove duplicate def of t2_2.
* testsuite/version_script.map: Remove duplicate def of foo.
* testsuite/Makefile.am (ver_matching_def.so): Depend upon
version_script.map.
* testsuite/Makefile.in: Rebuild.
* options.h (class General_options): Add -x/--discard-all.
* object.cc (Sized_relobj::do_count_local_symbols): Handle
--discard-all. If the local symbol needs a dynamic entry, check
that before handling --discard-locals.
* output.cc (Output_segment::Output_segment): If PT_TLS, set the
flags to PF_R.
(Output_segment::add_output_section): Don't change the flags if
the type is PT_TLS.
* dynobj.cc (Dynobj::create_gnu_hash_table): Add symbols to the
GNU hash table if they need a dynamic value. Otherwise, don't add
them if they are defined in a dynamic object or are forced local.
* symtab.h (Symbol::needs_dynsym_entry): A symbol in both a
regular and a dynamic object only needs a dynamic symbol table
entry if it is externally visible.
* output.h (class Output_section): Add is_entsize_zero_ field.
* output.cc (Output_section::Output_section): Initialize
is_entsize_zero_.
(Output_section::set_entsize): If two different entsizes are
requested, force it to zero.
(Output_section::add_input_section): Set flags for .debug_str
before updating section flags. Set entsize.
(Output_section::update_flags_for_input_section): Set SHF_MERGE
and SHF_STRING if all input sections have those flags.
* arm.cc (Arm_relobj::scan_sections_for_stubs): Exclude ICF-eliminated
sections.
* object.cc (Sized_relobj::do_finalize_local_symbols): Handle
relaxed input sections.
* output.cc (Output_section::find_relaxed_input_section): Change
return type to Output_relaxed_input_section pointer. Adjust code
for new type of relaxed_input_section_map_.
* output.h (Output_section::find_relaxed_input_section): Change
return type to Output_relaxed_input_section pointer.
(Output_section::Output_relaxed_input_section_by_input_section_map):
New type.
(Output_section::relaxed_input_section_map_): Change type to
Output_section::Output_relaxed_input_section_by_input_section_map.
* symtab.cc (Symbol_table::compute_final_value): Handle relaxed
input section.
elfcpp/ChangeLog
* arm.h: New enums for EABI object attribute tags and values.
gold/ChangeLog
* arm.cc (attributes.h): New include.
(Arm_relobj::Arm_relobj): Initialize attributes_section_data_.
(Arm_relobj::~Arm_relobj): Delete object pointed by
attributes_section_data_.
(Arm_relobj::attributes_section_data): New method definition.
(Arm_relobj::attributes_section_data_): New data member declaration.
(Arm_dynobj::Arm_dynobj): Initialize attributes_section_data_.
(Arm_dynobj::~Arm_dynobj): Delete object pointed by
attributes_section_data_.
(Arm_dynobj::attributes_section_data): New method definition.
(Arm_dynobj::attributes_section_data_): New data member declaration.
(Target_arm::Target_arm): Initialize attributes_section_data_. Change
initialization value of may_use_blx_ to false.
(Target_arm::using_thumb2, Target_arm::using_thumb_only,
Target_arm::may_use_arm_nop, Target_arm::may_use_thumb2_nop): Use
object attributes to compute results instead of hard-coding.
(Target_arm::do_attribute_arg_type, Target_arm::do_attributes_order,
Target_arm::get_secondary_compatible_arch,
Target_arm::set_secondary_compatible_arch
Target_arm::tag_cpu_arch_combine, Target_arm::aeabi_enum_name,
Target_arm::tag_cpu_name_value, Target_arm::merge_object_attributes):
New method declarations.
(Target_arm::get_aeabi_object_attribute): New method definition.
(Target_arm::attributes_section_data_): New data member declaration.
(read_arm_attributes_section): New template definition.
(Arm_relobj::do_read_symbols): Read attributes section if it exists.
(Arm_dynobj::do_read_symbols): Ditto.
(Target_arm::do_finalize_sections): Merge attributes sections from
input. Check for BLX use after attributes section merging.
Fix __exidx_start and __exidx_end visibility. Create an
.ARM.attributes section if necessary.
(Target_arm::get_secondary_compatible_arch,
Target_arm::set_secondary_compatible_arch,
Target_arm::tag_cpu_arch_combine, Target_arm::aeabi_enum_name,
Target_arm::tag_cpu_name_value, Target_arm::merge_object_attributes,
Target_arm::do_attribute_arg_type, Target_arm::do_attributes_order):
New method definitions.
PR gold/10893
* i386.cc (Target_i386::Scan::globa): Use is_func instead of
checking elfcpp::STT_FUNC.
(Target_i386::Relocate::relocate): Likewise.
* x86_64.cc (Target_x86_64::Scan::global): Likewise.
* symtab.cc (Symbol_table::sized_write_symbol): Turn IFUNC
symbols from shared libraries into normal FUNC symbols.
* symtab.h (Symbol): Add is_func and use it.
* arm.cc: Update comments about interworking and stub generation.
(Target_arm::Relocate::reloc_is_non_pic): Update list of relocations
considered as non-PIC.
(Arm_relocate_functions::base_abs): Fix formatting.
(Arm_relocate_functions::got_prel): Fix comment. Change interface
of function to use GOT entry address instead of offset.
(Target_arm::Scan::global): Issue an error if a symbol would need a
PLT does not get one because it is untyped. Remove code to create
dynamic symbols for relative branches.
(Target_arm::Relocate::relocate: Use 0 instead of false since function
takes unsigned integer instead of boolean.
* arm.cc: Remove comment about missing .ARM.exidx section symbols.
(Target_arm::do_finalize_sections): Add parameter for symbol table
pointer. Add __exidx_start and __exidx_end symbols as appropriate.
* i386.cc (Target_i386::do_finalize_sections): Add an additional
parameter for symbol table pointer.
* layout.cc (Layout::finalize): Call Target::finalize_sections with
an additional parameter for a pointer to symbol table.
* powerpc.cc (Target_powerpc::do_finalize_sections): Add an additional
parameter for a symbol table pointer.
* sparc.cc (Target_sparc::do_finalize_sections): Ditto.
* target.h (Target::finalize_sections, Target::do_finalize_sections):
Ditto.
* x86_64.cc (Target_x86_64::do_finalize_sections): Add an additional
parameter for a symbol table pointer.
* incremental-dump.cc (main): Check that the offeset of a script is 0.
* incremental.cc (Incremental_inputs::sized_create_inputs_section_data):
Write 0 for the data_offset of scripts.
Revert:
2009-11-25 Doug Kwan <dougkwan@google.com>
* arm.cc (Target_arm::Target_arm): Move method definition
outside of class definition. Add code to handle
--target1-rel, --target1-abs and --target2= options.
(Target_arm::get_reloc_reloc_type): Change method to be
non-static and const.
(Target_arm::target1_is_rel_, Target_arm::target2_reloc_):
New data member declaration.
(Target_arm::Scan::local, Target_arm::Scan::global,
Target_arm::Relocate::relocate,
Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
Adjust call to Target_arm::get_real_reloc_type.
(Target_arm::get_real_reloc_type): Use command line options
to determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
* options.h (--target1-rel, --target1-abs, --target2): New
ARM-only options.
* arm.cc (Target_arm::Target_arm): Move method definition outside of
class definition. Add code to handle --target1-rel, --target1-abs
and --target2= options.
(Target_arm::get_reloc_reloc_type): Change method to be non-static
and const.
(Target_arm::target1_is_rel_, Target_arm::target2_reloc_): New data
member declaration.
(Target_arm::Scan::local, Target_arm::Scan::global,
Target_arm::Relocate::relocate,
Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Adjust
call to Target_arm::get_real_reloc_type.
(Target_arm::get_real_reloc_type): Use command line options to
determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
* options.h (--target1-rel, --target1-abs, --target2): New ARM-only
options.
* arm.cc (Target_arm::Target_arm): Move method definition outside of
class definition. Add code to handle --target1-rel, --target1-abs
and --target2= options.
(Target_arm::get_reloc_reloc_type): Change method to be non-static
and const.
(Target_arm::target1_is_rel_, Target_arm::target2_reloc_): New data
member declaration.
(Target_arm::Scan::local, Target_arm::Scan::global,
Target_arm::Relocate::relocate,
Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Adjust
call to Target_arm::get_real_reloc_type.
(Target_arm::get_real_reloc_type): Use command line options to
determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
* options.h (--target1-rel, --target1-abs, --target2): New ARM-only
options.
* incremental.cc (Incremental_inputs_header,
Incremental_inputs_header_write, Incremental_inputs_entry,
Incremental_inputs_entry_write): Add a typedef with the data type.
* incremental.cc (Incremental_inputs_header,
Incremental_inputs_header_write, Incremental_inputs_entry,
Incremental_inputs_entry_write): Update comment about which
type has the filed descriptions.
* arm.cc (Target_arm::may_use_arm_nop): New method definition.
(Arm_relocate_functions::arm_branch_common): Change method defintion
in class definition to a method declaration and update list of formal
parameters.
(Arm_relocate_functions::plt32, Arm_relocate_functions::call,
Arm_relocation_functions::jump24): Adjust call to
Arm_relocate_functions::arm_branch_common. Update list of formal
parameters.
(Arm_relocate_functions::xpc25): New method definition.
(Arm_relocate_functions::arm_branch_common): Move method defintion
out from class definition. Use stubs for mode-switching and extending
branch ranges.
(Target_arm::Relocate::relocate): Handle weakly-undefined symbols
specially. Change code to enable use of stubs in ARM branches.
* arm.cc (Arm_relobj::do_relocate_sections): Remove options parameter
in method declaration.
(Target_arm::relocate_stub): New method declaration.
(Target_arm::default_target): Change to return a pointer instead of
a const reference.
(Reloc_stub::stub_type_for_reloc): Adjust for the change in
Target_arm::default_target.
(Arm_Relobj::do_relocate_sections): Remove options paramater in
method definition.
(Target_arm::relocate_section): Adjust view.
(Target_arm::relocate_stub): New method definition.
* i386.cc (Target_i386::do_calls_non_split): Add a cast to avoid
a format warning.
* incremental.cc (open_incremental_binary): Initialized local
variables to avoid warnings.
* object.cc (make_elf_object): Ditto.
* x86_64.cc (Target_x86_64::do_calls_non_split): Add a cast to avoid
a format warning.
* arm.cc (Target_arm::fake_relnum_for_stubs): New constant.
(arm_symbol_value): Remove.
(Arm_relocate_functions::arm_branch_common,
Arm_relocate_functions::abs8, Arm_relocate_functions::thm_abs5,
Arm_relocate_functions::abs12, Arm_relocate_functions::abs16,
Arm_relocate_functions::abs32, Arm_relocate_functions::rel32,
Arm_relocate_functions::thm_call, Arm_relocate_functions::plt32,
Arm_relocate_functions::call, Arm_relocate_functions::jump24,
Arm_relocate_functions::prel31, Arm_relocate_functions::mov_abs_nc,
Arm_relocate_functions::movt_abs, Arm_relocate_functions::movw_abs_nc,
Arm_relocate_functions::thm_mobw_abs_nc,
Arm_relocate_functions::thm_mov_abs,
Arm_relocate_functions::movw_prel_nc,
Arm_relocate_functions::thm_movt_abs,
Arm_relocate_functions::movt_prel,
Arm_relocate_functions::thm_movw_prel_nc,
Arm_relocate_functions::thm_movt_prel): Adjust callers of the above.
(Target_arm::Relocate::relocate): Only decompose address into two
parts if relocation type uses the thumb-bit and pass the actual
bit instead of a flag indicating that the thumb-bit is used. Adjust
calls to methods in Arm_relocate_functions for this change.
* arm.cc (class Reloc_stub): Correct a comment.
(Target_arm::Target_arm): Initialize arm_input_section_map_.
(Target_arm::scan_section_for_stubs): New method declaration.
(Target_arm::do_make_elf_object, Target_arm::do_make_output_section):
Change methods from private to protected.
(Target_arm::do_may_relax): New method definition.
(Target_arm::do_relax, Target_arm::group_sections,
Target_arm::scan_reloc_for_stub,
Target_arm::scan_reloc_section_for_stubs): New method declarations.
(Target_arm::arm_input_section_map_): New data member declaration.
(Target_arm::scan_reloc_for_stub,
Target_arm::scan_reloc_section_for_stubs,
Target_arm::scan_section_for_stubs, Target_arm::group_sections,
Target_arm::do_relax): New method definitions.
* object.h (class Object): Add is_needed and set_is_needed
methods. Add is_needed_ field. Make bool fields into bitfields.
* symtab.cc (Symbol_table::set_dynsym_indexes): If a symbol is
defined in a dynamic object and referenced by a regular object,
set is_needed for the dynamic object.
* layout.cc (Layout::finish_dynamic_section): Don't add DT_NEEDED
if the file is marked with as_needed and it is not needed.
* options.h (class General_options): Add --warn-common.
* resolve.cc (Symbol_table::resolve): Handle --warn-common when
merging two common symbols.
(Symbol_table::should_override): Handle --warn-common when merging
a common symbol with a defined symbol. Use report_resolve_problem
for multiple definitions.
(Symbol_table::report_resolve_problem): New function.
* symtab.h (class Symbol_table): Declare report_resolve_problem.
* arm.cc (Target_arm::Target_arm): Initialize stub_tables_ and
stub_factory_.
(Target_arm::stub_factory): New method definition.
(Target_arm::new_arm_input_section,
Target_arm::find_arm_input_section, Target_arm::new_stub_table,
Target_arm::reloc_uses_thumb_bit): New method declarations.
(Target_arm::Stub_table_list, Target_arm::Arm_input_section_map):
New type definitions.
(Target_arm::stub_tables_, Target_arm::stub_factory_): New data
member declarations.
(Target_arm::reloc_uses_thumb_bit, Target_arm::new_arm_input_section,
Target_arm::find_arm_input_section, Target_arm::new_stub_table):
New method definitions.
* po/Make-in ($(srcdir)/$(PACKAGE).pot): Pass -C and
--msgid-bugs-address.
(install-pdf): New target.
(install-data_yes): Look up one directory to find mkinstalldirs.
* arm.cc (Stub_addend_reader): New struct template definition
and partial specializations.
(Stub_addend_reader::operator()): New method definition for a
partially specialized template.
* 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.