1. 11 Jul, 2018 1 commit
  2. 10 Jul, 2018 1 commit
    • Cary Coutant's avatar
      Fix test for availability of emplace_back. · 21555352
      Cary Coutant authored
      Testing for the GCC version 5 or later isn't right, since C++ 11 support
      wasn't enabled by default until later.  This patch tests the C++ standard
      support directly instead of inferring it from the GCC version.
      	* incremental.cc (Sized_incremental_binary::setup_readers): Use
      	emplace_back for C++ 11 or later.
  3. 09 Jul, 2018 1 commit
    • Alan Modra's avatar
      [GOLD] PowerPC .gnu.attributes support · 1cbba2d2
      Alan Modra authored
      	* powerpc.h (Tag_GNU_Power_ABI_FP): Define.
      	(Tag_GNU_Power_ABI_Vector, Tag_GNU_Power_ABI_Struct_Return): Define.
      	* powerpc.cc: Include attributes.h.
      	(Powerpc_relobj::attributes_section_data_): New variable, with
      	accessor and associated constructor and destructor support.
      	(Powerpc_dynobj::attributes_section_data_): Likewise.
      	(Powerpc_relobj::do_read_symbols): Stash SHT_GNU_ATTRIBUTES section
      	contents in attributes_section_data_.
      	(Powerpc_dynobj::do_read_symbols): Likewise.
      	(Target_powerpc): Add attributes_section_data_, last_fp_, last_ld_,
      	last_vec_, and last_struct_ vars.
      	(Target_powerpc::merge_object_attributes): New function.
      	(Target_powerpc::do_finalize_sections): Iterate over input objects
      	merging attributes.  Create output attributes section.
      (cherry picked from commit 724436fc)
  4. 26 Jun, 2018 1 commit
    • Nick Clifton's avatar
      Updated translations. · 71b4e2ec
      Nick Clifton authored
      opcodes	* po/uk.po: Updated Ukranian translation.
      	* po/de.po: Updated German translation.
      	* po/pt_BR.po: Updated Brazilian Portuguese translation.
      ld	* po/uk.po: Updated Ukranian translation.
      gold	* po/uk.po: Updated Ukranian translation.
      gas	* po/uk.po: Updated Ukranian translation.
      bfd	* po/uk.po: Updated Ukranian translation.
      binutils* po/sv.po: Updated Swedish translation.
      	* po/uk.po: Updated Ukranian translation.
  5. 24 Jun, 2018 2 commits
  6. 23 Jun, 2018 5 commits
    • Cary Coutant's avatar
      Bump version number and summarize new features in 1.16. · 155ea1bc
      Cary Coutant authored
      	* version.cc (version_string): Bump to 1.16.
      	* NEWS: Add new features in 1.16.
    • Cary Coutant's avatar
      Fix "may be used uninitialized" warning. · add41311
      Cary Coutant authored
      	PR gold/22914
      	* x86_64.cc (Target_x86_64::record_gnu_property): Initialize val.
    • Cary Coutant's avatar
      Add x86-64 support for Indirect Branch Tracking (IBT). · 750ea5ed
      Cary Coutant authored
      	PR gold/22915
      	* x86_64.cc (Output_data_plt_x86_64_ibt): New class.
      	(Target_x86_64::do_make_data_plt): (All instantiations) Check for
      	IBT feature bit and create IBT PLTs.
    • 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.
    • Cary Coutant's avatar
      Silence GCC 9 error about deprecated implicit copy constructor. · a1893a82
      Cary Coutant authored
      Replacing push_back() with emplace_back() eliminates the calls to the
      copy constructor, but I still had to provide explicit copy constructors
      because of the call to vector::reserve(), which tries to instantiate them
      even though they'll never actually be called when reserve() is called
      on an empty vector.
      	* incremental.cc (Sized_incremental_binary::setup_readers): Use
      	emplace_back for GCC 5 and later.
      	* incremental.h (Incremental_binary::Input_reader): Provide copy
      	(Sized_incremental_binary::Sized_input_reader): Likewise.
  7. 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.
  8. 21 Jun, 2018 1 commit
    • Cary Coutant's avatar
      Fix treatment of symbol versions with unused as-needed libraries. · cea6ffbd
      Cary Coutant authored
      When we have a weak reference to a symbol defined in an
      as-needed library, and that library ends up not-needed, gold
      simply clears the version information in the symbol table, even
      if the symbol could have been resolved by a needed library later
      in the link order. This results in a loss of version information,
      which can cause the program to bind to the wrong version at run
      This patch lets a dynamic definition override an earlier one if
      the earlier one is from a not-needed library, so that we can
      retain the version information from the binding to the needed
      library. In order to do that, the tracking of needed/not-needed
      had to be moved up to symbol resolution time, instead of during
      In cases where we still end up discarding version information,
      I've added a warning.
      For the original problem report and discussion, see:
      	* resolve.cc (Symbol_table::resolve): Rename tobinding to
      	orig_tobinding.  Call set_is_needed() for objects that resolve
      	non-weak references.
      	(Symbol_table::should_override): Allow a dynamic definition to
      	override an earlier one in a not-needed library.
      	* symtab.cc (Symbol_table::set_dynsym_indexes): Remove separate
      	processing for as-needed symbols.  Add warning when discarding
      	version informatin.
      	* testsuite/Makefile.am (weak_as_needed): New test case.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/weak_as_needed.sh: New test script.
      	* testsuite/weak_as_needed_a.c: New source file.
      	* testsuite/weak_as_needed_b.c: New source file.
      	* testsuite/weak_as_needed_b.script: New version script.
      	* testsuite/weak_as_needed_c.c: New source file.
      	* testsuite/weak_as_needed_c.script: New version script.
  9. 20 Jun, 2018 4 commits
    • Cary Coutant's avatar
      Fix problem where gold does not create base version for executables. · ebb13322
      Cary Coutant authored
      	PR gold/23268
      	* dynobj.cc (Versions::Versions): Change init for needs_base_version_.
      	(Versions::record_version): Add verdefs for both shared objects and
      	(Versions::add_def): Likewise for base version.
      	(Versions::add_need): Don't add base version for executables.
      	(Versions::version_index): Look up version for both shared objects and
      	* testsuite/Makefile.am (ver_test_14): New test case.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/ver_test_14.script: New version script.
      	* testsuite/ver_test_14.sh: New test script.
    • Cary Coutant's avatar
      Fix typo in most recent entry. · 4ef2c1b9
      Cary Coutant authored
    • Cary Coutant's avatar
      Replace thread config with automatic config using ax_pthread.m4. · c8dc28bc
      Cary Coutant authored
      The autotools library macro (AX_PTHREAD) is now used to detect if
      pthreads is present and multi-threaded linking in gold is automatically
      enabled if it is found. This enables multi-threaded gold on platforms
      where pthreads is enabled via other methods than just -lpthread
      (e.g., MinGW).
      2018-06-19  Joshua Watt  <jpewhacker@gmail.com>
      	    Cary Coutant  <ccoutant@gmail.com>
      	* configure.ac: Replace manual thread configuration with AX_PTHREAD.
      	Add --enable-threads=auto.
      	* Makefile.am (THREADFLAGS, THREADLIBS): New defines.
      	(THREADSLIB): Remove; change all references to THREADLIBS.
      	* Makefile.in: Regenerate.
      	* aclocal.m4: Regenerate.
      	* config.in: Regenerate.
      	* configure: Regenerate.
      	* testsuite/Makefile.am (THREADSLIB): Replace with...
      	(THREADFLAGS, THREADLIBS): ... these.
      	(LDADD): Remove; add as individual defines for...
      	(object_unittest, binary_unittest, leb128_unittest)
      	(overflow_unittest): ... these tests.
      	(tls_test, tls_pic_test, tls_pie_test, tls_pie_pic_test)
      	(tls_shared_test, tls_shared_ie_test, tls_shared_gd_to_ie_test)
      	(tls_shared_gnu2_gd_to_ie_test, tls_shared_gnu2_test_LDFLAGS)
      	(tls_shared_nonpic_test_LDFLAGS): Add $(THREADFLAGS) and ($THREADLIBS).
      	* testsuite/Makefile.in: Regenerate.
    • Cary Coutant's avatar
      Remove *.stderr when "make clean". · 27ab0424
      Cary Coutant authored
      	* testsuite/Makefile.am (MOSTLYCLEANFILES): Add *.stderr.
      	* testsuite/Makefile.in: Regenerate.
  10. 19 Jun, 2018 1 commit
    • Simon Marchi's avatar
      Bump to autoconf 2.69 and automake 1.15.1 · d0ac1c44
      Simon Marchi authored
      When trying to run the update-gnulib.sh script in gdb, I get this:
      Error: Wrong automake version (Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^      =:+{}]+)}/ at /opt/automake/1.11.1/bin/automake line 4113.), we need 1.11.1.
      Apparently, it's an issue with a regex in automake that triggers a
      warning starting with Perl 5.22.  It has been fixed in automake 1.15.1.
      So I think it's a good excuse to bump the versions of autoconf and
      automake used in the gnulib import.  And to avoid requiring multiple
      builds of autoconf/automake, it was suggested that we bump the required
      version of those tools for all binutils-gdb.
      For autoconf, the 2.69 version is universally available, so it's an easy
      choice.  For automake, different distros and distro versions have
      different automake versions.  But 1.15.1 seems to be the most readily
      available as a package.  In any case, it's easy to build it from source.
  11. 10 May, 2018 1 commit
    • Stephen Crane's avatar
      Fix _GLOBAL_OFFSET_TABLE_ value for large GOTs (aarch64). · a45a8f91
      Stephen Crane authored
      Gold resolves GOT-relative relocs relative to the GOT base +
      0x8000 when the GOT is larger than 0x8000. However, previously
      the _GLOBAL_OFFSET_TABLE_ symbol was set to GOT base + 0x8000
      when the .got.plt was larger than 0x8000. This patch makes both
      checks use the size of the .got section so that they agree when
      to add 0x8000.
  12. 25 Apr, 2018 1 commit
    • Cary Coutant's avatar
      Fix bug with relocation addends and merge sections with --icf. · 651d1620
      Cary Coutant authored
      During --icf processing, gold was incorrectly processing the relocation
      addend for references to items in a merge section. PC-relative references
      and other forms of reference with a biased base address require a
      non-section local symbol, where the addend is purely the bias.
      	PR gold/20642
      	PR gold/22820
      	* gc.h (gc_process_relocs): Flag STT_SECTION symbols in symvec.
      	* icf.cc (get_section_contents): For merge sections, ignore the
      	addend for relocations against non-section symbols.
  13. 24 Apr, 2018 1 commit
    • Cary Coutant's avatar
      Fix internal error caused by conflicting default version definitions. · 890d1555
      Cary Coutant authored
      	PR gold/16504
      	* dynobj.cc (Versions::symbol_section_contents): Don't set
      	VERSYM_HIDDEN flag for undefined symbols.
      	* symtab.cc (Symbol_table::add_from_object): Don't override default
      	version definition with a different default version.
      	* symtab.h (Symbol::from_dyn): New method.
      	* testsuite/plugin_test.c (struct sym_info): Add ver field.
      	(claim_file_hook): Pass symbol version to plugin API.
      	(parse_readelf_line): Parse symbol version.
      	* testsuite/Makefile.am (ver_test_pr16504): New test case.
      	* testsuite/Makefile.in: Regenerate.
      	* testsuite/ver_test_pr16504.sh: New test script.
      	* testsuite/ver_test_pr16504_a.c: New source file.
      	* testsuite/ver_test_pr16504_a.script: New version script.
      	* testsuite/ver_test_pr16504_b.c: New source file.
      	* testsuite/ver_test_pr16504_b.script: New version script.
  14. 19 Apr, 2018 1 commit
    • Cary Coutant's avatar
      Fix second bug where --icf=safe triggers segfault when linking ARM. · d83d5403
      Cary Coutant authored
      When checking a R_ARM_TARGET[12] relocation, we need a valid target
      pointer, but the garbage collection code was passing a NULL instead.
      The previous fix for this bug fixed the call to
      scan.global_reloc_may_be_function_pointer, but missed the similar
      call to scan.local_reloc_may_be_function_pointer.
      	PR gold/23046
      	* gc.h (gc_process_relocs): Pass target to
  15. 18 Apr, 2018 1 commit
  16. 14 Apr, 2018 1 commit
    • Cary Coutant's avatar
      Fix bug where --icf=safe triggers segfault when linking ARM. · aae82809
      Cary Coutant authored
      When checking a R_ARM_TARGET[12] relocation, we need a valid target
      pointer, but the garbage collection code was passing a NULL instead.
      	PR gold/23046
      	* gc.h (gc_process_relocs): Pass target to
  17. 09 Apr, 2018 4 commits
    • Alan Modra's avatar
      Regenerate some files · c4a614e2
      Alan Modra authored
      The gold change is to pick up HJ's PR22318 AC_PLUGINS update.  The
      ld change is to correct a file I generated from a modified tree.
      	* configure: Regenerate.
      	* po/BLD-POTFILES.in: Regenerate.
    • Alan Modra's avatar
      PowerPC inline PLT call support · 23cedd1d
      Alan Modra authored
      In addition to the existing relocs we need two more to mark all
      instructions in the call sequence, PLTCALL on the call itself (plus
      the toc restore insn for ppc64), and PLTSEQ on others.  All
      relocations in a particular sequence have the same symbol.
      Example ppc64 ELFv2 assembly:
       .reloc .,R_PPC64_PLTSEQ,puts
      	std 2,24(1)
      	addis 12,2,puts@plt@ha	# .reloc .,R_PPC64_PLT16_HA,puts
      	ld 12,puts@plt@l(12)	# .reloc .,R_PPC64_PLT16_LO_DS,puts
       .reloc .,R_PPC64_PLTSEQ,puts
      	mtctr 12
       .reloc .,R_PPC64_PLTCALL,puts
      	ld 2,24(1)
      Example ppc32 -fPIC assembly:
      	addis 12,30,puts+32768@plt@ha # .reloc .,R_PPC_PLT16_HA,puts+0x8000
      	lwz 12,12,puts+32768@plt@l    # .reloc .,R_PPC_PLT16_LO,puts+0x8000
       .reloc .,R_PPC_PLTSEQ,puts+32768
      	mtctr 12
       .reloc .,R_PPC_PLTCALL,puts+32768
      Marking sequences like this allows the linker to convert them to nops
      and a direct call if the target symbol turns out to be local.
      When the call is __tls_get_addr, each relocation shown above is paired
      with an R_PPC*_TLSLD or R_PPC*_TLSGD reloc to additionally mark the
      sequence for possible TLS optimization.  The TLSLD or TLSGD relocs are
      emitted first.
      	* elf/ppc.h (R_PPC_PLTSEQ, R_PPC_PLTCALL): Define.
      	* elf/ppc64.h (R_PPC64_PLTSEQ, R_PPC64_PLTCALL): Define.
      	* elf32-ppc.c (ppc_elf_howto_raw): Add PLTSEQ and PLTCALL howtos.
      	(is_plt_seq_reloc): New function.
      	(ppc_elf_check_relocs): Handle PLTSEQ and PLTCALL relocs.
      	(ppc_elf_tls_optimize): Handle inline plt call sequence.
      	(ppc_elf_relax_section): Handle PLTCALL reloc.
      	(ppc_elf_relocate_section): Nop out inline plt call sequence when
      	resolving locally.
      	* elf64-ppc.c (ppc64_elf_howto_raw): Add R_PPC64_PLTSEQ and
      	R_PPC64_PLTCALL entries.  Comment R_PPC64_TOCSAVE.
      	(has_tls_get_addr_call): Correct comment.
      	(is_branch_reloc): Add PLTCALL.
      	(is_plt_seq_reloc): New function.
      	(ppc64_elf_check_relocs): Handle PLT16_LO_DS reloc.  Set
      	has_tls_reloc for R_PPC64_TLSGD and R_PPC64_TLSLD.  Create plt
      	entry for R_PPC64_PLTCALL.
      	(ppc64_elf_tls_optimize): Handle inline plt call sequence.
      	(ppc_type_of_stub): Handle PLTCALL reloc.
      	(toc_adjusting_stub_needed): Likewise.
      	(ppc64_elf_relocate_section): Set "can_plt_call" for PLTCALL
      	reloc insn.  Nop out inline plt call sequence when resolving
      	locally.  Handle __tls_get_addr inline plt call optimization.
      	* powerpc.h (R_POWERPC_PLTSEQ, R_POWERPC_PLTCALL): Define.
      	* powerpc.cc (Target_powerpc::Track_tls::maybe_skip_tls_get_addr_call):
      	Handle inline plt sequence relocs.
      	(Stub_table::Plt_stub_key::Plt_stub_key): Likewise.
      	(Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Likewise.
      	(Target_powerpc::Relocate::relocate): Likewise.
    • Alan Modra's avatar
      Support PLT16 relocs against local symbols · 2d7ad24e
      Alan Modra authored
      Necessary if gcc is to use PLT16 relocs to implement -mlongcall, and
      there isn't a good technical reason why local symbols should be
      excluded from PLT16 support.  Non-ifunc local symbol PLT entries go in
      a separate section to other PLT entries.  In a fixed position
      executable they won't need to be relocated, and in a PIE or shared
      library I chose to not implement lazy relocation.
      	* elf64-ppc.c (LOCAL_PLT_ENTRY_SIZE): Define.
      	(struct ppc_stub_hash_entry): Add symtype field.
      	(PLT_KEEP): Define.
      	(struct ppc_link_hash_table): Add pltlocal and relpltlocal.
      	(create_linkage_sections): Create pltlocal and relpltlocal.
      	(ppc64_elf_check_relocs): Allow PLT relocs on local symbols.
      	Set PLT_KEEP.
      	(ppc64_elf_adjust_dynamic_symbol): Keep PLT entries for inline calls.
      	(allocate_dynrelocs): Allocate pltlocal and relpltlocal.
      	(ppc64_elf_size_dynamic_sections): Size pltlocal and relpltlocal.
      	Keep PLT entries for inline calls against locals.
      	(ppc_build_one_stub): Use pltlocal as appropriate.
      	(ppc_size_one_stub): Likewise.
      	(ppc64_elf_size_stubs): Set symtype.
      	(build_global_entry_stubs_and_plt): Init pltlocal and write
      	relpltlocal for globals.
      	(write_plt_relocs_for_local_syms): Likewise for local syms.
      	(ppc64_elf_relocate_section): Support PLT for local syms.
      	* elf32-ppc.c (PLT_KEEP): Define.
      	(struct ppc_elf_link_hash_table): Add pltlocal and relpltlocal.
      	(ppc_elf_create_glink): Create pltlocal and relpltlocal.
      	(ppc_elf_check_relocs): Allow PLT relocs on local symbols.
      	Set PLT_KEEP.  Adjust update_local_sym_info call.
      	(ppc_elf_adjust_dynamic_symbol): Keep PLT entries for inline calls.
      	(allocate_dynrelocs): Allocate pltlocal and relpltlocal.
      	(ppc_elf_size_dynamic_sections): Size pltlocal and relpltlocal.
      	(ppc_elf_relocate_section): Support PLT16 relocs for local syms.
      	(write_global_sym_plt): Init pltlocal and write relpltlocal.
      	(ppc_finish_symbols): Likewise for locals.
      	* emulparams/elf32ppc.sh (OTHER_RELRO_SECTIONS_2): Add .branch_lt.
      	(OTHER_GOT_RELOC_SECTIONS): Add .rela.branch_lt.
      	* testsuite/ld-powerpc/elfv2so.d: Update for symbol/stub reordering.
      	* testsuite/ld-powerpc/relbrlt.d: Likewise.
      	* testsuite/ld-powerpc/relbrlt.s: Likewise.
      	* testsuite/ld-powerpc/tlsso.r: Likewise.
      	* testsuite/ld-powerpc/tlstocso.r: Likewise.
      	* powerpc.cc (Target_powerpc::lplt_): New variable.
      	(Target_powerpc::lplt_section): Associated accessor.
      	(Target_powerpc::plt_off): Handle local non-ifunc symbols.
      	(Target_powerpc::make_lplt_section): New function.
      	(Target_powerpc::make_local_plt_entry): New function.
      	(Powerpc_relobj::do_relocate_sections): Write out lplt.
      	(Output_data_plt_powerpc::first_plt_entry_offset): Zero for lplt.
      	(Output_data_plt_powerpc::add_local_entry): New function.
      	(Output_data_plt_powerpc::do_write): Ignore lplt.
      	(Target_powerpc::make_iplt_section): Make lplt first.
      	(Target_powerpc::make_brlt_section): Make .branch_lt relro.
      	(Target_powerpc::Scan::local): Handle PLT16 relocs.
    • Alan Modra's avatar
      PowerPC PLT16 relocations · 08be3224
      Alan Modra authored
      The PowerPC64 ELFv2 ABI and the PowerPC SysV ABI support a number of
      relocations that can be used to create and access a PLT entry.
      However, the relocs are not well defined.  The PLT16 family of relocs
      talk about "the section offset or address of the procedure linkage
      table entry".  It's plain that we do need a relative address when PIC
      as otherwise we'd have dynamic text relocations, but "section offset"
      doesn't specify which section.  The most obvious one, ".plt", isn't
      that useful because there is no readily available way of addressing
      the start of the ".plt" section.  Much more useful would be "the
      GOT/TOC-pointer relative offset of the procedure linkage table entry",
      and I suppose you could argue that is a "section offset" of sorts.
      For PowerPC64 it is better to use the same TOC-pointer relative
      addressing even when non-PIC, since ".plt" may be located outside the
      range of a 32-bit address.  However, for ppc32 we do want an absolute
      address when non-PIC as a GOT pointer may not be set up.  Also, for
      ppc32 PIC we have a similar situation to R_PPC_PLTREL24 in that the
      GOT pointer is set to a location in the .got2 section and we need to
      specify the .got2 offset in the PLT16 reloc addend.
      This patch supports PLT16 relocations using these semantics.  This is
      not an ABI change for ppc32 since the relocations were not previously
      supported by GNU ld, but is for ppc64 where some of the PLT16 relocs
      were supported.  I'm not particularly concerned since the old ppc64
      PLT16 reloc semantics made them almost completely useless.
      	* elf32-ppc.c (ppc_elf_check_relocs): Handle PLT16 relocs.
      	(ppc_elf_relocate_section): Likewise.
      	* elf64-ppc.c (ppc64_elf_check_relocs): Handle PLT16_LO_DS.
      	(ppc64_elf_relocate_section): Likewise.  Correct PLT16
      	resolution to plt entry relative to toc pointer.
      	* powerpc.cc (Target_powerpc::plt_off): New functions.
      	(is_plt16_reloc): New function.
      	(Stub_table::plt_off): Use Target_powerpc::plt_off.
      	(Stub_table::plt_call_size): Use plt_off.
      	(Stub_table::do_write): Likewise.
      	(Target_powerpc::Scan::get_reference_flags): Return RELATIVE_REF
      	for PLT16 relocations.
      	(Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Return true
      	for PLT16 relocations.
      	(Target_powerpc::Scan::global): Make a PLT entry for PLT16 relocations.
      	(Target_powerpc::Relocate::relocate): Support PLT16 relocations.
      	(Powerpc_scan_relocatable_reloc::global_strategy): Return RELOC_SPECIAL
      	for ppc32 plt16 relocs.
  18. 07 Apr, 2018 1 commit
    • Cary Coutant's avatar
      Further improve warnings for relocations referring to discarded sections. · 43193fe9
      Cary Coutant authored
      Relocations referring to discarded sections are now treated as errors
      instead of warnings.
      Also with this patch, we will now print the section group signature and the
      object file with the prevailing definition of that group along with the
      name of the symbol that the relocation is referring to. This additional
      information should be much more useful to anyone trying to track down
      the source of such errors.
      To do so, we now map each discarded section to the Kept_section info in
      the Layout class, and defer the logic that maps a discarded section to
      its counterpart in the kept group. This gives us the information we need
      to identify the signature symbol given the discarded section, and the
      name of the object file that provided the prevailing (i.e., first)
      definition of that group.
      	* object.cc (Sized_relobj_file::include_section_group): Store
      	reference to Kept_section info for discarded comdat sections
      	regardless of size.  Move size checking to map_to_kept_section.
      	(Sized_relobj_file::include_linkonce_section): Likewise.
      	(Sized_relobj_file::map_to_kept_section): Add section name parameter.
      	Insert size checking logic from above functions.
      	(Sized_relobj_file::find_kept_section_object): New method.
      	(Sized_relobj_file::get_symbol_name): New method.
      	* object.h (Sized_relobj_file::map_to_kept_section): Add section_name
      	parameter.  Adjust all callers.
      	(Sized_relobj_file::find_kept_section_object): New method.
      	(Sized_relobj_file::get_symbol_name): New method.
      	(Sized_relobj_file::Kept_comdat_section): Replace object and shndx
      	fields with sh_size, kept_section, symndx, and is_comdat fields.
      	(Sized_relobj_file::set_kept_comdat_section): Replace kept_object
      	and kept_shndx parameters with is_comdat, symndx, sh_size, and
      	(Sized_relobj_file::get_kept_comdat_section): Likewise.
      	* target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR.
      	Adjust all references.
      	(issue_undefined_symbol_error): New function template.
      	(relocate_section): Pass section name to map_to_kept_section.
      	Move discarded section code to new function above.
      	* aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move
      	declaration for gsym out one level.  Call issue_discarded_error.
      	* arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise.
      	* powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
  19. 05 Apr, 2018 3 commits
    • Cary Coutant's avatar
      Improve warnings for relocations referring to discarded sections. · c54b27d1
      Cary Coutant authored
      	* target-reloc.h (relocate_section): Add local symbol index or global
      	symbol name to warning about relocation that refers to discarded
    • Cary Coutant's avatar
      Revert previous patch and apply revised patch. · 494e49c9
      Cary Coutant authored
      2018-04-05  James Cowgill  <james.cowgill@mips.com>
      	PR gold/22770
      	* mips.cc (Mips_got_info::record_got_page_entry): Fetch existing
      	page entries for the object's GOT.
      	PR gold/22770
      	* mips.cc (Mips_got_info::record_got_page_entry): Don't insert
      	Got_page_entry for object's GOT.
      	(Mips_got_info::add_got_page_entries): Add all pages from from's GOT.
      	Rename to add_got_page_count.
      	(Got_page_entry): Remove num_pages.
    • James Cowgill's avatar
      MIPS: Fix GOT page counter in multi-got links · 67faf1f4
      James Cowgill authored
      The record_got_page_entry function records and updates the maximum
      number of GOT page entries which may be required by an object. In the
      case where an existing GOT page entry was expanded, only the entry
      belonging to output GOT would have its page count updated. This leaves
      the entry belonging to the object GOT with the num_pages count of 1 it
      was originally initialized with. Later on when GOTs are being merged in a
      multi-got link, this causes the value of entry->num_pages in
      add_got_page_entries to always be 1 and underestimates the number of pages
      required for the new entry. This in turn leads to an assertion failure in
      get_got_page_offset where we run out of pages.
      Fix by obtaining the object's GOT entry unconditionally and not just
      the first time it gets created. Now that entry2 is always valid, remove
      the useless NULL checks.
      	PR gold/22770
      	* mips.cc (Mips_got_info::record_got_page_entry): Fetch existing
      	page entries for the object's GOT.
  20. 04 Apr, 2018 2 commits
  21. 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.
  22. 28 Mar, 2018 3 commits
    • Cary Coutant's avatar
      Use top-level config support for enabling plugins. · 24538276
      Cary Coutant authored
      Also recognizes --plugin options when plugins are disabled.
      2018-03-28  Cary Coutant  <ccoutant@gmail.com>
      	PR gold/21423
      	PR gold/22500
      	* configure.ac: Call AC_USE_SYSTEM_EXTENSIONS.
      	Replace check for --enable-plugins with AC_PLUGINS.
      	* options.cc (parse_plugin, parse_plugin_opt): Remove #ifdef.
      	(General_options::finalize): Check if plugins enabled.
      	* options.h (--plugin, --plugin-opt): Define even if plugins not
      	* Makefile.in: Regenerate.
      	* aclocal.m4: Regenerate.
      	* configure: Regenerate.
      	* testsuite/Makefile.in: Regenerate.
    • Cary Coutant's avatar
      Add support for R_AARCH64_TLSLE_LDST8_TPREL_LO12, etc. · e82e6b2b
      Cary Coutant authored
      	PR gold/22969
      	* aarch64.h: Fix spelling of R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC.
      	PR gold/22969
      	* aarch64-reloc.def: Add TLSLE_LDST* relocations.
      	* aarch64.cc (Target_aarch64::optimize_tls_reloc): Likewise.
      	(Target_aarch64::Scan::local): Likewise.
      	(Target_aarch64::Scan::global): Likewise.
      	(Target_aarch64::Relocate::relocate): Likewise.
      	(Target_aarch64::Relocate::relocate_tls): Likewise.
    • Roland McGrath's avatar
      gold/testsuite: Fix bad regexp in split_x86_64.sh · 9c75b456
      Roland McGrath authored
      	* testsuite/split_x86_64.sh: Fix bad regexp.
  23. 26 Mar, 2018 1 commit
    • Cary Coutant's avatar
      Fix case where IR file provides symbol visibility but replacement file does not. · 0b7a4aa6
      Cary Coutant authored
      In PR 22868, two IR files provide conflicting visibility for a symbol.
      When a def with PROTECTED visibility is seen after a def with DEFAULT
      visibility, gold does not override the visibility. Later, if the
      replacement object define the symbol with DEFAULT visibility, the symbol
      remains DEFAULT. This was caused by a recent change to allow multiply-defined
      absolute symbols, combined with the fact that the plugin framework was using
      SHN_ABS as the section index for placeholder symbols. The solution is to
      use a real (but arbitrary) section index.
      	PR gold/22868
      	* plugin.cc (Sized_pluginobj::do_add_symbols): Use a real section
      	index instead of SHN_ABS for defined symbols.
      	* testsuite/Makefile.am (plugin_pr22868): New test case.
      	* testsuite/Makefile.in: Regenerate
      	* testsuite/plugin_pr22868.sh: New test script.
      	* testsuite/plugin_pr22868_a.c: New source file.
      	* testsuite/plugin_pr22868_b.c: New source file.
  24. 24 Mar, 2018 1 commit
    • Cary Coutant's avatar
      Fix warn-unused-return message. · 8da9a904
      Cary Coutant authored
      	* plugin.cc (link_or_copy_file): Remove newlines from warning messages.
      	Add pedantic check for return value from ::write.