1. 20 Sep, 2019 1 commit
    • Alan Modra's avatar
      [GOLD] Fix spurious "plugin needed to handle lto object" warnings · 0a9fdbbf
      Alan Modra authored
      lto_slim_object_ was unitialized.  I also thought it worth adding
      a sanity check on the .gnu.lto_.lto.* section size, and made some
      other tidies.
      	PR 24768
      	* layout.cc (Layout::Layout): Init lto_slim_object_.
      	* object.cc (Sized_relobj_file::do_layout): Wrap overlong line.
      	Don't use C cast.  Validate section size.  Don't copy contents.
      (cherry picked from commit 4c51daca)
  2. 13 Jul, 2019 1 commit
    • Alan Modra's avatar
      [GOLD] PowerPC notoc eh_frame · 220f9906
      Alan Modra authored
      When generating notoc call and branch stubs without the benefit of
      pc-relative insns, the stubs need to use LR to access the run time PC.
      All LR changes must be described in .eh_frame if we're to support
      unwinding through asynchronous exceptions.  That's what this patch
      The patch has gone through way too many iterations.  At first I
      attempted to add multiple FDEs, one for each stub.  That ran into
      difficulties with do_plt_fde_location which is only capable of setting
      the address of a single FDE per Output_data section, and with removing
      any FDEs added on a previous do_relax pass.  Removing FDEs (git commit
      be897fb7) went overboard in matching the FDE contents.  That means
      either stashing the contents created for add_eh_frame_for_plt to use
      when calling remove_eh_frame_for_plt, or recreating contents on the
      fly (*) just to remove FDEs.  In fact, FDE content matching is quite
      unnecesary.  FDEs added by a previous do_relax pass are those with
      u_.from_linker.post_map set.  So they can easily be recognised just by
      looking at that flag.  This patch keeps that part of the multiple FDE
      In the end I went for just one FDE per stub group to describe the call
      stubs.  That's reasonably efficient for the common case of only
      needing to describe the __tls_get_addr_opt call stub.  We don't expect
      to be making many calls using notoc stubs without pc-relative insns.
      *) Which has it's own set of problems.  The contents must be recreated
      using the old stub layout, but .eh_frame size can affect stub
      requirements so you need to temporarily keep the old .eh_frame size
      when creating new stubs, then reset .eh_frame size before adding new
      	* ehframe.cc (Fde::operator==): Delete.
      	(Cie::remove_fde): Delete.
      	(Eh_frame::remove_ehframe_for_plt): Delete fde_data and fde_length
      	parameters.  Remove all post-map plt FDEs.
      	* ehframe.h (Fde:post_map): Make const, add variant to compare plt.
      	(Fde::operator==): Delete.
      	(Cie::remove_fde): Implement here.
      	(Cie::last_fde): New accessor.
      	(Eh_frame::remove_ehframe_for_plt): Update prototype.
      	* layout.cc (Layout::remove_eh_frame_for_plt): Delete fde_data and
      	fde_length parameters.
      	* layout.h (Layout::remove_eh_frame_for_plt): Update prototype.
      	* powerpc.cc (Stub_table::tls_get_addr_opt_bctrl_): Delete.
      	(Stub_table::plt_fde_len_, plt_fde_, init_plt_fde): Delete.
      	(Stub_table::add_plt_call_entry): Don't set tls_get_addr_opt_bctrl_.
      	(eh_advance): New function.
      	(stub_sort): New function.
      	(Stub_table::add_eh_frame): Emit eh_frame for notoc plt calls and
      	branches as well as __tls_get_addr_opt plt call stub.
      	(Stub_table::remove_eh_frame): Update to suit.
  3. 01 Jan, 2019 1 commit
  4. 30 Jul, 2018 1 commit
  5. 23 Jun, 2018 1 commit
    • Cary Coutant's avatar
      Update support for .note.gnu.property sections. · a2575bec
      Cary Coutant authored
      The original patch did not give the target enough hooks to discover that
      an input object file does not have a particular property. For the
      GNU_PROPERTY_X86_FEATURE_1_AND property, for example, where a missing
      property should be assumed to be all zeroes, and ANDed with other
      object modules, this is essential. We now store the target-specific
      properties locally in the Target structure as native uint32_t fields,
      then AND the per-object feature bits with the program's feature bits
      when we're finished processing each input object file. The target-specific
      properties are then added back to the output note section during
      	PR gold/22914
      	* layout.cc (read_sized_value): Fix spelling of section name.
      	(Layout::layout_gnu_property): Call Sized_target::record_gnu_property
      	for target-specific properties;
      	don't store them with target-independent properties yet.
      	(Layout::merge_gnu_properties): New method.
      	(Layout::add_gnu_property): New method.
      	(Layout::create_gnu_properties_note): Call target to finalize
      	target-specific properties. Fix spelling of output section name.
      	* layout.h (Layout::merge_gnu_properties): New method.
      	(Layout::add_gnu_property): New method.
      	* object.cc (Sized_relobj_file::do_layout): Call
      	* target.h (Target::merge_gnu_property): Remove.
      	(Target::finalize_gnu_properties): New method.
      	(Target::do_merge_gnu_property): Move to Sized_target and rename.
      	(Target::do_finalize_gnu_properties): New virtual method.
      	(Sized_target::record_gnu_property): Moved and renamed from
      	(Sized_target::merge_gnu_properties): New virtual method.
      	* x86_64.cc (Target_x86_64::isa_1_used_, isa_1_needed_)
      	(feature_1_, object_feature_1_, seen_first_object_): New data members.
      	(Target_x86_64::do_merge_gnu_property): Rename to ...
      	(Target_x86_64::record_gnu_property): ... this.  Save target-specific
      	properties in Target class object.
      	(Target_x86_64::merge_gnu_properties): New method.
      	(add_property): New static inline function.
      	(Target_x86_64::do_finalize_gnu_properties): New method.
      	* testsuite/Makefile.am (gnu_property_test): Remove C source file;
      	link directly without compiler driver.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/gnu_property_a.S: Add _start.
  6. 22 Jun, 2018 1 commit
    • Cary Coutant's avatar
      Add support for .note.gnu.property sections. · 6c04fd9b
      Cary Coutant authored
      	PR gold/22914
      	* elfcpp.h (NT_GNU_PROPERTY_TYPE_0): New note type.
      	(GNU_PROPERTY_*): New Gnu property types.
      	* x86_64.h (GNU_PROPERTY_X86_FEATURE_1_IBT)
      	(GNU_PROPERTY_X86_FEATURE_1_SHSTK): New x86 feature bits.
      	PR gold/22914
      	* layout.cc (Layout::Layout): Initialize gnu_properties_.
      	(read_sized_value, write_sized_value): New functions.
      	(Layout::layout_gnu_property): New method.
      	(Layout::create_notes): Call create_gnu_properties_note.
      	(Layout::create_gnu_properties_note): New method.
      	* layout.h (Layout::layout_gnu_property): New method.
      	(Layout::create_gnu_properties_note): New method.
      	(Layout::Gnu_property, Layout::Gnu_properties): New types.
      	(Layout::gnu_properties_): New data member.
      	* object.cc (Sized_relobj_file::layout_gnu_property_section): New
      	(Sized_relobj_file::do_layout): Handle .note.gnu.property sections.
      	* object.h (Sized_relobj_file::layout_gnu_property_section): New
      	* target.h (Target::merge_gnu_property): New method.
      	(Target::do_merge_gnu_property): New virtual method.
      	* x86_64.cc (Target_x86_64::do_merge_gnu_property): New method.
      	* testsuite/Makefile.am (gnu_property_test): New test case.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/gnu_property_a.S: New source file.
      	* testsuite/gnu_property_b.S: New source file.
      	* testsuite/gnu_property_c.S: New source file.
      	* testsuite/gnu_property_main.c: New source file.
      	* testsuite/gnu_property_test.sh: New test script.
  7. 03 Apr, 2018 1 commit
    • Cary Coutant's avatar
      Fix problem where mixed section types can cause internal error during a -r link. · bce5a025
      Cary Coutant authored
      During a -r (or --emit-relocs) link, if two sections had the same name but
      different section types, gold would put relocations for both sections into
      the same relocation section even though the data sections remained separate.
      For .eh_frame sections, when one section is PROGBITS and another is
      X86_64_UNWIND, we really should be using the UNWIND section type and
      combining the sections anyway.  For other sections, we should be
      creating one relocation section for each output data section.
      	PR gold/23016
      	* incremental.cc (can_incremental_update): Check for unwind section
      	* layout.h (Layout::layout): Add sh_type parameter.
      	* layout.cc (Layout::layout): Likewise.
      	(Layout::layout_reloc): Create new output reloc section if data
      	section does not already have one.
      	(Layout::layout_eh_frame): Check for unwind section type.
      	(Layout::make_eh_frame_section): Use unwind section type for .eh_frame
      	and .eh_frame_hdr.
      	* object.h (Sized_relobj_file::Shdr_write): New typedef.
      	(Sized_relobj_file::layout_section): Add sh_type parameter.
      	(Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type
      	* object.cc (Sized_relobj_file::check_eh_frame_flags): Check for
      	unwind section type.
      	(Sized_relobj_file::layout_section): Add sh_type parameter; pass it
      	to Layout::layout.
      	(Sized_relobj_file::do_layout): Make local copy of sh_type.
      	Force .eh_frame sections to unwind section type.
      	Pass sh_type to layout_section.
      	(Sized_relobj_file<size, big_endian>::do_layout_deferred_sections):
      	Pass sh_type to layout_section.
      	* output.cc (Output_section::Output_section): Initialize reloc_section_.
      	* output.h (Output_section::reloc_section): New method.
      	(Output_section::set_reloc_section): New method.
      	(Output_section::reloc_section_): New data member.
      	* target.h (Target::unwind_section_type): New method.
      	(Target::Target_info::unwind_section_type): New data member.
      	* aarch64.cc (aarch64_info): Add unwind_section_type.
      	* arm.cc (arm_info, arm_nacl_info): Likewise.
      	* i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise.
      	* mips.cc (mips_info, mips_nacl_info): Likewise.
      	* powerpc.cc (powerpc_info): Likewise.
      	* s390.cc (s390_info): Likewise.
      	* sparc.cc (sparc_info): Likewise.
      	* tilegx.cc (tilegx_info): Likewise.
      	* x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise.
      	* testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/testfile.cc: Add unwind_section_type.
      	* testsuite/pr23016_1.sh: New test script.
      	* testsuite/pr23016_1a.s: New source file.
      	* testsuite/pr23016_1b.s: New source file.
      	* testsuite/pr23016_2.sh: New test script.
      	* testsuite/pr23016_2a.s: New source file.
      	* testsuite/pr23016_2b.s: New source file.
  8. 07 Mar, 2018 1 commit
    • Sriraman Tallam's avatar
      New option -z,keep-text-section prefix. · 779bdadb
      Sriraman Tallam authored
      This option does not merge certain text sections with prefixes
      .text.hot, .text.unlikely, .text.startup and .text.exit.
      	* layout.cc (Layout::default_section_order): Check for text section
      	(Layout::text_section_name_mapping): New static member.
      	(Layout::text_section_name_mapping_count): New static member.
      	(Layout::match_section_name): New static function.
      	(Layout::output_section_name): Check for text section prefixes.
      	* layout.h (Output_section_order::ORDER_TEXT_HOT): New enum value.
      	(Output_section_order::ORDER_TEXT_STARTUP): New enum value.
      	(Output_section_order::ORDER_TEXT_EXIT): New enum value.
      	(Output_section_order::ORDER_TEXT_UNLIKELY): New enum value.
      	(Layout::text_section_name_mapping): New static member.
      	(Layout::text_section_name_mapping_count): New static member.
      	(Layout::match_section_name): New static function.
      	* options.h (keep_text_section_prefix): New -z option.
      	* testsuite/Makefile.am (keep_text_section_prefix): New test.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/keep_text_section_prefix.cc: New test source.
      	* testsuite/keep_text_section_prefix.sh: New test script.
  9. 03 Jan, 2018 1 commit
  10. 09 Nov, 2017 1 commit
    • H.J. Lu's avatar
      gold: Ignore def/ref from a dynamic object for special symbols · dc8d2d90
      H.J. Lu authored
      Since special symbol must be defined in a regular object, definition
      from a dynamic object should be ignored.  If special symbol has the
      hidden or internal visibility, reference from a dynamic object should
      also be ignored.  Also __start and __stop symbols in a dynamic object
      shouldn't be preempted.
      	PR gold/22291
      	* layout.cc (Layout::define_section_symbols): Use STV_PROTECTED
      	for __start and __stop symbols.
      	* symtab.cc (Symbol_table::define_special_symbol): Add an
      	argument, visibility.  Ignore definition and reference from
      	a dynamic object, depending on visibility.
      	(Symbol_table::do_define_in_output_data): Pass visibility to
      	(Symbol_table::do_define_in_output_segment): Likewise.
      	(Symbol_table::do_define_as_constant): Likewise.
      	(Symbol_table::add_undefined_symbol_from_command_line): Pass
      	STV_DEFAULT to define_special_symbol.
      	* symtab.h (Symbol_table::define_special_symbol): Add an
      	argument, visibility.
  11. 20 Oct, 2017 1 commit
    • Sriraman Tallam's avatar
      New gold linker option -z,text-unlikely-segment. · 3b4190cc
      Sriraman Tallam authored
      2017-10-04  Sriraman Tallam  <tmsriram@google.com>
      	* options.h (-z,text_unlikely_segment): New option.
      	* layout.cc (Layout::layout): Create new output section
      	for .text.unlikely sections with the new option.
      	(Layout::segment_precedes): Check for the new option
      	when segment flags match.
      	* testsuite/text_unlikely_segment.cc: New test source.
      	* testsuite/text_unlikely_segment.sh: New test script.
      	* testsuite/Makefile.am (text_unlikely_segment): New test.
      	* testsuite/Makefile.in: Regenerate.
  12. 01 Aug, 2017 1 commit
    • Alan Modra's avatar
      [GOLD] PowerPC recreate eh_frame for stubs on each relax pass · be897fb7
      Alan Modra authored
      There is a very small but non-zero probability that a stub group
      contains stubs on one relax pass, but does not on the next.  In that
      case we would get an FDE covering a zero length address range.
      (Actually, it's even worse.  Alignment padding for stubs can mean the
      address for the non-existent stubs is past the end of the original
      section to which stubs are attached, and due to the way
      do_plt_fde_location calculates the length we can get a negative
      length.)  Fixing this properly requires removing the FDE.
      Also, I have been implementing the __tls_get_addr_opt support for
      gold, and that stub needs something other than the default FDE.  The
      necessary FDE will depend on the offset to the __tls_get_addr_opt
      stub, which of course can change during relaxation.  That means at the
      very least, rewriting the FDE on each pass, possibly changing the FDE
      size.  I think that is better done by completely recreating PLT
      eh_frame FDEs.
      	* ehframe.cc (Fde::operator==): New.
      	(Cie::remove_fde, Eh_frame::remove_ehframe_for_plt): New.
      	* ehframe.h (Fde::operator==): Declare.
      	(Cie::remove_fde, Eh_frame::remove_ehframe_for_plt): Likewise.
      	* layout.cc (Layout::remove_eh_frame_for_plt): New.
      	* layout.h (Layout::remove_eh_frame_for_plt): Declare.
      	* powerpc.cc (Target_powerpc::do_relax): Remove old eh_frame FDEs.
      	(Stub_table::add_eh_frame): Delete eh_frame_added_ condition.
      	Don't add eh_frame for empty stub section.
      	(Stub_table::remove_eh_frame): New.
  13. 18 Jul, 2017 1 commit
  14. 15 May, 2017 1 commit
  15. 02 Jan, 2017 1 commit
  16. 23 Dec, 2016 1 commit
    • Cary Coutant's avatar
      Fix placement of forced local symbols in the dynamic symbol table. · c4d5a762
      Cary Coutant authored
      Gold was not placing forced-local symbols (e.g., hidden visibility)
      at the front of the dynamic symbol table, or including them in the
      count of local symbols recorded in the .dynsym section's sh_info field.
      	* layout.cc (Layout::finalize): Track count of forced-local symbols
      	in .dynsym.
      	(Layout::create_symtab_sections): Add local_dynamic_count parameter;
      	use that instead of sh_info value.
      	(Layout::create_dynamic_symtab): Add pforced_local_dynamic_count
      	parameter; pass it to Symtab::set_dynsym_indexes().  Include forced
      	locals in sh_info value.  Pass index of first real global to
      	Dynobj::create_gnu_hash_table() and Dynobj::create_elf_hash_table().
      	* layout.h (Layout::create_symtab_sections): Add local_dynamic_count
      	(Layout::create_dynamic_symtab): Add pforced_local_dynamic_count
      	* symtab.cc (Symbol_table::set_dynsym_indexes): Add pforced_local_count
      	parameter.  Process forced-local symbols first and return the count.
      	(Symbol_table::finalize): Update comments.
      	* symtab.h (Symbol_table::set_dynsym_indexes): Add pforced_local_count
      	(Symbol_table::first_dynamic_global_index_): Update comment.
      	(Symbol_table::dynamic_count_): Update comment.
      	* testsuite/Makefile.am (ifuncmod1.sh): New test case.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/ifuncmod1.sh: New shell script.
  17. 20 Dec, 2016 1 commit
    • Cary Coutant's avatar
      Fix problem where linker does not place .note sections according to script. · 412ffd83
      Cary Coutant authored
      	PR gold/14676
      	PR gold/20983
      	* layout.h (Layout::choose_output_section): Add match_input_spec
      	parameter. Adjust all callers.
      	* layout.cc (Layout::choose_output_section): Likewise.  Pass
      	match_input_spec to Script_sections::output_section_name().
      	(Layout::create_note): Pass true for match_input_spec.
      	* script-sections.h (Script_sections::output_section_name): Add
      	match_input_spec parameter.
      	* script-sections.cc (Sections_element::output_section_name): Likewise.
      	(Output_section_definition::output_section_name): Likewise.
      	(Script_sections::output_section_name): Likewise.
  18. 13 Dec, 2016 1 commit
    • Cary Coutant's avatar
      Do not use linker script to place static relocation sections. · 03fb64f8
      Cary Coutant authored
      	PR gold/20522
      	* layout.cc (Layout::choose_output_section): Add is_reloc parameter.
      	Adjust all callers.  Do not use linker script for is_reloc sections.
      	(Layout::layout_reloc): Pass is_reloc == true.
      	* layout.h (Layout::choose_output_section): Add is_reloc parameter.
  19. 27 Nov, 2016 1 commit
    • Ambrogino Modigliani's avatar
      Fix spelling in comments in C source files (gold) · 5c3024d2
      Ambrogino Modigliani authored
      	* aarch64.cc: Fix spelling in comments.
      	* arm.cc: Fix spelling in comments.
      	* icf.cc: Fix spelling in comments.
      	* layout.cc: Fix spelling in comments.
      	* layout.h: Fix spelling in comments.
      	* mips.cc: Fix spelling in comments.
      	* output.h: Fix spelling in comments.
      	* plugin.h: Fix spelling in comments.
      	* script-sections.h: Fix spelling in comments.
      	* script.h: Fix spelling in comments.
      	* stringpool.h: Fix spelling in comments.
      	* tilegx.cc: Fix spelling in comments.
  20. 21 Nov, 2016 1 commit
    • Igor Kudrin's avatar
      Add --build-id=uuid support for MinGW32. · b32e1756
      Igor Kudrin authored
      2016-11-21  Igor Kudrin  <ikudrin@accesssoftek.com>
      	* layout.cc: Include windows.h and rpcdce.h (for MinGW32).
      	(Layout::create_build_id): Generate uuid using UuidCreate().
  21. 24 Aug, 2016 1 commit
    • Roland McGrath's avatar
      [gold] Implement -z stack-size option · 1130c90e
      Roland McGrath authored
      	* options.h (General_options): Grok -z stack-size.
      	* output.h (Output_segment::set_size): New method.
      	* layout.cc (Layout::create_executable_stack_info): Renamed to ...
      	(Layout::create_stack_segment): ... this.  Always create the
      	segment if -z stack-size was used.
      	(Layout::set_segment_offsets): Don't call ->set_offset on the
      	PT_GNU_STACK segment.
  22. 04 Mar, 2016 1 commit
    • Cary Coutant's avatar
      Add support for STT_SPARC_REGISTER symbols. · dc1c8a16
      Cary Coutant authored
      	PR gold/19019
      	* layout.h (Layout::add_target_specific_dynamic_tag): New function.
      	* layout.cc (Layout::add_target_specific_dynamic_tag): New function.
      	* mips.cc (Target_mips::make_symbol): Adjust function signature.
      	* sparc.cc (Target_sparc::Target_sparc): Initialize register_syms_.
      	(Target_sparc::do_is_defined_by_abi): Remove test for
      	(Target_sparc::Register_symbol): New struct type.
      	(Target_sparc::register_syms_): New data member.
      	(Target_sparc<64, true>::sparc_info): Set has_make_symbol to true.
      	(Target_sparc::make_symbol): New function.
      	(Target_sparc::do_finalize_sections): Add register symbols and new
      	dynamic table entries.
      	* symtab.h (Sized_symbol::init_undefined): Add value parameter.
      	(Symbol_table::add_target_global_symbol): New function.
      	(Symbol_table::target_symbols_): New data member.
      	* symtab.cc (Sized_symbol::init_undefined): Add value parameter.
      	(Symbol_table::Symbol_table): Initialize target_symbols_.
      	(Symbol_table::add_from_object): Pass additional parameters to
      	(Symbol_table::define_special_symbol): Likewise.
      	(Symbol_table::add_undefined_symbol_from_command_line): Pass 0 for
      	undefined symbol value.
      	(Symbol_table::set_dynsym_indexes): Process target-specific symbols.
      	(Symbol_table::sized_finalize): Likewise.
      	(Symbol_table::sized_write_globals): Likewise.
      	* target.h (Sized_target::make_symbol): Add name, st_type, object,
      	st_shndx, and value parameters.
  23. 01 Jan, 2016 1 commit
  24. 28 Oct, 2015 1 commit
    • Marcin Kościelnicki's avatar
      Support 64-bit entry size in SHT_HASH (for s390). · 8d9743bd
      Marcin Kościelnicki authored
      	* dynobj.cc (Dynobj::create_elf_hash_table): Create hash table with
      	target-specific entry size.
      	(Dynobj::sized_create_elf_hash_table): Add size template parameter.
      	* dynobj.h (Dynobj::sized_create_elf_hash_table): Likewise.
      	* layout.cc (Layout::create_dynamic_symtab): Set entsize to
      	* target.h (Target::hash_entry_size): New method.
      	(Target::Target_info::hash_entry_size): New data member.
      	* aarch64.cc (Target_aarch64::aarch64_info): Add hash_entry_size.
      	* arm.cc (Target_arm::arm_info): Likewise.
      	(Target_arm_nacl::arm_nacl_info): Likewise.
      	* i386.cc (Target_i386::i386_info): Likewise.
      	(Target_i386_nacl::i386_nacl_info): Likewise.
      	(Target_iamcu::iamcu_info): Likewise.
      	* mips.cc (Target_mips::mips_info): Likewise.
      	(Target_mips_nacl::mips_nacl_info): Likewise.
      	* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
      	* sparc.cc (Target_sparc::sparc_info): Likewise.
      	* tilegx.cc (Target_tilegx::tilegx_info): Likewise.
      	* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
      	(Target_x86_64_nacl::x86_64_nacl_info): Likewise.
      	* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
  25. 20 Jul, 2015 1 commit
    • H.J. Lu's avatar
      Clear SHF_COMPRESSED flag bit from input to output · f54f5e31
      H.J. Lu authored
      For relocatable link, we should clear the SHF_COMPRESSED flag bit from
      input group section.
      	PR gold/18689
      	* layout.cc (Layout::layout): Clear the SHF_COMPRESSED flag bit
      	from input group section for relocatable link.
      	* testsuite/Makefile.am (check_SCRIPTS): Add pr18689.sh.
      	(check_DATA): Add pr18689.stdout.
      	(MOSTLYCLEANFILES): Add pr18689a.o pr18689b.o.
      	(pr18689.stdout): New rule.
      	(pr18689a.o): Likewise.
      	(pr18689b.o): Likewise.
      	(pr18689.o): Likewise.
      	* testsuite/pr18689.c: New file.
      	* testsuite/pr18689.sh: Likewise.
      	* testsuite/Makefile.in: Regenerated.
  26. 12 Jul, 2015 1 commit
    • H.J. Lu's avatar
      Add SHF_COMPRESSED section decompression to gold · 48058663
      H.J. Lu authored
      This patch adds SHF_COMPRESSED section decompression to gold.
      	PR gold/18321
      	* compressed_output.h (decompress_input_section): Add arguments
      	for ELF class, big endian and sh_flags.
      	* compressed_output.cc (decompress_input_section): Likewise.
      	Support the SHF_COMPRESSED section.
      	* dynobj.h (Dynobj): Add elfsize and is_big_endian member
      	* plugin.h (Pluginobj): Likewise.
      	* layout.cc (Layout::get_output_section_flags): Also clear the
      	SHF_COMPRESSED bit.
      	* object.h (Compressed_section_info): Add flag to store sh_flags.
      	(Object): Add pure virtual elfsize and is_big_endian member
      	* object.cc (need_decompressed_section): Don't skip the ".zdebug"
      	prefix here.
      	(build_compressed_section_map): Check SHF_COMPRESSED for
      	uncompressed size.  Store sh_flags in Compressed_section_info.
      	Pass size, big_endian and sh_flags to decompress_input_section.
      	Skip the ".debug"/".zdebug" prefix when passing section name to
      	(Sized_relobj_file<size, big_endian>::do_find_special_section):
      	Don't check ".zdebug_*" sections.
      	(Object::decompressed_section_contents): Pass ELF class, big
      	endian and sh_flags to decompress_input_section.
      	* reloc.cc (Sized_relobj_file<size, big_endian>::write_sections):
      	* testsuite/Makefile.am (check_DATA): Add
      	debug_msg_cdebug_gabi.err and gdb_index_test_2_gabi.stdout.
      	(MOSTLYCLEANFILES): Add debug_msg_cdebug_gabi.err and
      	(debug_msg_cdebug_gabi.o): New.
      	(odr_violation1_cdebug_gabi.o): Likewise.
      	(odr_violation2_cdebug_gabi.o): Likewise.
      	(debug_msg_cdebug_gabi.err): Likewise.
      	(check_SCRIPTS): Add gdb_index_test_2_gabi.sh.
      	(gdb_index_test_cdebug_gabi.o): Likewise.
      	(gdb_index_test_2_gabi): Likewise.
      	(gdb_index_test_2_gabi.stdout): Likewise.
      	* testsuite/gdb_index_test_2_gabi.sh: New file.
      	* testsuite/Makefile.in: Regenerated.
  27. 11 Jun, 2015 1 commit
    • Cary Coutant's avatar
      Fix bug where SECTIONS clause does not handle compressed debug sections. · dd68f8fa
      Cary Coutant authored
      When laying out .debug_* sections, we translate the names of compressed
      debug sections that start with ".zdebug", but when processing input
      section specs in a linker script, we do not handle the translation there.
      This results in an internal error as reported in PR 17731.
      	PR gold/17731
      	* layout.cc (corresponding_uncompressed_section_name): New function.
      	(Layout::choose_output_section): Call it.
      	* layout.h (corresponding_uncompressed_section_name): New function.
      	* script-sections.cc (Input_section_info::set_section_name): Check
      	for compressed debug section (.zdebug style).
  28. 02 Jun, 2015 1 commit
    • Cary Coutant's avatar
      PR 17819: Fix --build-id=tree when using --compress-debug-sections. · 9c7fe3c5
      Cary Coutant authored
      When --build-id=tree is selected, gold would schedule a set of
      tasks to run to compute md5 hashes in parallel on chunks of the
      file. The scheduling was done before the
      Write_after_input_sections_task ran, so if we are compressing
      debug sections, the output file will change size and be remapped
      to a new address, sometimes causing the build id computation to
      crash, but even when it doesn't crash, it wouldn't include the
      debug information in the hash computation.
      This patch delays the scheduling of the md5 tasks until after
              PR gold/17819
              * gold.cc (queue_final_tasks): When --build-id=tree, queue a
              separate task to schedule the build id computation.
              * layout.cc (Hash_task::Hash_task): Remove build_id_blocker,
              add Output_file and offset.
              (Hash_task::run): Get and release the input views.
              (Hash_task::is_runnable): Always return NULL (always runnable).
              (Layout::queue_build_id_tasks): Remove.
              (Layout::write_build_id): Add array_of_hashes and size_of_hashes
              parameters; use them instead of class members.
              (Build_id_task_runner::run): New function.
              (Close_task_runner::run): Pass array_of_hashes and size_of_hashes
              to write_build_id.
              * layout.h (Layout::queue_build_id_tasks): Remove.
              (Layout::write_build_id): Add array_of_hashes and size_of_hashes
              (Layout::array_of_hashes_): Remove.
              (Layout::size_of_array_of_hashes_): Remove.
              (Layout::input_view_): Remove.
              (Build_id_task_runner): New class.
              (Close_task_runner::Close_task_runner): Add array_of_hashes and
              size_of_hashes parameters.
              (Close_task_runner::array_of_hashes_): New data member.
              (Close_task_runner::size_of_hashes_): New data member.
              * testsuite/Makefile.am
              (flagstest_compress_debug_sections_and_build_id_tree): New test.
              * testsuite/Makefile.in: Regenerate.
  29. 09 Mar, 2015 1 commit
    • Cary Coutant's avatar
      Fix failure in exception_static_test. · e1663197
      Cary Coutant authored
      Because the __EH_FRAME_BEGIN__ symbol is provided in an empty .eh_frame
      section in crtbeginT.o, if crt1.o has a non-empty .eh_frame section,
      we place all optimized .eh_frame sections into the output section ahead
      of the __EH_FRAME_BEGIN__ symbol, which breaks EH for statically-linked
      This patch fixes the problem by delaying the attachment of the optimized
      .eh_frame sections to the output section until we see the end marker
      section (or to the end of pass 1 if we never see an end marker).
      	PR gold/14675
      	* ehframe.cc (Eh_frame::add_ehframe_input_section): Change return type;
      	return enum indicating whether .eh_frame section is empty, optimizable,
      	unrecognized, or an end marker. Adjust explicit instantiations.
      	* ehframe.h (Eh_frame::Eh_frame_section_disposition): New enum type.
      	(Eh_frame::add_ehframe_input_section): Change return type.
      	* gold.cc (queue_middle_tasks): Call Layout::finalize_eh_frame_section.
      	* layout.cc (Layout::layout_eh_frame): Don't add optimized sections
      	to the .eh_frame output section until we see the end marker.
      	(Layout::finalize_eh_frame_section): New.
      	* layout.h: (Layout::finalize_eh_frame_section): New.
  30. 17 Feb, 2015 1 commit
    • Cary Coutant's avatar
      Fix --dynamic-list so that symbols not in the list are still exported. · e9c1bdad
      Cary Coutant authored
      In PR 13577, the complaint was that -Bsymbolic was overriding the binding
      behavior for symbols listed in the --dynamic-list by setting the DT_SYMBOLIC
      tag in the dynamic table. In reading the Gnu ld manual, I decided that
      --dynamic-list should be mutually exclusive of -Bsymbolic, and modified
      gold so that --dynamic-list would treat symbols listed as preemptible,
      and all other symbols as internally bound. I was wrong.
      PR 16992 shows that with --dynamic-list (and not -Bsymbolic), a symbol
      not listed in the dynamic list is being internally bound within the
      shared library, but because it's still in the dynamic symbol table, we
      expose it to a COPY relocation, and things go really bad from there.
      (I can reproduce the same failure, simply by turning on -Bsymbolic-functions
      with the Gnu linker. Even though the symbol is bound internally, it's
      still exported to the dynamic symbol table, and is exposed to a COPY
      I've backed out part of the fix for PR 13577, and -Bsymbolic (or
      -Bsymbolic-functions) can now be used with --dynamic-list, but if the
      two are used together, we do not set DT_SYMBOLIC or DF_SYMBOLIC
      (this matches Gnu ld behavior). We now treat symbols listed in the
      dynamic list as premptible, but we do not automatically treat symbols
      not listed there as non-premptible.
      	PR gold/13577
      	PR gold/16992
      	* layout.cc (Layout::finish_dynamic_section): Don't set DT_SYMBOLIC or
      	DF_SYMBOLIC if --dynamic-list option is used.
      	* options.cc (General_options::finalize): --dynamic-list is not
      	mutually exclusive with -Bsymbolic.
      	* symtab.h (Symbol::is_preemptible): Don't exclude dynamic symbols not
      	listed in --dynamic-list.
      	* testsuite/Makefile.am (dynamic_list_lib2.so): Add
      	* testsuite/Makefile.in: Regenerate.
  31. 09 Jan, 2015 1 commit
    • Cary Coutant's avatar
      Don't align start of segment unless alignment is larger than page size. · a5cd8f05
      Cary Coutant authored
      This fixes an issue where a page-aligned data section, combined with -z relro,
      could lead to a gap between text and data segments larger than a page, and
      we would fail to overlap the segments in the file.
      	* layout.cc (Layout::set_segment_offsets): Don't align start of segment
      	unless alignment is larger than page size.
  32. 01 Jan, 2015 1 commit
  33. 01 Dec, 2014 2 commits
    • Dmitriy Ivanov's avatar
      Add support for -z global. · fb257835
      Dmitriy Ivanov authored
      	* layout.cc (Layout::finish_dynamic_section): When '-z global'
      	is specified set DF_1_GLOBAL in DT_FLAGS_1 flags.
      	* options.h (General_options): New -z option (global).
    • Cary Coutant's avatar
      Fix extraneous warning about executable stack. · d8e60314
      Cary Coutant authored
      PR gold/17578 notes that gold will print a warning about an executable stack
      when the -z execstack option is given, even when there is no --warn_execstack
      option. The warning is completely useless and unexpected, since the user
      explicitly requested an executable stack, and did not even ask for warnings.
      This patch fixes that, and adds an extra warning when --warn_execstack
      and -z noexecstack are both given and an input file requires an executable
      	PR gold/17578
      	* layout.cc (Layout::layout_gnu_stack): Don't warn when -z execstack
      	is given.
      	(Layout::create_executable_stack_info): Warn when -z noexecstack is
      	given but some inputs require executable stack.
  34. 26 Nov, 2014 1 commit
    • Cary Coutant's avatar
      Update list of debug sections for --strip-debug-xxx options. · 982bbd97
      Cary Coutant authored
      Add .debug_gdb_scripts, .debug_gnu_pubnames, .debug_gnu_pubtypes,
      and .debug_str_offsets to lists of sections to strip or keep
      when stripping debug info.
      	* layout.cc (gdb_sections): Keep .debug_gdb_scripts and
      	.debug_str_offsets; strip .debug_gnu_pubnames and
      	(lines_only_debug_sections): Strip all four new sections.
  35. 30 Sep, 2014 1 commit
    • Kito Cheng's avatar
      Fix SysV-style hash table when --hash-style=both. · cd6da036
      Kito Cheng authored
      When --hash-style-both is used, gold currently builds the sysv hash
      table first, then the gnu hash table. Building the gnu hash table
      renumbers the dynamic symbol table, invalidating the sysv hash
      table. This patch reverses the order in which the hash tables are
      build so that both hash tables are correct.
      	PR gold/13597
      	* layout.cc (Layout::create_dynamic_symtab): Build gnu-style
      	hash table before sysv-style hash table.
  36. 24 Sep, 2014 1 commit
    • Cary Coutant's avatar
      Fix race condition causing assert in Eh_frame_hdr::do_sized_write(). · 635aa30e
      Cary Coutant authored
      2014-09-23  Taiju Tsuiki  <tzik@google.com>
                  Cary Coutant  <ccoutant@google.com>
      	* gold.cc (queue_final_tasks): Add Write_sections_task as a blocker
      	on input_sections_blocker.
      	* layout.cc (Write_sections_task::locks): Unblock
      	* layout.h (Write_sections_task::Write_sections_task): Add
      	* testsuite/Makefile.am (exception_x86_64_bnd_test): Add gcctestdir/ld
      	* testsuite/Makefile.in: Regenerate.
  37. 09 Jun, 2014 1 commit
  38. 06 Jun, 2014 1 commit
    • Cary Coutant's avatar
      Strip .debug_gnu_pubnames and .debug_gnu_pubtypes when building .gdb_index. · 4320c691
      Cary Coutant authored
      When not stripping those sections, there was a bug where gold was incorrectly
      adjusting section-relative offsets by the offset of the input section within
      the output section. That adjustment was both unnecessary and wrong, causing
      gold to miss a number of debug entries that should have been added to
      .gdb_index.  (With stripping, the adjustment was always 0, so the bug in
      dwarf_reader.cc would have been hidden by the change to layout.cc.)
      	* dwarf_reader.h (Dwarf_pubnames_table): Remove output_section_offset_.
      	* dwarf_reader.cc (Dwarf_pubnames_table::read_section): Likewise.
      	(Dwarf_pubnames_table::read_header): Likewise.
      	* layout.cc (gdb_fast_lookup_sections): Add .debug_gnu_pubnames and
  39. 02 May, 2014 1 commit
    • Cary Coutant's avatar
      Fix handling of __ehdr_start when it cannot be defined. · d1bddd3c
      Cary Coutant authored
      2014-05-02  Cary Coutant  <ccoutant@google.com>
      	* defstd.cc (in_segment): Define __ehdr_start here...
      	* layout.cc (Layout::finalize): ...Instead of here.  Set the
      	output segment when known.
      	* resolve.cc (Symbol::override_base_with_special): Remember
      	the original binding.
      	* symtab.cc (Symbol::set_output_segment): New function.
      	(Symbol::set_undefined): New function.
      	* symtab.h (Symbol::is_weak_undefined): Check original undef
      	(Symbol::is_strong_undefined): New function.
      	(Symbol::set_output_segment): New function.
      	(Symbol::set_undefined): New function.
      	* target-reloc.h (is_strong_undefined): Remove.
      	(issue_undefined_symbol_error): Call Symbol::is_weak_undefined.
      	Check for hidden undefs.
      	(relocate_section): Call Symbol::is_strong_undefined.
      	* testsuite/Makefile.am (ehdr_start_test_1)
      	(ehdr_start_test_2, ehdr_start_test_3)
      	(ehdr_start_test_4, ehdr_start_test_5): New test cases.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/ehdr_start_def.cc: New source file.
      	* testsuite/ehdr_start_test.cc: New source file.
      	* testsuite/ehdr_start_test.t: New linker script.
      	* testsuite/ehdr_start_test_4.sh: New shell script.