Commit Graph

4454 Commits

Author SHA1 Message Date
Alan Modra b16c44debc bfd_get_filename
This macro says:
/* Cast from const char * to char * so that caller can assign to
   a char * without a warning.  */

I reckon that isn't such a good idea since it can result in char*
variables where const char* is appropriate.  Not very many places
need the char* cast.

bfd/
	* aout-target.h (object_p): Formatting.
	* bfd-in.h (bfd_get_filename): Don't cast to char*.
	* corefile.c (generic_core_file_matches_executable_p): Constify
	variables and remove cast.
	* bfd-in2.h: Regenerate.
binutils/
	* nm.c (print_object_filename_bsd, print_object_filename_sysv),
	(print_object_filename_posix, print_archive_filename_bsd),
	(print_archive_filename_sysv, print_archive_filename_posix),
	(print_archive_member_bsd, print_archive_member_sysv),
	(print_archive_member_posix): Constify parameter.
	(struct output_fns <print_object_filename, print_archive_filename>),
	(<print_archive_member>): Likewise.
	* objcopy.c (copy_archive): Add cast for make_tempdir.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
	variable.
	* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
	* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
gdb/
	* coffread.c (coff_symfile_read): Constify filename variable.
	* dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
	(elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
	* gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
	* solib.c (reload_shared_libraries_1): Likewise.
	* symfile.c (reread_symbols): Likewise.
	* solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
	* solib-darwin.c (darwin_bfd_open): Likewise.
	* symfile-mem.c (symbol_file_add_from_memory): Likewise.
sim/cris/
	* sim-if.c (sim_open): Constify filename variable.
2019-09-06 12:22:59 +09:30
Eric Botcazou de07a74580 Fix PR ld/24574
This restores a line that has been dropped when the auto-import feature
of the PE-COFF linker was overhauled about one year.  It is necessary
for GDB to properly resolve extern symbol in DLLs.

ld/ChangeLog
	* pe-dll.c (pe_find_data_imports): Replace again the original name
	of the undefined symbol with the __imp_ prefixed one after it is
	resolved.
2019-09-05 18:23:37 +02:00
Alan Modra 77486630b1 R_PPC64_PCREL_OPT
The loads and stores handled in the second instruction of a sequence
marked by R_PPC64_PCREL_OPT may be a prefix instruction.  For example:
 pld ra,symbol@got@pcrel
0:
 pld rt,off(ra)
 .reloc 0b-8,R_PPC64_PCREL_OPT,(.-8)-(0b-8)
can be optimised to
 pld rt,symbol+off@pcrel
 pnop

	* elf64-ppc.c (xlate_pcrel_opt): Handle prefix loads and stores
	in second instruction.
	(ppc64_elf_relocate_section): Likewise.
2019-09-05 13:56:20 +09:30
Alan Modra a78fca7b57 Segfault in ld building SPEC CPU2017 527.cam4_r with -flto
Caused by the PR24406 fix.  unwrap_hash_lookup shouldn't be called
with link_info.wrap_hash NULL.

	PR ld/24406
	* plugin.c (get_symbols): Test link_info.wrap_hash before calling
	unwrap_hash_lookup.
2019-08-29 00:33:49 +09:30
Tamar Christina 652afeef24 AArch64: Fix LD crash on weak and undefined TLS symbols. (PR/24602).
This patch fixes a few linker crashes due to TLS code reaching an assert when it
shouldn't.

The first scenario is with weak TLS symbols that remain weak during linking.  In
this case the mid-end would not have seen a TLS symbol and so wouldn't have
allocated the TLS section.  We currently assert here and the linker crashes with
a not very useful message.

This patch changes this to return the value 0 for the TLS symbol in question
emulating what lld and gold and other BFD targets do.  However because weak TLS
is implementation defined and we don't define any behavior for it I also emit a
warning to the user to inform them of such.

Secondly when a strong TLS reference is undefined. The linker crashes even after
it correctly reported that there is an undefined reference.  This changes it so
that it gracefully exits and reports a useful error.

bfd/ChangeLog:

	PR ld/24601
	* elfnn-aarch64.c (aarch64_relocate): Handle weak TLS and undefined TLS.
	Also Pass input_bfd to _bfd_aarch64_elf_resolve_relocation.
	* elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Use it.
	* elfxx-aarch64.h (_bfd_aarch64_elf_resolve_relocation): Emit warning
	for weak TLS.

ld/ChangeLog:

	PR ld/24601
	* testsuite/ld-aarch64/aarch64-elf.exp (undef-tls, weak-tls): New.
	* testsuite/ld-aarch64/undef-tls.d: New test.
	* testsuite/ld-aarch64/undef-tls.s: New test.
	* testsuite/ld-aarch64/weak-tls.d: New test.
	* testsuite/ld-aarch64/weak-tls.s: New test.
2019-08-22 11:43:15 +01:00
Tamar Christina b4e87f2c1e Arm: Fix performance issue with thumb-2 tailcalls
We currently use a padding NOP after a Thumb to Arm interworking veneer (BX pc).
The NOP is never executed but may result in a performance penalty on some cores.

For this reason this patch changes the NOPs after Thumb to Arm veneers into B .-2
and adds a note to this in the source code for future reference.

bfd/ChangeLog:

	* elf32-arm.c (elf32_thumb2_plt_entry, elf32_arm_plt_thumb_stub,
	elf32_arm_stub_long_branch_v4t_thumb_thumb,
	elf32_arm_stub_long_branch_v4t_thumb_arm,
	elf32_arm_stub_short_branch_v4t_thumb_arm,
	elf32_arm_stub_long_branch_v4t_thumb_arm_pic,
	elf32_arm_stub_long_branch_v4t_thumb_thumb_pic,
	elf32_arm_stub_long_branch_v4t_thumb_tls_pic): Change nop to branch to
	previous instruction.

ld/ChangeLog:

	* testsuite/ld-arm/cortex-a8-fix-b-plt.d: Update Testcase.
	* testsuite/ld-arm/cortex-a8-fix-b-rel-arm.d: Likewise.
	* testsuite/ld-arm/cortex-a8-fix-bcc-plt.d: Likewise.
	* testsuite/ld-arm/farcall-cond-thumb-arm.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-app.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-lib-v4t.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-arm-short.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-arm.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-thumb.d: Likewise.
	* testsuite/ld-arm/fix-arm1176-on.d: Likewise.
	* testsuite/ld-arm/ifunc-10.dd: Likewise.
	* testsuite/ld-arm/ifunc-2.dd: Likewise.
	* testsuite/ld-arm/ifunc-4.dd: Likewise.
	* testsuite/ld-arm/ifunc-6.dd: Likewise.
	* testsuite/ld-arm/ifunc-8.dd: Likewise.
	* testsuite/ld-arm/jump-reloc-veneers-long.d: Likewise.
	* testsuite/ld-arm/mixed-app.d: Likewise.
	* testsuite/ld-arm/thumb2-b-interwork.d: Likewise.
	* testsuite/ld-arm/tls-longplt.d: Likewise.
	* testsuite/ld-arm/tls-thumb1.d: Likewise.
2019-08-20 16:35:28 +01:00
H.J. Lu 81e8046dc0 x86-64: Move PIC check for PC-relative relocations back
commit 83924b3846
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Feb 5 18:45:23 2019 -0800

    x86-64: Restore PIC check for PCREL reloc against protected symbol

moved PIC check for PC-relative relocations to elf_x86_64_check_relocs.
Since linker defined symbols may not be processed at the time, we need
to move the check back to elf_x86_64_relocate_section.

bfd/

	PR ld/24905
	* elf64-x86-64.c (elf_x86_64_check_relocs): Move PIC check for
	PC-relative relocations back to ...
	(elf_x86_64_relocate_section): Here.

ld/

	PR ld/24905
	* testsuite/ld-x86-64/pr24905-x32.d: New file.
	* testsuite/ld-x86-64/pr24905.d: Likewise.
	* testsuite/ld-x86-64/pr24905.s: Likewise.
	* testsuite/ld-x86-64/pr24905.t: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr24905 and pr24905-x32.
2019-08-16 14:25:58 -07:00
Christophe Lyon fdfc8cf7f0 [ld] [arm] Add support for noinit section
2019-08-16  Christophe Lyon  <christophe.lyon@linaro.org>

	* emulparams/armelf.sh (OTHER_SECTIONS): Add support for noinit
	section.

Change-Id: Ib293f28cc5f21e9e9a13abf4d4e37f0a0eec41c0
2019-08-16 08:28:52 +00:00
Alan Modra 7df6aecc97 PowerPC gcc bootstrap fail with bss-plt
git commit 3e04d7655b introduced a bug by sizing output sections
earlier in ppc_before_allocation.  That meant PLT (and GOT) sizes were
not included when calculating total executable section sizes.

	* emultempl/ppc32elf.em (ppc_before_allocation): Force running
	prelim_size_sections before deciding whether branch trampolines
	might be needed.
2019-08-16 13:38:11 +09:30
Jim Wilson 080a488354 RISC-V: Fix lui relaxation issue with code at address 0.
This fixes a problem originally reported at
    https://github.com/riscv/riscv-binutils-gdb/issues/173

If you have code linked at address zero, you can have a lui instruction
loading a value 0x800 which gets relaxed to a c.lui which is valid (c.lui 0x1
followed by addi -0x800).  Relaxation can reduce the value below 0x800 at which
point the c.lui 0x0 is no longer valid.  We can fix this by converting the
c.lui to a c.li which can load 0.

	bfd/
	* elfnn-riscv.c (perform_relocation) <R_RISCV_RVC_LUI>: If
	RISCV_CONST_HIGH_PART (value) is zero, then convert c.lui instruction
	to c.li instruction, and use ENCODE_RVC_IMM to set value.

	ld/
	* testsuite/ld-riscv-elf/c-lui-2.d: New.
	* testsuite/ld-riscv-elf/c-lui-2.ld: New.
	* testsuite/ld-riscv-elf/c-lui-2.s: New.
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run the c-lui-2 test.
2019-08-15 12:01:13 -07:00
Alan Modra dc02848a69 Sort statement_enum and lang_statement_union
To make comparing the two easier.

	* ldlang.h (enum statement_enum): Sort.
	(union lang_statement_union): Sort.
2019-08-10 17:16:16 +09:30
Alan Modra 4cfbdbfd26 Delete unused ldlang.h structs
* ldlang.h (lang_common_statement_type): Delete.
	(lang_object_symbols_statement_type): Delete.
	(union lang_statement_union): Remove common_statement and
	object_symbols_statement.
2019-08-10 17:16:16 +09:30
Alan Modra 988de25b36 stat_alloc casts
Casts from a void* just clutter the source.

	* ldexp.c (exp_intop, exp_bigintop, exp_relop, exp_binop, exp_trinop),
	(exp_unop, exp_nameop, exp_assop, exp_assert): Remove casts of
	stat_alloc return value.
	* ldlang.c (new_statement, new_afile, sort_def_symbol),
	(lang_memory_region_lookup, lang_memory_region_alias),
	(ldlang_add_undef, ldlang_add_require_defined, insert_pad),
	(lang_add_gc_name, lang_new_phdr): Likewise.
	* lexsup.c (set_segment_start): Likewise.
2019-08-10 17:16:16 +09:30
Alan Modra 36983a93bb lang_input_statement_type next pointers
"next" and "next_real_file" in lang_input_statement_type always point
to another lang_input_statement_type, so it makes sense for these to
not be the generic lang_statement_union_type.  This patch also updates
a number of variables in ldlang.c for the same reason, and modifies
lang_statement_append to reduce the need for casts.

	* ldlang.h (lang_input_statement_type): Make next
	and next_real_file a lang_input_statement_type pointer.
	(lang_statement_append): Delete prototype.
	(LANG_FOR_EACH_INPUT_STATEMENT): Update for lang_input_statement_type
	change.
	* ldmain.c (add_archive_element): Likewise.
	* ldlang.c: Likewise throughout.
	(lang_statement_append): Make static.  Make element and field
	void pointers.  Remove casts in calls.
	(lang_check): Use a lang_input_statement_type pointer for "file".
	(find_rescan_insertion): Similarly for "iter" and return value.
	(lang_process): Similarly for "insert", "iter" and "temp".
	* emultempl/spuelf.em (embedded_spu_file): Likewise.
	* emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Expand
	lang_statment_append call.
2019-08-10 17:16:16 +09:30
Mihailo Stojanovic f16a9783c5 Add support for a MIPS specific .MIPS.xhash section.
This patch is a reimplementation of [1] which was submitted in 2015 by
Neil Schellenberger. Copyright issue was sorted out [2] last year.
It proposed a new section (.gnu.xhash) and related dynamic tag
(DT_GNU_XHASH). The new section would be virtually identical to the
existing .gnu.hash except for the translation table (xlat) which would
contain correct MIPS .dynsym indexes corresponding to the hashvals in
chains. This is because MIPS ABI imposes a different ordering on the
dynsyms than the one expected by the .gnu.hash section. Another addition
would be a leading word (ngnusyms) which would contain the number of
entries in the translation table.

  In this patch, the new section name and dynamic tag are changed to
reflect the fact that the section should be treated as MIPS-specific
(.MIPS.xhash and DT_MIPS_XHASH).

  This patch addresses the alignment issue as reported in [3], which is
caused by the leading word added to the .MIPS.xhash section. Leading word
is removed in this patch, and the number of entries in the translation
table is now calculated using DT_MIPS_SYMTABNO dynamic tag (this is
addressed by the corresponding glibc patch).

  Suggestions on coding style in [4] were taken into account. Existing
GNU hash testcase was covered, and another one was added in the MIPS
part of the testsuite.

  The other major change is reserving MIPS ABI version 5 for .MIPS.xhash,
marking the need of support for .MIPS.xhash in the dynamic linker (again,
addressed in the corresponding glibc patch). This is something which I
am not sure of, especially after reading [5]. I am confused on whether
this ABI version is reserved for IFUNC, or it can be used for this
purpose.

Already mentioned glibc patch is submitted at:
https://sourceware.org/ml/libc-alpha/2019-06/msg00456.html

[1] https://sourceware.org/ml/binutils/2015-10/msg00057.html
[2] https://sourceware.org/ml/binutils/2018-03/msg00025.html
[3] https://sourceware.org/ml/binutils/2016-01/msg00006.html
[4] https://sourceware.org/ml/binutils/2016-02/msg00097.html
[5] https://sourceware.org/ml/libc-alpha/2016-12/msg00853.html

ld      * emulparams/elf32bmip.sh: Add .MIPS.xhash section.
        * emulparams/elf32bmipn32-defs.sh: Add .MIPS.xhash section.
        * emulparams/elf64bmip-defs.sh: Add .MIPS.xhash section.
        * emultempl/mipself.em: Remove mips_after_parse function.
        * testsuite/ld-elf/hash.d: Update comment.
        * testsuite/ld-mips-elf/hash1.d: New test.
        * testsuite/ld-mips-elf/hash1.s: Ditto.
        * testsuite/ld-mips-elf/hash1a.d: Remove.
        * testsuite/ld-mips-elf/hash1b.d: Ditto.
        * testsuite/ld-mips-elf/hash1c.d: Ditto
        * testsuite/ld-mips-elf/hash2.d: New test.
        * testsuite/ld-mips-elf/mips-elf.exp: New tests.
        * testsuite/ld-mips-elf/start.s: New test.

bfd     * elf-bfd.h (struct elf_backend_data): New members.
        * elflink.c (_bfd_elf_link_create_dynamic_sections): Create
        .gnu.hash section if necessary.
        (struct collect_gnu_hash_codes): New member.
        (elf_gnu_hash_process_symidx): New function name.
        (elf_renumber_gnu_hash_syms): Ignore local and undefined
        symbols. Record xlat location for every symbol which should have
        a .MIPS.xhash entry.
        (bfd_elf_size_dynamic_sections): Add DT_GNU_HASH dynamic tag to
        dynamic section if necessary.
        (GNU_HASH_SECTION_NAME): New define.
        (bfd_elf_size_dynsym_hash_dynstr): Get .MIPS.xhash section.
        Update the section size info.
        * elfxx-mips.c (struct mips_elf_hash_sort_data): New members.
        (struct mips_elf_link_hash_entry): New member.
        (mips_elf_link_hash_newfunc): Initialize .MIPS.xhash translation
        table location.
        (mips_elf_sort_hash_table): Initialize the pointer to the
        .MIPS.xhash section.
        (mips_elf_sort_hash_table_f): Populate the .MIPS.xhash
        translation table entry with the symbol dynindx.
        (_bfd_mips_elf_section_from_shdr): Add SHT_MIPS_XHASH.
        (_bfd_mips_elf_fake_sections): Initialize .MIPS.xhash section
        info.
        (_bfd_mips_elf_create_dynamic_sections): Create .MIPS.xhash
        section.
        (_bfd_mips_elf_size_dynamic_sections): Add DT_MIPS_XHASH tag to
        dynamic section.
        (_bfd_mips_elf_finish_synamic_sections): Add DT_MIPS_XHASH.
        (_bfd_mips_elf_final_write_processing): Set .MIPS.xhash section
        sh_link info.
        (_bfd_mips_elf_get_target_dtag): Get DT_MIPS_XHASH tag.
        (MIPS_LIBC_ABI_XHASH): New ABI version enum value.
        (_bfd_mips_post_process_headers): Mark the ABI version as
        MIPS_LIBC_ABI_XHASH if there exists a .MIPS.xhash section,
        but not a .hash section.
        (_bfd_mips_elf_record_xhash_symbol): New function. Record a
        position in the translation table, associated with the hash
        entry.
        * elfxx-mips.h (literal_reloc_p): Define
        elf_backend_record_xhash_symbol backend hook.
        * elfxx-target.h: Initialize elf_backend_record_xhash_symbol
        backend hook.

include * elf/mips.h (SHT_GNU_XHASH): New define.
        (DT_GNU_XHASH): New define.

binutils * readelf.c (get_mips_dynamic_type): Return MIPS_XHASH dynamic type.
        (get_mips_section_type_name): Return MI{S_XHASH name string.
        (dynamic_section_mips_val): Initialize the .MIPS.xhash dynamic
        info.
        (process_symbol_table): Initialize the .MIPS.xhash section
        pointer. Adjust the readelf output to support the new section.
        (process_object): Set the .MIPS.xhash dynamic info to zero.
2019-08-09 11:06:37 +01:00
Nick Clifton dbe15e4e1d Change the output of readelf's note display so that the "Data size" column header is left justified.
PR 24887
binutils* readelf.c (process_notes_at): Left justify the "Data size"
	column heading.
	* testsuite/binutils-all/i386/empty.d: Adjust for new output format.
	* testsuite/binutils-all/i386/ibt.d: Likewise.
	* testsuite/binutils-all/i386/pr21231a.d: Likewise.
	* testsuite/binutils-all/i386/pr21231b.d: Likewise.
	* testsuite/binutils-all/i386/shstk.d: Likewise.
	* testsuite/binutils-all/note-2-32.d: Likewise.
	* testsuite/binutils-all/note-2-64.d: Likewise.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk.d: Likewise.

ld	* testsuite/ld-aarch64/bti-plt-2.d: Adjust for new output format
	from readelf.
	* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: Likewise.
	* testsuite/ld-aarch64/property-bti-pac1.d: Likewise.
	* testsuite/ld-aarch64/property-bti-pac2.d: Likewise.
	* testsuite/ld-aarch64/property-bti-pac3.d: Likewise.
	* testsuite/ld-elf/x86-feature-1a.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1b.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1c.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1d.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1e.rd: Likewise.
	* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
	* testsuite/ld-i386/pr23372a.d: Likewise.
	* testsuite/ld-i386/pr23372c.d: Likewise.
	* testsuite/ld-i386/pr23486a.d: Likewise.
	* testsuite/ld-i386/pr23486b.d: Likewise.
	* testsuite/ld-i386/pr23486c.d: Likewise.
	* testsuite/ld-i386/pr23486d.d: Likewise.
	* testsuite/ld-i386/pr24322a.d: Likewise.
	* testsuite/ld-i386/pr24322b.d: Likewise.
	* testsuite/ld-i386/property-x86-3.d: Likewise.
	* testsuite/ld-i386/property-x86-4a.d: Likewise.
	* testsuite/ld-i386/property-x86-5.d: Likewise.
	* testsuite/ld-i386/property-x86-cet1.d: Likewise.
	* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
	* testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372a.d: Likewise.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486a.d: Likewise.
	* testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486b.d: Likewise.
	* testsuite/ld-x86-64/pr23486c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486c.d: Likewise.
	* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486d.d: Likewise.
	* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.d: Likewise.
	* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458a.d: Likewise.
	* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458b.d: Likewise.
	* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458c.d: Likewise.
	* testsuite/ld-x86-64/property-1.r: Likewise.
	* testsuite/ld-x86-64/property-1a.r: Likewise.
	* testsuite/ld-x86-64/property-2.r: Likewise.
	* testsuite/ld-x86-64/property-2a.r: Likewise.
	* testsuite/ld-x86-64/property-3.r: Likewise.
	* testsuite/ld-x86-64/property-3a.r: Likewise.
	* testsuite/ld-x86-64/property-4.r: Likewise.
	* testsuite/ld-x86-64/property-4a.r: Likewise.
	* testsuite/ld-x86-64/property-5.r: Likewise.
	* testsuite/ld-x86-64/property-5a.r: Likewise.
	* testsuite/ld-x86-64/property-6.r: Likewise.
	* testsuite/ld-x86-64/property-7.r: Likewise.
	* testsuite/ld-x86-64/property-7a.r: Likewise.
	* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.

gas	* testsuite/gas/i386/property-1.d: Adjust for new output format
	from readelf.
	* testsuite/gas/i386/property-2.d: Likewise.
	* testsuite/gas/i386/x86-64-property-1.d: Likewise.
	* testsuite/gas/i386/x86-64-property-2.d: Likewise.
2019-08-08 17:04:31 +01:00
Jose E. Marchesi fca8e23c31 ld: use a specific linker script in BPF targets
This patch makes the elf64bpf emulation to use it's own linker script,
based on elf.sc.  At the moment, the only change is that the BPF
executable doesn't define an entry symbol (BPF programs feature
several entry points scattered in several sections.)

This is a step towards the goal of generating proper ELF executables
that would be loaded by the kernel's libbpf.  We are not there yet:
BPF "programs" should still be linked with -r.

This change removes a warning while linking executables, decreases the
number of unsupported tests in the target from 47 to 29, and increases
the number of expected passes from 104 to 145.

Regtested in x86_64 for all targets.
No regressions.

ld/ChangeLog:

2019-08-07  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* scripttempl/elf64bpf.sc: Adapted from elf.sc.
	* emulparams/elf64bpf.sh (SCRIPT_NAME): Use elf64bpf.
	(EMBEDDED): Define.
	* testsuite/ld-bpf/call-1.d: Do not expect a warning regarding an
	undefined entry symbol.
	* testsuite/ld-bpf/jump-1.d: Likewise.
	* testsuite/ld-undefined/undefined.exp: Do not pass '-e entry' to
	ld in BPF targets, and do not expect line number information.
	* testsuite/ld-srec/srec.exp (run_srec_test): xfail s-record tests
	in BPF targets.
2019-08-07 13:57:30 +02:00
Alan Modra 128bf1fe60 LTO object insertion point
This is a mostly cosmetic fix for cases like PR24873 where LTO
recompiled objects were supposed to be inserted inside a group.  The
specific case handled by this patch is when the first file inside a
group is an archive, the first file claimed by the plugin.  Prior to
this patch we would have inserted the recompiled objects before the
group, which doesn't matter really since the entire group will be
reloaded, but it looks a little wrong in map files.

	PR 24873
	* ldlang.c (find_replacements_insert_point): Return "before" flag.
	(find_next_input_statement): New function.
	(lang_process): When placing recompiled LTO objects before a
	claimed archive, place them immediately before in the statement
	list.
2019-08-06 15:47:41 +09:30
Alan Modra b02c4f1623 PR24873, gcc -flto objects result in --start-group .. --end-group failure to include --as-needed libraries
Reloading of archives (and checking --as-needed DSOs again) is
disabled until we hit the plugin insert point.  It's necessary to do
that because in a case like lib1.a lto.o lib2.a where lib1.a and
lib2.a contain duplicate symbols, we want the lto.o recompiled object
to pull in objects from lib2.a as necessary, but not from lib1.a.
Unfortunately this heuristic fails when the insert point is inside a
group, because ld actually loads the symbols from the recompiled
object before running over the contours of the script, thus missing
the fact that new undefs appeared in the group.

	PR 24873
	* ldlang.c (plugin_undefs): New static var.
	(open_input_bfds <lang_group_statement_enum>): Loop on
	plugin_undefs and hitting plugin_insert point.
	(lang_process <lto_plugin_active>): Set plugin_undefs.
2019-08-06 15:37:08 +09:30
Alan Modra 1b611b2dc3 PowerPC tlsie test fix
* testsuite/ld-powerpc/tlsie.s: Correct medium model ELF sequence.
2019-08-02 12:41:05 +09:30
Alan Modra 776ab89fe3 PR24806, Linking with -T inside --start-group/--end-group
This patch processes INSERT AFTER and INSERT BEFORE in a user -T
script when such a script is invoked on the command line inside
--start-group/--end-group.  Also, ld now warns when the user simply
forgot --end-group.

	PR 24806
	* ldlang.c (process_insert_statements): Add start of list
	parameter.  Use rather than lang_os_list.head.  Process insert
	statements inside group statements with a recursive call.
	(lang_process): Adjust process_insert_statements call.
	* lexsup.c (parse_args): Warn when adding missing --end-group.
2019-08-01 14:38:57 +09:30
Alan Modra 5c1e6d53a5 Rename lang_output_section_statement to lang_os_list
The idea is to make it a little easier to find uses of this list,
so searches don't hit occurrences of lang_output_section_statement_type
and lang_output_section_statement_enum.

	* ldlang.h (lang_os_list): Rename from lang_output_section_statement.
	* ldlang.c: Likewise throughout file.
	* emultempl/alphaelf.em: Likewise.
	* emultempl/elf32.em: Likewise.
	* emultempl/mmo.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
2019-08-01 11:57:25 +09:30
Alan Modra 6e99a238f0 Ajdust lto-3r and lto-5r tests for powerpc64
* testsuite/ld-plugin/lto-3r.d: Accept D for powerpc64 descriptors.
	* testsuite/ld-plugin/lto-5r.d: Likewise.
2019-07-26 10:02:34 +09:30
H.J. Lu 8f79c1075e Revert "Remove tests that test __gnu_lto_v1 symbol."
Revert

commit 8c728a9d93
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jul 22 14:23:32 2019 +0200

    Remove tests that test __gnu_lto_v1 symbol.

since outputs of these tests are used by later tests.  Check the normal
symbol, foo, instead of __gnu_lto_v.*, which GCC stopped emitting after
r273662.

	* testsuite/ld-plugin/lto-3r.d: Restored.  Check foo instead
	of __gnu_lto_v.*.
	* testsuite/ld-plugin/lto-5r.d: Likewise.
	* testsuite/ld-plugin/lto.exp: Run lto-3r and lto-5r tests.
2019-07-24 08:17:33 -07:00
Claudiu Zissulescu ef551643dc [ARC] Add linker relaxation.
Add linker relaxation. The first relaxation added is converting
GOTPC32 to PCREL relocations. This relaxation doesn't change the size of
the binary.

bfd/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* elf32-arc.c (bfd_get_32_me): New function.
	(bfd_put_32_me): Likewise.
	(arc_elf_relax_section): Likewise.
	(bfd_elf32_bfd_relax_section): Define.

ld/testsuite/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* ld-arc/relax-local-pic.d: New test.
	* ld-arc/relax-local-pic.s: New file.
2019-07-24 16:33:29 +03:00
H.J. Lu 19889a5835 Add missing ChangeLog entries for
commit 8c728a9d93
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jul 22 14:23:32 2019 +0200

    Remove tests that test __gnu_lto_v1 symbol.
2019-07-23 08:40:23 -07:00
Alan Modra df3a023bd6 SHF_GNU_MBIND requires ELFOSABI_GNU
When SHF_GNU_MBIND was added in the SHF_LOOS to SHF_HIOS range, it
should have required ELFOSABI_GNU since these flags are already in use
by other OSes.  HPUX SHF_HP_TLS in fact has the same value.  That
means no place in binutils should test SHF_GNU_MBIND without first
checking OSABI, and SHF_GNU_MBIND should not be set without also
setting OSABI.  At least, that's the ideal, but the patch accepts
SHF_GNU_MBIND on ELFOSABI_NONE object files since gas didn't always
set OSABI.  However, to reinforce the fact that SHF_GNU_MBIND isn't
proper without a non-zero OSABI, readelf will display the flag as
LOOS+0 if OSABI isn't set.

The clash with SHF_HP_TLS means that hppa64-linux either has that flag
on .tbss sections or supports GNU_MBIND, not both.  (hppa64-linux
users, if there are any, may have noticed that GNU ld since 2017
mysteriously aligned their .tbss sections to a 4k boundary.  That was
one consequence of SHF_HP_TLS being blindly interpreted as
SHF_GNU_MBIND.)  Since it seems that binutils, gdb, gcc, glibc, and
the linux kernel don't care about SHF_HP_TLS I took that flag out of
.tbss for hppa64-linux.

bfd/
	* elf-bfd.h (enum elf_gnu_osabi): Add elf_gnu_osabi_mbind.
	* elf.c (_bfd_elf_make_section_from_shdr): Set elf_gnu_osabi_mbind.
	(get_program_header_size): Formatting.  Only test SH_GNU_MBIND
	when elf_gnu_osabi_mbind is set.
	(_bfd_elf_map_sections_to_segments): Likewise.
	(_bfd_elf_init_private_section_data): Likewise.
	(_bfd_elf_final_write_processing): Update comment.
	* elf64-hppa.c (elf64_hppa_special_sections): Move .tbss entry.
	(elf_backend_special_sections): Define without .tbss for linux.
binutils/
	* readelf.c (get_parisc_segment_type): Split off hpux entries..
	(get_ia64_segment_type): ..and these..
	(get_hpux_segment_type): ..to here.
	(get_segment_type): Condition GNU_MBIND on osabi.  Use
	get_hpux_segment_type.
	(get_symbol_binding): Do not print UNIQUE for ELFOSABI_NONE.
	(get_symbol_type): Do not print IFUNC for ELFOSABI_NONE.
gas/
	* config/obj-elf.c (obj_elf_change_section): Don't emit a fatal
	error for non-SHF_ALLOC SHF_GNU_MBIND here.
	(obj_elf_parse_section_letters): Return SHF_GNU_MBIND in new
	gnu_attr param.
	(obj_elf_section): Adjust obj_elf_parse_section_letters call.
	Formatting.  Set SHF_GNU_MBIND and elf_osabi from gnu_attr.
	Emit normal error for non-SHF_ALLOC SHF_GNU_MBIND and wrong osabi.
	(obj_elf_type): Set elf_osabi for ifunc.
	* testsuite/gas/elf/section12a.d: xfail msp430 and hpux.
	* testsuite/gas/elf/section12b.d: Likewise.
	* testsuite/gas/elf/section13.d: Likewise.
	* testsuite/gas/elf/section13.l: Adjust expected error.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Condition
	SHF_GNU_MBIND on osabi.  Set output elf_gnu_osabi_mbind.
2019-07-23 18:22:02 +09:30
Alan Modra ec49711a16 Move ld-scripts size tests
Also restore them somewhat closer to the original.  They originally
failed on many targets, and a month later I "simplified" them as part
of a larger patch fixing other failing tests.  That unfortunately lost
their main purpose, which was to test TLS layout.

	* testsuite/ld-elf/size-1.d,
	* testsuite/ld-elf/size-1.s,
	* testsuite/ld-elf/size-1.t: New test.
	* testsuite/ld-elf/size-2.d,
	* testsuite/ld-elf/size-2.s,
	* testsuite/ld-elf/size-2.t: New test.
	* testsuite/ld-scripts/size-1.d,
	* testsuite/ld-scripts/size-1.s,
	* testsuite/ld-scripts/size-1.t,
	* testsuite/ld-scripts/size-2.s,
	* testsuite/ld-scripts/size-2.d,
	* testsuite/ld-scripts/size-2.t,
	* testsuite/ld-scripts/size.exp: Delete.
2019-07-23 18:22:01 +09:30
Srinath Parvathaneni 0c628bba5a Fixes the linker testcase "Secure gateway veneers:cmse functions debug information missing" which was failing due to output regular expression mismatch on arm-none-linux-gnueabihf targets.
* ld/testsuite/ld-arm/cmse_main_sec_debug.d: Modify regexps to
	allow for output from a arm-none-linux-gnueabihf target.
2019-07-22 14:46:11 +01:00
Alan Modra 9ab3a74416 PR24827, Linker loops forever if unterminated multi-line comment in script
YY_INPUT returns 0 on end of input, not EOF.

	PR 24827
	* ldlex.l (comment): Check for 0 return from input(), not EOF.
2019-07-20 10:55:16 +09:30
Alan Modra c213164ad2 [PowerPC64] pc-relative TLS relocations
This patch supports using pcrel instructions in TLS code sequences.  A
number of new relocations are needed, gas operand modifiers to
generate those relocations, and new TLS optimisation.  For
optimisation it turns out that the new pcrel GD and LD sequences can
be distinguished from the non-pcrel GD and LD sequences by there being
different relocations on the new sequence.  The final "add ra,rb,13"
on IE sequences similarly needs a new relocation, or as I chose, a
modification of R_PPC64_TLS.  On pcrel IE code, the R_PPC64_TLS points
one byte into the "add" instruction rather than being on the
instruction boundary.

GD:
 pla 3,z@got@tlsgd@pcrel	  # R_PPC64_GOT_TLSGD34
 bl __tls_get_addr@notoc(z@tlsgd) # R_PPC64_TLSGD and R_PPC64_REL24_NOTOC
  edited to IE
   pld 3,z@got@tprel@pcrel
   add 3,3,13
  edited to LE
   paddi 3,13,z@tprel
   nop

LD:
 pla 3,z@got@tlsld@pcrel	  # R_PPC64_GOT_TLSLD34
 bl __tls_get_addr@notoc(z@tlsld) # R_PPC64_TLSLD and R_PPC64_REL24_NOTOC
 ..
 paddi 9,3,z2@dtprel
 pld 10,z3@got@dtprel@pcrel
 add 10,10,3
  edited to LE
   paddi 3,13,0x1000
   nop

IE:
 pld 9,z@got@tprel@pcrel	  # R_PPC64_GOT_TPREL34
 add 3,9,z@tls@pcrel		  # R_PPC64_TLS at insn+1
 ldx 4,9,z@tls@pcrel
 lwax 5,9,z@tls@pcrel
 stdx 5,9,z@tls@pcrel
  edited to LE
  paddi 9,13,z@tprel
  nop
  ld 4,0(9)
  lwa 5,0(9)
  std 5,0(9)

LE:
 paddi 10,13,z@tprel

include/
	* elf/ppc64.h (R_PPC64_TPREL34, R_PPC64_DTPREL34),
	(R_PPC64_GOT_TLSGD34, R_PPC64_GOT_TLSLD34),
	(R_PPC64_GOT_TPREL34, R_PPC64_GOT_DTPREL34): Define.
	(IS_PPC64_TLS_RELOC): Include new tls relocs.
bfd/
	* reloc.c (BFD_RELOC_PPC64_TPREL34, BFD_RELOC_PPC64_DTPREL34),
	(BFD_RELOC_PPC64_GOT_TLSGD34, BFD_RELOC_PPC64_GOT_TLSLD34),
	(BFD_RELOC_PPC64_GOT_TPREL34, BFD_RELOC_PPC64_GOT_DTPREL34),
	(BFD_RELOC_PPC64_TLS_PCREL): New pcrel tls relocs.
	* elf64-ppc.c (ppc64_elf_howto_raw): Add howtos for pcrel tls relocs.
	(ppc64_elf_reloc_type_lookup): Translate pcrel tls relocs.
	(must_be_dyn_reloc, dec_dynrel_count): Add R_PPC64_TPREL64.
	(ppc64_elf_check_relocs): Support pcrel tls relocs.
	(ppc64_elf_tls_optimize, ppc64_elf_relocate_section): Likewise.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
gas/
	* config/tc-ppc.c (ppc_elf_suffix): Map "tls@pcrel", "got@tlsgd@pcrel",
	"got@tlsld@pcrel", "got@tprel@pcrel", and "got@dtprel@pcrel".
	(fixup_size, md_assemble): Handle pcrel tls relocs.
	(ppc_force_relocation, ppc_fix_adjustable): Likewise.
	(md_apply_fix, tc_gen_reloc): Likewise.
ld/
	* testsuite/ld-powerpc/tlsgd.d,
	* testsuite/ld-powerpc/tlsgd.s,
	* testsuite/ld-powerpc/tlsie.d,
	* testsuite/ld-powerpc/tlsie.s,
	* testsuite/ld-powerpc/tlsld.d,
	* testsuite/ld-powerpc/tlsld.s: New tests.
	* testsuite/ld-powerpc/powerpc.exp: Run them.
2019-07-19 18:01:25 +09:30
Alan Modra 7a70898417 [PowerPC] Rename testcase
Just making room for a new tlsld test.

	* testsuite/ld-powerpc/tlsldopt.d: Rename from tlsld.d.
	* testsuite/ld-powerpc/tlsldopt.s: Rename from tlsld.s.
	* testsuite/ld-powerpc/tlsldopt32.d: Rename from tlsld32.d.
	* testsuite/ld-powerpc/tlsldopt32.s: Rename from tlsld32.s.
	* testsuite/ld-powerpc/powerpc.exp: Update.
2019-07-19 18:01:25 +09:30
Alan Modra 88468fe096 Re: ld -r: Don't merge with member of output section group
PR 24819
	* testsuite/ld-elf/pr24819.d: xfail for genelf targets.
2019-07-19 18:01:25 +09:30
H.J. Lu 54d7dae59a ld -r: Don't merge with member of output section group
When doing a relocatable link, members of input section group are
placed in their own output sections.  We need to make sure that no
input sections are merged with member of output section group.

	PR ld/24819
	* emultempl/elf32.em (elf_orphan_compatible): Return FALSE for
	member of output section group when doing a relocatable link.
	* testsuite/ld-elf/pr24819.d: New file.
	* testsuite/ld-elf/pr24819.s: Likewise.
2019-07-18 08:01:54 -07:00
Alan Modra f26a32876b Dynamic TLS section symbols
It is possible to create shared libraries on PowerPC using
-ftls-model=inital-exec or -ftls-model=local-exec.  The first is half
reasonable, getting you a shared library that can't be dlopen'd but
otherwise is reasonable.  The second is quite bad.  Not only do you
lose being able to dlopen, the library also has dynamic text
relocations.  Worse, the TPREL16_LO, TPREL16_HA and other TPREL16
dynamic relocs emitted were wrong, resulting in wrong values being
applied by ld.so.

Using the first TLS section symbol in dynamic relocations for local
TLS symbols doesn't work.  It's wrong because TLS symbols used by TLS
relocs have values relative to the TLS segment, whereas the TLS
section symbols are addresses.  This patch instead uses a symbol index
of zero which is used elsewhere by PowerPC on dynamic TLS relocs.
It's not strictly ABI compliant to use a non-TLS symbol with TLS
relocs but symbol index zero can be interpreted as "no symbol".  Not
using the first TLS section symbol means it doesn't need to be dynamic.

The patch also fixes a further problem with PowerPC32 dynamic TPREL16*
relocs, which shouldn't have the symbol value in the addend as we do
for non-TLS symbols.

bfd/
	* elflink.c (_bfd_elf_omit_section_dynsym_default): Don't keep
	tls_sec.
	(_bfd_elf_init_1_index_section): Prefer not using TLS sections.
	(_bfd_elf_init_2_index_sections): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): When emitting dynamic
	relocations for local TLS symbols, use STN_UNDEF as the relocation
	symbol.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise, and don't
	leave TLS symbol value in the addend.
ld/
	* testsuite/ld-powerpc/tlsso.r: Update.
	* testsuite/ld-powerpc/tlsso32.g: Update.
	* testsuite/ld-powerpc/tlsso32.r: Update.
	* testsuite/ld-powerpc/tlstocso.r: Update.
	* testsuite/ld-cris/tls-dso-dtpoffd2.d: Update.
	* testsuite/ld-cris/tls-dso-dtpoffd4.d: Update.
	* testsuite/ld-cris/tls-dso-tpoffgotcomm1.d: Update.
	* testsuite/ld-cris/tls-gd-1.d: Update.
	* testsuite/ld-cris/tls-gd-1h.d: Update.
	* testsuite/ld-cris/tls-gd-2.d: Update.
	* testsuite/ld-cris/tls-gd-2h.d: Update.
	* testsuite/ld-cris/tls-ie-10.d: Update.
	* testsuite/ld-cris/tls-ie-11.d: Update.
	* testsuite/ld-cris/tls-ie-8.d: Update.
	* testsuite/ld-cris/tls-ie-9.d: Update.
	* testsuite/ld-cris/tls-js1.d: Update.
	* testsuite/ld-cris/tls-ld-4.d: Update.
	* testsuite/ld-cris/tls-ld-5.d: Update.
	* testsuite/ld-cris/tls-ld-6.d: Update.
	* testsuite/ld-cris/tls-ld-7.d: Update.
	* testsuite/ld-cris/tls-ldgd-14.d: Update.
	* testsuite/ld-cris/tls-ldgd-15.d: Update.
	* testsuite/ld-cris/tls-ldgdx-14.d: Update.
	* testsuite/ld-cris/tls-ldgdx-15.d: Update.
	* testsuite/ld-cris/tls-local-54.d: Update.
	* testsuite/ld-cris/tls-local-60.d: Update.
	* testsuite/ld-cris/tls-local-61.d: Update.
	* testsuite/ld-cris/tls-local-63.d: Update.
	* testsuite/ld-cris/tls-local-64.d: Update.
	* testsuite/ld-cris/tls-ok-30.d: Update.
	* testsuite/ld-cris/tls-ok-32.d: Update.
	* testsuite/ld-cris/tls-ok-34.d: Update.
	* testsuite/ld-mips-elf/tls-multi-got-1.got: Update.
	* testsuite/ld-mips-elf/tls-multi-got-1.r: Update.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.d: Update.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.got: Update.
	* testsuite/ld-mips-elf/tlslib-o32-hidden.got: Update.
	* testsuite/ld-mips-elf/tlslib-o32-ver.got: Update.
	* testsuite/ld-mips-elf/tlslib-o32.got: Update.
	* testsuite/ld-s390/tlspic.rd: Update.
	* testsuite/ld-s390/tlspic_64.rd: Update.
	* testsuite/ld-sparc/tlssunnopic32.rd: Update.
	* testsuite/ld-sparc/tlssunnopic64.rd: Update.
	* testsuite/ld-sparc/tlssunpic32.rd: Update.
	* testsuite/ld-sparc/tlssunpic64.rd: Update.
2019-07-13 09:57:50 +09:30
Alan Modra 7b2438015c PR24786, wrong LMA if first section in overlay is empty
This stops the first overlay section being ignored when empty,
losing its LMA assignment

	PR 24786
	* ldlang.h (enum section_type): Add first_overlay_section.
	* ldlang.c (lang_add_section): Adjust switch statement.
	(map_input_to_output_sections): Likewise.
	(lang_size_sections_1): Always set last_os for first overlay section.
	(lang_leave_overlay): Set sectype to first_overlay_section.
2019-07-13 09:57:50 +09:30
Alan Modra 3836e1d1ab Re: PowerPC notoc call stub tests
Correct the tests for powerpc 32-bit targets.

	* testsuite/ld-powerpc/callstub-1.d: Pass -melf64ppc to ld.
	* testsuite/ld-powerpc/callstub-2.d: Likewise.
2019-07-08 15:24:14 +09:30
Jan Beulich f2d4ba38f5 gas/ELF: don't accumulate .type settings
Recently a patch was submitted for a Xen Project test harness binary to
override the compiler specified @object to @func (see [1]). In a reply I
suggested we shouldn't make ourselves dependent on currently unspecified
behavior of gas here: It accumulates all requests, and then
bfd/elf.c:swap_out_syms(), in an apparently ad hoc manner, prioritizes
certain flags over others.

Make the behavior predictable: Generally the last .type is what counts.
Exceptions are directives which set multiple bits (TLS, IFUNC, and
UNIQUE): Subsequent directives requesting just the more generic bit
(i.e. FUNC following IFUNC) won't clear the more specific one.  Warn
about incompatible changes, except from/to STT_NOTYPE.

Also add a new target hook, which hppa wants to use right away afaict.

In the course of adding the warning I ran into two ld testsuite
failures.  I can only assume that it was a copy-and-paste mistake that
lead to the same symbol having its type set twice.

[1] https://lists.xenproject.org/archives/html/xen-devel/2019-05/msg01980.html
2019-07-04 10:35:47 +02:00
Nick Clifton 125f83f66c Fix a bug recently introduced to the linker where it would complain about a section being larger than a file, even if the section was artificial.
PR 24753
bfd	* compress.c (bfd_get_full_section_contents): Do not complain
	about linker created sections that are larger than the file size.

ld	* emultempl/aarch64elf.em (_aarch64_add_stub_section): Include the
	LINKER_CREATED section flag when creating the stub section.
2019-07-02 14:14:13 +01:00
Srinath Parvathaneni bb32413ff7 Ensure that debug information is retained for ARMv8-M security functions.
Consider a file containing only Armv8-M secure entry functions.
This file is compiled and linked with "-march=armv8-m.main -mfloat-abi=hard
-mfpu=fpv5-sp-d16 -mcmse -static --specs=rdimon.specs
-Wl,--section-start,.gnu.sgstubs=0x190000 -ffunction-sections
-fdata-sections
-Wl,--gc-sections -g" options to generate an executable.

The executable generated does not contain any debug information of these
secure entry functions even though it contains secure entry functions in
the .text section.  This patch fixes this problem.
2019-07-02 12:43:59 +01:00
Nick Clifton 539300fb92 Correct the calculation of offsets for ARM exidx relocs when performing a partial link.
PR 23839
bfd	* elf32-arm.c (elf32_arm_update_relocs): Do not include the
	section VMA in the offset used to update exidx relocs.

ld	* testsuite/ld-arm/unwind-4.d: Adjust for corrected calculation of
	exidx relocs.
2019-07-01 11:17:01 +01:00
Alan Modra 60d53d7f03 PowerPC notoc call stub tests
* testsuite/ld-powerpc/callstub-1.d,
	* testsuite/ld-powerpc/callstub-1.s: New test.
	* testsuite/ld-powerpc/callstub-2.d,
	* testsuite/ld-powerpc/callstub-2.s: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run them.
2019-06-28 10:16:17 +09:30
Jan Beulich 8e5cb9a54e ld/plugins: avoid shadowing a C library symbol
With my (oldish) gcc/glibc combination I'm seeing

.../ld/plugin.c: In function ‘get_lto_kind’:
.../ld/plugin.c:664: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
.../ld/plugin.c: In function ‘get_lto_resolution’:
.../ld/plugin.c:685: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
.../ld/plugin.c: In function ‘get_lto_visibility’:
.../ld/plugin.c:711: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
2019-06-25 12:02:23 +02:00
H.J. Lu f93ab3a0b8 elf: Remove the property after reporting its removal
commit d2ef37ebd9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Dec 7 08:30:30 2018 -0800

    elf: Report property change when merging properties

failed to remove the property after reporting it has been removed.  This
patch corrects it.

bfd/

	PR ld/24721
	* elf-properties.c (elf_merge_gnu_property_list): Remove the
	property after reporting property removal.

ld/

	PR ld/24721
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests.
	* testsuite/ld-x86-64/pr24721-x32.d: New file.
	* testsuite/ld-x86-64/pr24721.d: Likewise.
	* testsuite/ld-x86-64/pr24721.map: Likewise.
	* testsuite/ld-x86-64/pr24721a.s: Likewise.
	* testsuite/ld-x86-64/pr24721b.s: Likewise.
2019-06-24 11:08:57 -07:00
Alan Modra bb22a41815 PR24704, Internal error building skiboot for powerpc64-linux-gnu
While the skiboot linker script bears some culpability in this PR,
it's also true that the GOT indirect to GOT relative optimisation for
16-bit offsets isn't safe.  At least, it isn't safe to remove the GOT
entry based on distance between the GOT pointer and symbol calculated
from the preliminary layout.  So this patch removes that optimisation,
and reduces the range allowed for 32-bit and 34-bit offsets.

	PR 24704
bfd/
	* elf64-ppc.c (R_PPC64_GOT16_DS): Don't set has_gotrel.
	(ppc64_elf_edit_toc): Don't remove R_PPC64_GOT16_DS got entries.
	Reduce range of offsets allowed for other GOT relocs.
ld/
	* testsuite/ld-powerpc/elfv2exe.d: Update.
	* testsuite/ld-powerpc/elfv2so.d: Update.
2019-06-23 23:11:27 +09:30
Szabolcs Nagy e30d1fa1bf Add R_AARCH64_P32_MOVW_PREL_* ELF32 relocs
These ilp32 relocations were missing for some reason.

bfd/ChangeLog:

	* elfnn-aarch64.c: Enable MOVW_PREL relocs for ELF32.

include/ChangeLog:

	* elf/aarch64.h (R_AARCH64_P32_MOVW_PREL_G0): Define.
	(R_AARCH64_P32_MOVW_PREL_G0_NC): Define.
	(R_AARCH64_P32_MOVW_PREL_G1): Define.

ld/ChangeLog:

	* testsuite/ld-aarch64/aarch64-elf.exp: Add emit-relocs-22 and -23.
	* testsuite/ld-aarch64/emit-relocs-22.d: New test.
	* testsuite/ld-aarch64/emit-relocs-22.s: New test.
	* testsuite/ld-aarch64/emit-relocs-23.d: New test.
	* testsuite/ld-aarch64/emit-relocs-23.s: New test.
2019-06-14 12:02:19 +01:00
Alan Modra 3a3a077c4a Regenerate with approved autotools version
bfd/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
binutils/
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* doc/Makefile.in: Regenerate.
gas/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
ld/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
libctf/
	* configure: Regenerate.
2019-06-14 10:30:35 +09:30
Alan Modra e3fa7860f4 Fix alpha testsuite regression
readelf st_other display improved for alpha.

	PR 24662
	* testsuite/ld-alpha/tlsbin.rd: Update.
	* testsuite/ld-alpha/tlsbinr.rd: Update.
	* testsuite/ld-alpha/tlspic.rd: Update.
2019-06-14 10:23:20 +09:30
Maciej W. Rozycki c1b00498af LD/doc: Clarify `-rpath' option's semantics WRT link-time dependencies
Mention in the description of the `-rpath' LD option the restrictions
the option has with respect to searching link-time dependencies of
shared objects referred in the link.  Previously these restrictions were
only documented along with the `-rpath-link' option, which may not be
the place one would consider when looking for the semantics of `-rpath'.

Copy the relevant part of the `-rpath-link' option description then,
splitting the now overlong paragraph into three, for legibility.

	ld/
	* ld.texi (Options): Also document `-rpath' option restrictions
	in the description of the option itself.
2019-06-07 19:25:21 +01:00
Sudakshina Das 237df8fe18 [BFD, AArch64] Fix PT_GNU_PROPERTY alignment issue
If the new GNU property section was being created by the linker
(this will happen only if none of the inputs have any GNU property
section but the command line to the linker forces a bti with
--force-bti), the alignment of the section and hence the program
header of PT_GNU_PROPERTY type was not being set correctly. This
patch fixes this issue.

bfd/ChangeLog:

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Set
	alignment of the new gnu property section.

ld/ChangeLog:

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
	* testsuite/ld-aarch64/property-bti-pac4-a.d: New test.
	* testsuite/ld-aarch64/property-bti-pac4-b.d: New test.
	* testsuite/ld-aarch64/property-bti-pac4.s: New test.
2019-06-06 12:27:41 +01:00
Sudakshina Das 8bf6d176b0 [LD, AArch64] Move ELF options behind -z
This patch moves the current AArch64 ld options of --force-bti
and --pac-plt to -z force-bti and -z pac-plt since these are
ELF specific options.

*** bfd/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* bfd-in.h: Change comment.
	* bfd-in2.h: Regenerate.
	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update warning.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties):
	Likwise.

*** ld/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Update options names.
	* emultempl/aarch64elf.em (OPTION_FORCE_BTI, OPTION_PAC_PLT): Remove.
	(PARSE_AND_LIST_LONGOPTS): Remove force-bti and pac-plt.
	(PARSE_AND_LIST_OPTIONS): Update to -z.
	(PARSE_AND_LIST_ARGS_CASE_Z_AARCH64): New.
	(PARSE_AND_LIST_ARGS_CASE_Z): Add PARSE_AND_LIST_ARGS_CASE_Z_AARCH64.
	(PARSE_AND_LIST_ARGS_CASES): Move cases for these options.
	* testsuite/ld-aarch64/bti-pac-plt-1.d: Update option.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-1.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-3.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-1.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-2.d: Likewise.
2019-06-06 12:21:14 +01:00
Nick Clifton ae9ac79e5e Harmonize readelf's output for version sections.
PR 24627
binutils * readelf.c (process_version_sections): Add 0x prefix to address
	display.  Correct indentation.

ld	* testsuite/ld-elf/ver_def.vd: Update expected output.
2019-05-30 10:17:29 +01:00
Alan Modra 6ff185b890 s12z genelf.em
This changes s12z to use generic.em and genelf.em, which is more
suited to targets that use the generic linker hash table.  A tweak or
two to some testsuite predicates then gives a clean testsuite result
on the target.

	PR 24596
binutils/
	* testsuite/lib/binutils-common.exp (supports_gnu_unique): Add
	s12z to targets not supporting this feature.
ld/
	* emulparams/m9s12zelf.sh (TEMPLATE_NAME): Set to generic.
	(EXTRA_EM_FILE): Define to genelf.
	* testsuite/lib/ld-lib.exp (uses_genelf): Add s12z.
2019-05-30 01:01:42 +09:30
Alan Modra 1336939d3c Support tcl procedure calls in run_dump_test xfail
Also support tcl procedure calls in the run_ld_link_tests and
run_ld_link_exec_tests optional "xfail" args.  Implements "is_generic"
and renames "is_generic_elf" to "uses_genelf", then uses these procs
in lots of ld tests.

moxie-elf  -FAIL: ld-elf/orphan3
mt-elf  -FAIL: ld-elf/merge
s12z-elf  -FAIL: ld-discard/extern
s12z-elf  -FAIL: ld-discard/start
s12z-elf  -FAIL: ld-discard/static
s12z-elf  -FAIL: PR ld/21703
s12z-elf  -FAIL: PR ld/21703 -r
s12z-elf  -FAIL: Symbol flags copy
s12z-elf  -FAIL: ld-elf/group1
s12z-elf  -FAIL: ld-elf/group3b
s12z-elf  -FAIL: ld-elf/group8a
s12z-elf  -FAIL: ld-elf/group8b
s12z-elf  -FAIL: ld-elf/group9a
s12z-elf  -FAIL: ld-elf/group9b
s12z-elf  -FAIL: ld-elf/linkonce2
s12z-elf  -FAIL: ld-elf/merge2
s12z-elf  -FAIL: ld-elf/merge3
s12z-elf  -FAIL: ld-elf/pr12851
s12z-elf  -FAIL: ld-elf/pr17550c
s12z-elf  -FAIL: ld-elf/pr17550d
s12z-elf  -FAIL: ld-elf/pr22677
s12z-elf  -FAIL: ld-elf/pr22836-1a
s12z-elf  -FAIL: ld-elf/pr22836-1b
s12z-elf  -FAIL: ld-elf/warn1
s12z-elf  -FAIL: ld-elf/warn3

binutils/
	* testsuite/lib/binutils-common.exp (run_dump_test): Support
	tcl procedures for xfail args.
ld/
	* testsuite/lib/ld-lib.exp (run_ld_link_tests): Support procedure
	calls in optional "xfail" args.
	(run_ld_link_exec_tests): Likewise.
	(is_generic): New.
	(uses_genelf): Rename from is_generic_elf.  Delete bogus semicolons.
	* testsuite/ld-scripts/align.exp: Rename is_generic_elf call.
	* testsuite/ld-elf/elf.exp: Use is_generic and uses_genelf.  Delete
	xfail_implib var.
	* testsuite/ld-elf/sec64k.exp: Use is_generic.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-discard/extern.d: Use is_generic in xfail.
	* testsuite/ld-discard/start.d: Likewise.
	* testsuite/ld-discard/static.d: Likewise.
	* testsuite/ld-elf/attributes.d: Likewise.
	* testsuite/ld-elf/group1.d: Likewise.
	* testsuite/ld-elf/group3b.d: Likewise.
	* testsuite/ld-elf/group8a.d: Likewise.
	* testsuite/ld-elf/group8b.d: Likewise.
	* testsuite/ld-elf/group9a.d: Likewise.
	* testsuite/ld-elf/group9b.d: Likewise.
	* testsuite/ld-elf/linkonce2.d: Likewise.
	* testsuite/ld-elf/merge2.d: Likewise.
	* testsuite/ld-elf/merge3.d: Likewise.
	* testsuite/ld-elf/pr12851.d: Likewise.
	* testsuite/ld-elf/pr12975.d: Likewise.
	* testsuite/ld-elf/pr13177.d: Likewise.
	* testsuite/ld-elf/pr13195.d: Likewise.
	* testsuite/ld-elf/pr17550c.d: Likewise.
	* testsuite/ld-elf/pr17550d.d: Likewise.
	* testsuite/ld-elf/pr17615.d: Likewise.
	* testsuite/ld-elf/pr21562a.d: Likewise.
	* testsuite/ld-elf/pr21562b.d: Likewise.
	* testsuite/ld-elf/pr21562c.d: Likewise.
	* testsuite/ld-elf/pr21562d.d: Likewise.
	* testsuite/ld-elf/pr21562i.d: Likewise.
	* testsuite/ld-elf/pr21562j.d: Likewise.
	* testsuite/ld-elf/pr21562k.d: Likewise.
	* testsuite/ld-elf/pr21562l.d: Likewise.
	* testsuite/ld-elf/pr21562m.d: Likewise.
	* testsuite/ld-elf/pr21562n.d: Likewise.
	* testsuite/ld-elf/pr22677.d: Likewise.
	* testsuite/ld-elf/pr22836-1a.d: Likewise.
	* testsuite/ld-elf/pr22836-1b.d: Likewise.
	* testsuite/ld-elf/warn3.d: Likewise.
	* testsuite/ld-elf/warn1.d: Likewise and xfail sparc solaris
	targets rather than notarget.
	* testsuite/ld-elf/compressed1d.d: Use uses_genelf in xfail.
	* testsuite/ld-elf/orphan-10.d: Likewise.
	* testsuite/ld-elf/orphan-9.d: Likewise.
	* testsuite/ld-elf/orphan-region.d: Likewise.
	* testsuite/ld-elf/orphan.d: Likewise.
	* testsuite/ld-elf/orphan3.d: Likewise.
	* testsuite/ld-elf/pr20528a.d: Likewise.
	* testsuite/ld-elf/pr20528b.d: Likewise.
	* testsuite/ld-elf/pr23658-1a.d: Likewise.
	* testsuite/ld-elf/pr23658-1b.d: Likewise.
	* testsuite/ld-elf/pr349.d: Likewise.
	* testsuite/ld-elf/warn2.d: Likewise and xfail sparc solaris
	targets rather than notarget.
	* testsuite/ld-elf/merge.d: Correct ms1-*-* to mt-*-*.
2019-05-30 00:52:08 +09:30
Faraz Shahbazker 1e129bbefa MIPS/LD: Skip overflow check for %pcrel_hi relocations
Overflow checks were removed for all hi16 relocations except PC-relative
high relocations per PR ld/16720.  Remove overflow checks from %pcrel_hi
relocations so that we can correctly handle negative offsets from PC.

bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>:
	Remove overflow check.

ld/
	* testsuite/ld-mips-elf/undefweak-overflow.s: Remove test case
	for pcrel_hi/pcrel_lo.
	* testsuite/ld-mips-elf/undefweak-overflow.d: Update to match.
	* testsuite/ld-mips-elf/reloc-pcrel-r6.s: New test source.
	* testsuite/ld-mips-elf/reloc-pcrel-r6.d: New test linker script.
	* testsuite/ld-mips-elf/reloc-pcrel-r6.ld: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2019-05-28 10:49:16 -07:00
Alan Modra eabf307f1d PE linker segmentation fault with MALLOC_PERTURB_=1
PR 24596
	* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Check that
	the output is coff before accessing coff tdata.
	* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2019-05-28 20:47:14 +09:30
Szabolcs Nagy 65f381e729 aarch64: fix variant_pcs ld tests
Force sysv hash style for reliable symbol table layout.

ld/ChangeLog:

	* testsuite/ld-aarch64/variant_pcs-now.d: Use --hash-style=sysv.
	* testsuite/ld-aarch64/variant_pcs-shared.d: Likewise.
2019-05-28 12:03:51 +01:00
Alan Modra 3d7d6a6ff4 Generic ELF target group signature symbol
Even though the generic ELF target doesn't handle groups correctly,
this helps avoid a segfault in bfd_elf_set_group_contents seen on
d30v-elf, dlx-elf, pj-elf, and xgate-elf when linking the pr22836
testcase.

	PR 24596
bfd/
	* linker.c (_bfd_generic_link_output_symbols): Heed BSF_KEEP.
ld/
	* emultempl/genelf.em (gld${EMULATION_NAME}_after_open): Set
	BFS_KEEP on group signature symbol.
2019-05-27 13:56:28 +09:30
Szabolcs Nagy 823710d585 aarch64: handle STO_AARCH64_VARIANT_PCS in bfd
Propagate STO_AARCH64_VARIANT_PCS st_other attribute to the output and
add DT_AARCH64_VARIANT_PCS dynamic tag if necessary.

Mismatching attributes are not diagnosed.

bfd/ChangeLog:

	* elfnn-aarch64.c (elfNN_aarch64_merge_symbol_attribute): New function.
	(struct elf_aarch64_link_hash_table): Add variant_pcs member.
	(elfNN_aarch64_allocate_dynrelocs): Update variant_pcs.
	(elfNN_aarch64_size_dynamic_sections): Add DT_AARCH64_VARIANT_PCS.
	(elf_backend_merge_symbol_attribute): Define.

ld/ChangeLog:

	* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
	* testsuite/ld-aarch64/variant_pcs-1.s: New asm for tests.
	* testsuite/ld-aarch64/variant_pcs-2.s: New asm for tests.
	* testsuite/ld-aarch64/variant_pcs-now.d: New test.
	* testsuite/ld-aarch64/variant_pcs-r.d: New test.
	* testsuite/ld-aarch64/variant_pcs-shared.d: New test.
	* testsuite/ld-aarch64/variant_pcs.ld: New linker script for tests.
2019-05-24 15:11:00 +01:00
Alan Modra 405b5bd86f Regen POTFILES for bpf
bfd/
	* po/SRC-POTFILES.in: Regenerate.
gas/
	* po/POTFILES.in: Regenerate.
ld/
	* po/BLD-POTFILES.in: Regenerate.
opcodes/
	* po/POTFILES.in: Regenerate.
2019-05-24 23:15:07 +09:30
Alan Modra 04bdff6a76 PowerPC notoc linkage stubs
Use pcrel addressing instructions in linkage stubs.

bfd/
	* elf64-ppc.c: Comment on powerxx _notoc stub variants.
	(LI_R11_0, LIS_R11, ORI_R11_R11_0, SLDI_R11_R11_34): Define.
	(PADDI_R12_PC, PLD_R12_PC, D34, HA34): Define.
	(struct ppc_link_hash_table): Add powerxx_stubs.
	(ppc64_elf_check_relocs): Set powerxx_stubs.
	(build_powerxx_offset, size_powerxx_offset),
	(num_relocs_for_powerxx_offset),
	(emit_relocs_for_powerxx_offset): New functions.
	(plt_stub_size): Size powerxx stubs.
	(ppc_build_one_stub): Emit powerxx stubs.
	(ppc_size_one_stub): Size powerxx stubs.  Omit .eh_frame for
	powerxx stubs.
ld/
	* testsuite/ld-powerpc/notoc2.d,
	* testsuite/ld-powerpc/notoc2.s: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.
2019-05-24 10:28:07 +09:30
Alan Modra 4a421c53cf PowerPC GOT_PCREL34 optimisation
bfd/
	* elf64-ppc.c (ppc64_elf_check_relocs): Set has_gotrel for
	R_PPC64_GOT_PCREL34.
	(xlate_pcrel_opt): New function.
	(ppc64_elf_edit_toc): Handle R_PPC64_GOT_PCREL34.
	(ppc64_elf_relocate_section): Edit GOT indirect to GOT relative
	for R_PPC64_GOT_PCREL34.  Implement R_PPC64_PCREL_OPT optimisation.
ld/
	* testsuite/ld-powerpc/pcrelopt.s,
	* testsuite/ld-powerpc/pcrelopt.d,
	* testsuite/ld-powerpc/pcrelopt.sec: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.
2019-05-24 10:27:53 +09:30
Jose E. Marchesi 8376927b2c ld: add support for eBPF
This patch adds support to the linker for the Linux eBPF architecture.
A minimal testsuite is included.

ld/ChangeLog:

2019-05-23  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* Makefile.am (ALL_64_EMULATION_SOURCES): Add eelf64bpf.c.
	* Makefile.in (prefix): Regenerate.
	* configure.tgt (targ_extra_ofiles): Add case for bpf-*-* targets.
	* emulparams/elf64bpf.sh: New file.
	* testsuite/lib/ld-lib.exp (check_gc_sections_available): Add
	bpf-*-* to the list of targets not supporting gc-sections.
	* testsuite/ld-bpf/bar.s: New file.
	* testsuite/ld-bpf/jump-1.d: Likewise.
	* testsuite/ld-bpf/foo.s: Likewise.
	* testsuite/ld-bpf/call-1.d: Likewise.
	* testsuite/ld-bpf/bpf.exp: Likewise.
	* testsuite/ld-bpf/baz.s: Likewise.
2019-05-23 19:34:15 +02:00
Alan Modra 82d7a6f4e3 Re: Have the linker report an error if the same script is used twice
git commit 6ec6968b1b results in
... error: linker script file '/usr/local/lib64/libgcc_s.so' appears multiple times
collect2: error: ld returned 1 exit status
FAIL: bootstrap

This patch changes things so that an error is given only when a -T
script or the default script is invoked more than once.  I'm still a
little nervous that we match script file names, not the entire path.

	PR 24576
	* ldfile.c (enum script_open_style): New.
	(struct script_name_list): New.
	(ldfile_open_command_file_1): Take a script_open_style param
	rather than booleans.  Adjust callers.  Only fail when -T or
	default -T script is invoked twice.
	(ldfile_try_open_bfd): Revert last change.
2019-05-23 10:38:45 +09:30
Nick Clifton 6ec6968b1b Have the linker report an error if the same script is used twice.
PR 24576
	* ld/ldfile.c: (ldfile_open_command_file_1): Add new parameter -
	is_script.  If true check that the file has not already been
	parsed as a linker script.
	(ldfile_open_script_file): New function.
	(ldfile_try_open_bfd): Use the new function in place of
	ldfile_open_command_line.
	* ldmain.c (main): Likewise.
	* lexsup.c (parse_args): Use the new function for opening linker
	scripts with the -T option.
	* ldfile.h (ldfile_open_script_file): Add prototype.
2019-05-22 15:58:57 +01:00
Faraz Shahbazker b474a2022d MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared library
bfd/
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Generate error
	for TLS_TPREL_HI16(/LO16) relocations in shared library.

ld/
	* testsuite/ld-mips-elf/pic-reloc-5.s: Add tests for
	%tprel_hi and %tprel_lo relocations.
	* testsuite/ld-mips-elf/pic-reloc-6.s: Likewise.
	* testsuite/ld-mips-elf/pic-reloc-5.d: Update accordingly.
	* testsuite/ld-mips-elf/pic-reloc-6.d: Likewise.
	* testsuite/ld-mips-elf/pic-reloc-tls.ld: New test linker
	script file.
2019-05-21 11:55:08 -07:00
Faraz Shahbazker 304f09d0d4 MIPS/LD: Fix memory fault linking non-PIC object in to shared library
bfd/
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Add NULL pointer
	checks.  Search the RELA table for n64 relocations.

ld/
	* testsuite/ld-mips-elf/pic-reloc-5.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-6.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-7.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-5.s: New test source.
	* testsuite/ld-mips-elf/pic-reloc-6.s: New test source.
	* testsuite/ld-mips-elf/pic-reloc-7.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2019-05-21 11:55:08 -07:00
Matthew Fortune 3734320dc0 [MIPS] Add generation of PLT entries with compact jumps for MIPS R6
Add a new option to get the linker to emit PLTs that use compact
branches instead of delay slot branches.

bfd/
	* elfxx-mips.c (LA25_BC): New macro.
	(mips_elf_link_hash_table)<compact_branches>: New field.
	(STUB_JALRC): New macro.
	(mipsr6_o32_exec_plt0_entry_compact): New array.
	(mipsr6_n32_exec_plt0_entry_compact): Likewise.
	(mipsr6_n64_exec_plt0_entry_compact): Likewise.
	(mipsr6_exec_plt_entry_compact): Likewise.
	(mips_elf_create_la25_stub): Use BC instead of J for stubs
	when compact_branches is true.
	(_bfd_mips_elf_finish_dynamic_symbol): Choose the compact
	PLT for MIPSR6 with compact_branches.  Do not reorder the
	compact branches PLT.  Switch the lazy stub for MIPSR6
	with compact_branches to use JALRC.
	(mips_finish_exec_plt): Choose the compact PLT0 for MIPSR6
	when compact_branches is true.
	(_bfd_mips_elf_compact_branches): New function.
	* elfxx-mips.h (_bfd_mips_elf_compact_branches): New prototype.

ld/
	* emultempl/mipself.em (compact_branches): New static variable.
	(mips_create_output_section_statements): Call
	_bfd_mips_elf_compact_branches.
	(PARSE_AND_LIST_PROLOGUE): Add OPTION_COMPACT_BRANCHES and
	OPTION_NO_COMPACT_BRANCHES.
	(PARSE_AND_LIST_LONGOPTS): Add compact-branches,
	no-compact-branches.
	(PARSE_AND_LIST_OPTIONS): Add --compact-branches,
	--no-compact-branches.
	(PARSE_AND_LIST_ARGS_CASES): Handle the above.
	* ld.texinfo: Document --compact-branches, --no-compact-branches.
	* testsuite/ld-mips-elf/pic-and-nonpic-1-r6.dd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1-r6.nd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.dd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.gd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1a-r6.s: New test source.
	* testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2019-05-21 09:22:28 -07:00
Andre Vieira e6f65e7573 [binutils][Arm] Fix Branch Future relocation handling and testisms
bfd/ChangeLog:
2019-05-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	PR/target 24460
	* elf32-arm.c (get_value_helper): Remove.
	(elf32_arm_final_link_relocate): Fix branch future relocations.

gas/ChangeLog:
2019-05-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* testsuite/gas/arm/armv8_1-m-bf.d: Allow different branch target naming
	conventions.
	* testsuite/gas/arm/armv8_1-m-bfl.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-bfcsel.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-loloop.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-bf-rel.d: Skip for vxworks.
	* testsuite/gas/arm/armv8_1-m-bf-rela.d: New test.
	* testsuite/gas/arm/armv8_1-m-bfl-rel.d: Skip for vxworks.
	* testsuite/gas/arm/armv8_1-m-bfl-rela.d: New test.

ld/ChangeLog:
2019-05-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* testsuite/ld-arm/arm-elf.exp: Add tests
	* testsuite/ld-arm/bfs-0.s: New test.
	* testsuite/ld-arm/bfs-1.s: New test.
	* testsuite/ld-arm/branch-futures.d: New test.
2019-05-21 14:53:49 +01:00
Tamar Christina 739b5c9c77 AArch64: Implement choice between Cortex-A53 erratum workarounds. (PR ld/24373)
The Cortex-A53 erratum currently has two ways it can resolve the erratum when
using the flag --fix-cortex-a53-843419:

1) If the address is within the range of an ADR instruction it rewrites the ADRP
   into an ADR, and those doesn't need the use of a veneer.

2) If the address is not within range, it adds a branch to a veneer which will
   execute the final bit of the erratum workaround and branch back to the call
   site.

When we do this we always generate the veneers and we always align the size of
the text section to 4KB.  This is because we only know which workaround we can
use after all linking has finished and all addresses are known.  This means even
though the veneers are not used, we still generate the section and we still
change the size of the input section.

This is problematic for small memory devices as this would require the user to
take about a ~4KB hit in memory even though it's not even used.

Since there's no real way to restart the linking process from the final write
phase this patch solves the issue by allowing the user more control over which
erratum workaround gets used.

Concretely this changes the option --fix-cortex-a53-843419 to take optional
arguments --fix-cortex-a53-843419[=full|adr|adrp]

- full (default): Use both ADRP and ADR workaround. This is equivalent to not
		  specifying any options and is the default behavior before this
		  patch.

- adr: Only use the ADR workaround, this will not cause any increase in binary
       size but linking will fail if the referenced address is out of range of
       an ADR instruction.

- adrp: Use only the ADRP workaround, this will never rewrite your ADRP.

In the cases where the user knows how big their binaries are the `adr` option
would prevent the unneeded overhead.

bfd/ChangeLog:

	PR ld/24373
	* bfd-in.h (enum erratum_84319_opts): New
	(bfd_elf64_aarch64_set_options, bfd_elf32_aarch64_set_options): Change
	int to enum erratum_84319_opts.
	* bfd-in2.h: Regenerate.
	* elfnn-aarch64.c (struct elf_aarch64_link_hash_table): Change
	fix_erratum_843419 to use new enum, remove fix_erratum_843419_adr.
	(_bfd_aarch64_add_stub_entry_after): Conditionally create erratum stub.
	(aarch64_size_one_stub): Conditionally size erratum 843419 stubs.
	(_bfd_aarch64_resize_stubs): Amend comment.
	(elfNN_aarch64_size_stubs): Don't generate stubs when no workaround
	requested.
	(bfd_elfNN_aarch64_set_options): Use new fix_erratum_843419 enum.
	(_bfd_aarch64_erratum_843419_branch_to_stub): Implement selection of
	erratum workaround.
	(clear_erratum_843419_entry): Update erratum conditional.

ld/ChangeLog:

	PR ld/24373
	* emultempl/aarch64elf.em (PARSE_AND_LIST_LONGOPTS): Add optional args
	to flags.
	* NEWS: Add changes to flag.
	(PARSE_AND_LIST_OPTIONS): Update help descriptions.
	(PARSE_AND_LIST_ARGS_CASES): Add new options to parser.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add new run_dump_tests.
	* testsuite/ld-aarch64/erratum843419-adr.d: New test.
	* testsuite/ld-aarch64/erratum843419-adrp.d: New test.
	* testsuite/ld-aarch64/erratum843419-far-adr.d: New test.
	* testsuite/ld-aarch64/erratum843419-far-full.d: New test.
	* testsuite/ld-aarch64/erratum843419-far.s: New test.
	* testsuite/ld-aarch64/erratum843419-full.d: New test.
	* testsuite/ld-aarch64/erratum843419-near.s: New test.
	* testsuite/ld-aarch64/erratum843419-no-args.d: New test.
2019-05-21 13:05:22 +01:00
Senthil Kumar Selvaraj 7622049e0b Fix PR 24571 - Relaxation does not shorten jmp or call to target at pc-relative range boundary
The range check done to transform an absolute call/jump to a pc-relative one is
off-by-one, and that causes this shortening optimization to be missed if the
branch target is right at the range boundary.

In the non-shrinkable case, the range is what is mentioned in the ISA - -4094
bytes in the backward direction, and 4096 bytes in the positive direction.

In the shrinkable case, the forward jump range increases by two bytes (deleted
because of the shortening from call/jmp to rcall/rjmp), and therefore, the
range is -4094 in the reverse, and 4098 in the positive direction.

Fix the ranges for !shrinkable and shrinkable cases, and add a test caes to
ensure jumps to max forward and backward ranges get relaxed to rjmp.
2019-05-21 12:48:06 +05:30
Senthil Kumar Selvaraj 338ba75534 Fix PR 24564 - link fails for some rcalls/rjmps with wraparound
The current code to compute relative distance in the wrap around case does not
handle the edge case of the target (after adjusting for implicit PC increment)
being exactly half of the wrap around distance. This patch fixes that and adds a
testcase.

The range for a forward relative jump call is 4096 bytes ((2 * 2047) + (2 bytes
for the implicit PC increment)). If the target of the jump is at a distance of
4098 bytes, it is out of range for a forward jump - however, a backward jump can
still reach that address if pmem-wrap-around is 8192.

Assume address 0 has rjmp to address 4098. With a wrap around of 8192 and
*without* adjusting for the implicit PC increment of 2 bytes, rjmp .-4096 will
jump to address 4096 (wrap around at 8192 and decreasing addresses from then
on). Adjusting 2 bytes for the implicit PC increment, the actual target is 4098.

avr_relative_distance_considering_wrap_around though, does the wrap around only
if the passed in distance is less than half of the wrap around distance. In this
case, it is exactly equal to half (original distance 4098, adjusted distance of
4096 and wraparound of 8192), and the bypassed wrap around causes the reloc
overflow error.

Fix by wrapping around even if adjusted distance is equal to half of wrap around
distance.
2019-05-21 12:34:22 +05:30
Faraz Shahbazker d87343802b [MIPS] PR gas/14798: Limit IRIX5 specific default typing to IRIX targets
On IRIX 5, every global symbol that is not explicitly labelled as
being a function is assumed to be an object.  There is no reason
why IRIX behaviour should extend to all MIPS targets, so limit this
to only IRIX targets.

gas/
	PR 14798
	* config/tc-mips.c (s_mips_globl): Only treat symbols that are
	not explicitly labelled as BSF_OBJECTs for IRIX targets.
	* testsuite/gas/mips/pr14798.s: New test source.
	* testsuite/gas/mips/pr14798-irix.d: New test.
	* testsuite/gas/mips/pr14798.d: Likewise.
	* testsuite/gas/mips/mips.exp: Run the new tests.

binutils/
	PR 14798
	* testsuite/binutils-all/readelf.ss-mips: Update reference output.
	* testsuite/binutils-all/readelf.ss-tmips: Likewise.

ld/
	PR 14798
	* testsuite/ld-mips-elf/reloc-6a.s: Specify .text section for
	global code symbols.
	* testsuite/ld-mips-elf/reloc-6b.s: Likewise.
2019-05-20 11:08:23 -07:00
Alan Modra af4fa23fba PR24567, assertion failure in ldlang.c:6868 when compiling with -flto
As the existing comment said: "a common ought to be overridden by a
def in a -flto object".  This patch makes the code actually do that,
rather than allowing a normal object file common to override a -flto
defined symbol.

	PR 24567
	* plugin.c (plugin_notice): Do not let a common symbol override
	a non-common definition in IR.
2019-05-17 21:06:07 +09:30
Dimitar Dimitrov dd3189990b Use the correct names for the init and fini array start symbols in the default Pru linker script.
* scripttempl/pru.sc (__init_array_begin, __init_array_begin):
	Rename.
2019-05-09 10:26:11 +01:00
Pekka Sepp?nen 46752c37b0 Fix compile time warning when building the linker in a MinGw32 environment using gcc 8.
PR 24536
	* ldbuildid.c (generate_build_id): Cast return value from
	GetProcAddress in order to avoid a compile time warning.
2019-05-08 16:54:16 +01:00
Alan Modra e1cbf07ac4 PicoJava weak undefined symbols
This fixes the recently added ld-elf/pr24511 test failure on pj-elf.
Incidentally, pj-elf has failed its gas "pj" test since 2005-12-22
(git commit 54758c3e39).  I think that makes the target ripe for
obsolescence.

bfd/
	* elf32-pj.c (pj_elf_reloc): Don't report undefined weak as an error.
ld/
	* testsuite/ld-undefined/weak-undef.exp: Don't xfail pj.
2019-05-06 11:41:28 +09:30
Alan Modra 27cdfa03b5 m32c padding with nops
m32c_md_end attempted to pad out a code section with nops, but this
was just plain wrong in many ways:
- The padding didn't happen at all if the last section emitted wasn't
  a code section.
- The padding went to the wrong place if subsections were used, and
  the last subseg used wasn't the highest numbered subseg.
- Padding wasn't added to all code sections.
- If the last section was empty, it was padded to 4 bytes.
- The padding didn't go to a 4-byte alignment boundary, instead it
  effectively made the last instruction 4 bytes in size.
- The padding didn't take into account that code sections may have
  contents other than machine instructions.

So, rip it out and handle nop padding properly, also fixing .align
.balign/.p2align in the middle of code.

gas/
	* config/tc-m32c.c (insn_size): Delete static var.
	(md_begin): Don't set it.
	(m32c_md_end): Delete.
	(md_assemble): Add insn_size auto var.
	* config/tc-m32c.h (md_end): Don't define.
	(m32c_md_end): Delete.
	(NOP_OPCODE, HANDLE_ALIGN, MAX_MEM_FOR_RS_ALIGN_CODE): Define.
	* testsuite/gas/all/align.d: Remove m32c from notarget list.
	* testsuite/gas/all/incbin.d: Likewise.
	* testsuite/gas/elf/dwarf2-11.d: Likewise.
	* testsuite/gas/macros/semi.d: Likewise.
	* testsuite/gas/all/gas.exp (do_comment): Similarly.
ld/
	* testsuite/ld-scripts/fill.d: Don't xfail m32c
	* testsuite/ld-scripts/fill16.d: Likewise.
2019-05-04 17:23:18 +09:30
Alan Modra a288c27099 PR24511, nm should not mark symbols in .init_array as "t"
This patch restricts the section names matched in coff_section_type,
a function that translates section names to symbol type, and arranges
to translate section flags to symbol type before looking at names.
The latter change resulted in various test failures due to improper
section flags being used in tests, and by the plugin support, so fix
that too.

The new test fails on many ELF targets that lack .init/fini_array
in their scripts.  I've just xfailed those.  pru-elf oddly defines
__init_array_begin rather than __init_array_start.  I've left that
target as a FAIL, and pj-elf too which reports an error for undefined
weak symbols.

bfd/
	PR 24511
	* syms.c (coff_section_type): Only allow '.', '$' and numeric
	following the standard section names.
	(bfd_decode_symclass): Prioritize section flag tests in
	decode_section_type before name tests in coff_section_type.
	* plugin.c (bfd_plugin_canonicalize_symtab): Init fake_section
	and fake_common_section using BFD_FAKE_SECTION.  Use "fake" as
	their names and choose standard .text section flags for
	fake_section.
ld/
	PR 24511
	* testsuite/ld-elf/pr14156a.d: Allow for .init/.fini being a
	data section on hppa64.
	* testsuite/ld-elf/pr14156b.d: Likewise.
	* testsuite/ld-scripts/pr18963.t: Map standard sections to set
	output section flags.
	* testsuite/ld-scripts/sane1.t: Likewise.
	* testsuite/ld-elf/init-fini-arrays.s: Reference __init_array_start
	and __fini_array_start.  Define __start et al.
	* testsuite/ld-elf/pr24511.d: New test.
2019-05-04 16:57:33 +09:30
Alan Modra 066f4018ae PowerPC64 GOT indirect to GOT relative optimisation
This implements an optimisation that converts sequences like
  addis r9,r2,sym@got@ha
  ld r3,sym@got@l(r9)
to
  addis r9,r2,sym@toc@ha
  addi r3,r9,sym@toc@l
when "sym" is locally defined and can't be overridden.

bfd/
	* elf64-ppc.c (struct ppc64_elf_obj_tdata): Add has_gotrel.
	(struct _ppc64_elf_section_data): Likewise.
	(ppc64_elf_check_relocs): Set above fields.
	(ppc64_elf_edit_toc): Add a pass over GOT relocs.
	(ppc64_elf_relocate_section): Edit GOT indirect to GOT relative
	when possible.
ld/
	* testsuite/ld-powerpc/elfv2exe.d: Update.
	* testsuite/ld-powerpc/elfv2so.d: Update.
	* testsuite/ld-powerpc/tocopt.d: Update.
	* testsuite/ld-powerpc/tocopt.s: Update.
	* testsuite/ld-powerpc/tocopt5.d: Update.
	* testsuite/ld-powerpc/tocopt5.s: Update.
	* testsuite/ld-powerpc/tocopt7.d: Update.
	* testsuite/ld-powerpc/tocopt7.s: Update.
	* testsuite/ld-powerpc/tocopt8.d: Update.
	* testsuite/ld-powerpc/tocopt8.s: Update.
2019-04-30 22:09:54 +09:30
Alan Modra 06ddcada14 ld.texi tweak for pod2man
Fixes the following error:
ld.pod around line 568: Expected '=item *'
POD document had syntax errors at /usr/bin/pod2man line 71.

	* ld.texi (How GNU properties are merged): Avoid pod2man error.
	Correct example.
2019-04-30 22:04:32 +09:30
H.J. Lu c54f15248e Don't complain undefined weak dynamic reference
When undefined non-weak references in IR objects are optimized out
by LTO, we can have weak dynamic referencs to symbols marked with
bfd_link_hash_undefined.  We shouldn't complain such undefined weak
dynamic references.

bfd/

	PR ld/24486
	* elflink.c (elf_link_output_extsym): Don't complain undefined
	weak dynamic reference.

ld/

	PR ld/24486
	* testsuite/ld-plugin/lto.exp: Run PR ld/24486 tests.
	* testsuite/ld-plugin/pr24486a.c: New file.
	* testsuite/ld-plugin/pr24486b.c: Likewise.
	* testsuite/ld-plugin/pr24486c.c: Likewise.
2019-04-26 07:52:09 -07:00
Nick Clifton 8e1920d611 Updated Russian translation for the ld subdirectory.
* po/ru.po: Updated Russian translation.
2019-04-26 15:29:39 +01:00
Christopher Yeleighton a094d01f01 Fix the hyphenation of word phrases such as "target specific" and "machine specific".
* ld.texi: Properly hyphenate the word "specific".
2019-04-26 15:23:59 +01:00
H.J. Lu 6fe014bcd3 LTO: Properly handle wrapper symbols in IR
When a wrapper symbol, __wrap_FOO, is defined in IR, its resolution
should be LDPR_PREVAILING_DEF, not PREVAILING_DEF_IRONLY, since LTO
doesn't know that __wrap_FOO provides definition of FOO.  And resolution
of FOO should be LDPR_RESOLVED_IR since it is resolved by __wrap_FOO in
IR.

	PR ld/24406
	* ld.texi: Remove LTO warning from --wrap.
	* plugin.c (get_symbols): Update resolution for wrapper and
	wrapped symbols.
	* testsuite/ld-plugin/lto.exp: Run ld/24406 tests.
	* testsuite/ld-plugin/pr24406-1.c: New file.
	* testsuite/ld-plugin/pr24406-2a.c: Likewise.
	* testsuite/ld-plugin/pr24406-2b.c: Likewise.
2019-04-25 07:54:00 -07:00
Sudakshina Das 68bb0359ee [BFD, AArch64] Improve bti/pac plts.
This patch aims to improve the definitions of BTI and PAC based PLTs.
The following changes are made:
   * PLT0 does not need PAC instructions since the PLTGOT[2] (and PLTGOT[1])
     are readonly so they cannot be corrupted at runtime. Thus both PAC plt0
     and BTI+PAC plt0 are removed and we can use basic plt0 and BTI plt0
     instead, respectively.
   * We can remove the extra padding nops when we add the new bti instructions.
     BTI plt0 and BTI TLSDESC plt are updated.
   * For better performance PLTn could be padded to 24bytes. Both BTI pltn and
     PAC pltn are updated.

*** bfd/ChangeLog ***

2019-04-25  Sudakshina Das  <sudi.das@arm.com>

	* elfnn-aarch64.c (PLT_BTI_ENTRY_SIZE): Remove.
	(PLT_BTI_TLSDESC_ENTRY_SIZE): Remove.
	(PLT_PAC_ENTRY_SIZE, PLT_BTI_PAC_ENTRY_SIZE): Remove.
	(PLT_BTI_SMALL_ENTRY_SIZE, PLT_PAC_SMALL_ENTRY_SIZE): Update.
	(elfNN_aarch64_small_plt0_pac_entry): Remove.
	(elfNN_aarch64_small_plt0_bti_pac_entry): Remove.
	(elfNN_aarch64_small_plt0_bti_entry): Update.
	(elfNN_aarch64_small_plt_bti_entry): Update.
	(elfNN_aarch64_small_plt_pac_entry): Update.
	(elfNN_aarch64_tlsdesc_small_plt_bti_entry): Update.
	(setup_plt_values): Setup new entries.
	(elfNN_aarch64_finish_dynamic_sections): Remove size change.
	(elfNN_aarch64_plt_sym_val): Likewise.

*** ld/ChangeLog ***

2019-04-25  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-aarch64/bti-pac-plt-1.d: Update.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: Update.
	* testsuite/ld-aarch64/bti-plt-1.d: Update.
	* testsuite/ld-aarch64/bti-plt-3.d: Update.
	* testsuite/ld-aarch64/bti-plt-5.d: Update.
	* testsuite/ld-aarch64/pac-plt-1.d: Update.
	* testsuite/ld-aarch64/pac-plt-2.d: Update.
2019-04-25 11:37:25 +01:00
Sandra Loosemore 44ed80923a Use better test for usable compiler in ld testsuite.
The ld testsuite includes numerous tests that depend on being able to
compile and link programs with the C compiler.  Some of these tests
use [which $CC] to check for the presence of the compiler before
proceeding with the test, but run_ld_link_exec_tests and run_cc_link_tests
give ERRORs if compilation fails.  Also, even if $CC is defined and present,
it may not be usable due to missing libraries, etc.

This patch adds a new procedure check_compiler_available that attempts
to build an empty program and caches the result.  Uses of [which $CC]
are replaced with calls to this procedure, and run_ld_link_exec_tests
and run_cc_link_tests now also guard attempts to use $CC.

2019-04-24  Sandra Loosemore  <sandra@codesourcery.com>

	ld/
	* testsuite/config/default.exp: Use [check_compiler_available]
	instead of [which $CC].
	* testsuite/ld-auto-import/auto-import.exp: Likewise.
	* testsuite/ld-cygwin/exe-export.exp: Likewise.
	* testsuite/ld-elf/audit.exp: Likewise.
	* testsuite/ld-elf/compress.exp: Likewise.
	* testsuite/ld-elf/dwarf.exp: Likewise.
	* testsuite/ld-elf/elf.exp: Likewise.
	* testsuite/ld-elf/indirect.exp: Likewise.
	* testsuite/ld-elf/linux-x86.exp: Likewise.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-elf/tls.exp: Likewise.
	* testsuite/ld-elf/wrap.exp: Likewise.
	* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp: Likewise.
	* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
	* testsuite/ld-elfweak/elfweak.exp: Likewise.
	* testsuite/ld-gc/gc.exp: Likewise.
	* testsuite/ld-i386/i386.exp: Likewise.
	* testsuite/ld-i386/no-plt.exp: Likewise.
	* testsuite/ld-i386/tls.exp: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
	* testsuite/ld-mn10300/mn10300.exp: Likewise.
	* testsuite/ld-pe/pe-compile.exp: Likewise.
	* testsuite/ld-pe/pe-run.exp: Likewise.
	* testsuite/ld-pe/pe-run2.exp: Likewise.
	* testsuite/ld-pie/pie.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-plugin/plugin.exp: Likewise.
	* testsuite/ld-scripts/crossref.exp: Likewise.
	* testsuite/ld-sh/sh.exp: Likewise.
	* testsuite/ld-shared/shared.exp: Likewise.
	* testsuite/ld-size/size.exp: Likewise.
	* testsuite/ld-srec/srec.exp: Likewise.
	* testsuite/ld-undefined/undefined.exp: Likewise.
	* testsuite/ld-unique/unique.exp: Likewise.
	* testsuite/ld-x86-64/mpx.exp: Likewise.
	* testsuite/ld-x86-64/no-plt.exp: Likewise.
	* testsuite/ld-x86-64/tls.exp: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Call
	check_compiler_available before trying to use the compiler.
	(run_cc_link_tests): Likewise.
	(check_compiler_available): New.  Use it instead of [which $CC].
2019-04-24 12:14:56 -07:00
Alan Modra cc9519e7d6 Fix automatic makefile dependencies for generated ld/e*.c
Commit c40e31a121 broke --enable-dependency-tracking=no.

	* Makefile.am (GENDEPDIR): New var, used..
	(GENSCRIPTS): ..here.
	* Makefile.in: Regenerate.
	* genscripts.sh: Test for $DEPDIR set before every use.
2019-04-23 17:02:44 +09:30
Matthew Fortune 6f38008bb4 Fix M5100 flags test with interAptiv-MR2
ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Fix expected ASEs
	for M5100.
2019-04-22 20:41:03 -07:00
Alan Modra fce9773608 s12z and h8300 no-print-map-discarded fails
This tidies the remaining --no-print-map-discarded fails.  h8300-elf
warns on a section without flags, and s12z doesn't support
--gc-sections.

bfd/
	* elf32-s12z.c (elf_backend_can_gc_sections): Don't define
ld/
	* testsuite/ld-gc/skip-map-discarded.s: Add section attributes.
	* testsuite/lib/ld-lib.exp (check_gc_sections_available): Add
	s12z to list of targets not supporting --gc-sections.
2019-04-19 12:41:58 +09:30
H.J. Lu 9a7f0679fd x86: Suggest -fPIE when not building shared object
When PIC is needed, linker should suggest -fPIE, instead of -fPIC, when
not building shared object.

bfd/

	* elf64-x86-64.c (elf_x86_64_need_pic): Suggest -fPIE when not
	building shared object.
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Likewise.

ld/

	* testsuite/ld-i386/i386.exp: Run pr18801a and pr18801b instead
	of pr18801.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr18801.d: Removed.
	* testsuite/ld-x86-64/pr18801.d: Likewise.
	* testsuite/ld-i386/pr18801a.d: New file.
	* testsuite/ld-i386/pr18801b.d: Likewise.
	* testsuite/ld-x86-64/pr18801a.d: Likewise.
	* testsuite/ld-x86-64/pr18801b.d: Likewise.
	* testsuite/ld-x86-64/pie2.d: Suggest -fPIE instead of -fPIC.
	* testsuite/ld-x86-64/pie2.d: Likewise.
	* testsuite/ld-x86-64/pr19719.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2a.d: Likewise.
	* testsuite/ld-x86-64/pr19969.d: Likewise.
	* testsuite/ld-x86-64/pr21997-1a.err: Likewise.
	* testsuite/ld-x86-64/pr21997-1b.err: Likewise.
	* testsuite/ld-x86-64/pr22001-1a.err: Likewise.
	* testsuite/ld-x86-64/pr22001-1b.err: Likewise.
	* testsuite/ld-x86-64/pr22791-1.err: Likewise.
2019-04-17 10:25:28 -07:00
H.J. Lu 4e84a8f8bb x86: Also check x86 linker_def for non-shared definition
Since elf_x86_linker_defined sets linker_def in elf_x86_link_hash_entry
for linker defined symbols, SYMBOL_DEFINED_NON_SHARED_P should also check
linker_def in elf_x86_link_hash_entry.

bfd/

	PR ld/24458
	* elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): Also check x86
	linker_def.

ld/

	PR ld/24458
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/24458 tests.
	* testsuite/ld-x86-64/pr24458.s: New file.
	* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458a.d: Likewise.
	* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458b.d: Likewise.
	* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458c.d: Likewise.
2019-04-17 09:08:46 -07:00
Jozef Lawrynowicz e25de718de MSP430 Linker: Define __crt0_init_bss/__crt0_movedata symbols when .lower or .either prefixed sections are present.
ld	* config/tc-msp430.c (msp430_make_init_symbols): Define __crt0_init_bss
	symbol when .lower.bss or .either.bss sections exist.
	Define __crt0_movedata when .lower.data or .either.data sections exist.
	* testsuite/gas/msp430/either-data-bss-sym.d: New test.
	* testsuite/gas/msp430/low-data-bss-sym.d: New test.
	* testsuite/gas/msp430/either-data-bss-sym.s: New test source.
	* testsuite/gas/msp430/low-data-bss-sym.s: New test source.
	* testsuite/gas/msp430/msp430.exp: Run new tests.
	Enable large code model when running -mdata-region={upper,either}
	tests.
2019-04-17 15:05:08 +01:00
Alan Modra a0fb961508 ns32k testsuite tidy
Some of these tests were excluded for ns32k-netbsd, exclude for all
ns32k instead.

binutils/
	* testsuite/binutils-all/copy-2.d: Don't run for ns32k-*-*.
	* testsuite/binutils-all/copy-3.d: Likewise.
gas/
	* testsuite/gas/all/gas.exp: Remove ns32k xfails.
	* testsuite/gas/all/weakref1u.d: Don't run for ns32k-*-*.
ld/
	* testsuite/ld-scripts/pr20302.d: Don't run for ns32k-*-*.
	* testsuite/ld-scripts/section-match-1.d: Likewise.
	* testsuite/ld-undefined/require-defined.exp: Likewise.
2019-04-16 19:59:55 +09:30
Faraz Shahbazker 86333705ae Skip print-map-discarded test for non-ELF targets
ld/
	* testsuite/ld-gc/gc.exp: Skip print-map-discarded test
	for non-ELF targets.
2019-04-15 08:48:42 -07:00
Andre Vieira f6b2b12db8 [binutils, ARM, 11/16] New BFCSEL instruction for Armv8.1-M Mainline
s patch is part of a series of patches to add support for Armv8.1-M Mainline instructions to binutils.

This patch adds the BFCSEL instruction. It also adds a local relocation with a new bfd_reloc_code_real enum.

ChangeLog entries are as follows:

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* reloc.c (BFD_RELOC_THUMB_PCREL_BFCSEL): New relocation.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

*** gas/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* config/tc-arm.c (T16_32_TAB): New entriy for bfcsel.
	(do_t_v8_1_branch): New switch case for bfcsel.
	(toU): Define.
	(insns): New instruction for bfcsel.
	(md_pcrel_from_section): New switch case
	for BFD_RELOC_THUMB_PCREL_BFCSEL.
	(md_appdy_fix): Likewise
	(tc_gen_reloc): Likewise.
	* testsuite/gas/arm/armv8_1-m-bfcsel.d: New.
	* testsuite/gas/arm/armv8_1-m-bfcsel.s: New.

*** ld/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-arm/bfcsel.s: New.
	* testsuite/ld-arm/bfcsel.d: New.
	* testsuite/ld-arm/arm-elf.exp: Add above test.

*** opcodes/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* arm-dis.c (thumb32_opcodes): New instruction bfcsel.
	(print_insn_thumb32): Edit the switch case for %Z.
2019-04-15 12:31:42 +01:00
Andre Vieira 65d1bc05e8 [binutils, ARM, 9/16] New BFL instruction for Armv8.1-M Mainline
This patch is part of a series of patches to add support for Armv8.1-M Mainline
instructions to binutils.

This patch adds the BFL instruction.

*** gas/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* config/tc-arm.c (T16_32_TAB): New entrie for bfl.
	(do_t_v8_1_branch): New switch case for bfl.
	(insns): New instruction for bfl.
	* testsuite/gas/arm/armv8_1-m-bfl.d: New.
	* testsuite/gas/arm/armv8_1-m-bfl.s: New.
	* testsuite/gas/arm/armv8_1-m-bfl-bad.s: New.
	* testsuite/gas/arm/armv8_1-m-bfl-bad.d: New.
	* testsuite/gas/arm/armv8_1-m-bfl-bad.l: New.
	* testsuite/gas/arm/armv8_1-m-bfl-rel.d: New.
	* testsuite/gas/arm/armv8_1-m-bfl-rel.s: New.

*** ld/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-arm/bfl.s: New.
	* testsuite/ld-arm/bfl.d: New.
	* testsuite/ld-arm/arm-elf.exp: Add above test.

*** opcodes/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* arm-dis.c (thumb32_opcodes): New instruction bfl.
2019-04-15 12:30:33 +01:00
Andre Vieira 4389b29a5a [binutils, ARM, 6/16] New BF instruction for Armv8.1-M Mainline
This patch is part of a series of patches to add support for Armv8.1-M Mainline
instructions to binutils.

This patch adds the BF instruction.

ChangeLog entries are as follows:
*** gas/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* config/tc-arm.c (T16_32_TAB): New entries for bf.
	(do_t_branch_future): New.
	(insns): New instruction for bf.
	* testsuite/gas/arm/armv8_1-m-bf.d: New.
	* testsuite/gas/arm/armv8_1-m-bf.s: New.
	* testsuite/gas/arm/armv8_1-m-bf-bad.s: New.
	* testsuite/gas/arm/armv8_1-m-bf-bad.l: New.
	* testsuite/gas/arm/armv8_1-m-bf-bad.d: New.
	* testsuite/gas/arm/armv8_1-m-bf-rel.d: New.
	* testsuite/gas/arm/armv8_1-m-bf-rel.s: New.

*** ld/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-arm/bf.s: New.
	* testsuite/ld-arm/bf.d: New.
	* testsuite/ld-arm/arm-elf.exp: Add above test.

*** opcodes/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* arm-dis.c (thumb32_opcodes): New instructions for bf.
2019-04-15 12:30:33 +01:00
Andre Vieira 031254f211 [binutils, ARM, 1/16] Add support for Armv8.1-M Mainline CLI
The patch is straightforward, it does the following:

- support the new Tag_CPU_arch build attribute value, ie.:
   + declare the new value
   + update all the asserts forcing logic to be reviewed for new
     architectures
   + create a corresponding bfd_mach_arm_8_1M_MAIN enumerator in bfd and
     add mapping from Tag_CPU_arch to it
   + teach readelf about new Tag_CPU_arch value
- declare armv8.1-m.main as a supported architecture value
- define Armv8.1-M Mainline in terms of feature bits available
- tell objdump mapping from bfd_mach_arm_8_1M_MAIN enumerator to feature
   bits available
- update architecture-specific logic in gas and bfd guarded by the
   asserts mentioned above.
- tests for all the above

ChangeLog entries are as follows:

*** bfd/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* archures.c (bfd_mach_arm_8_1M_MAIN): Define.
	* bfd-in2.h: Regenerate.
	* cpu-arm.c (arch_info_struct): Add entry for Armv8.1-M Mainline.
	* elf32-arm.c (using_thumb_only): Return true for Armv8.1-M Mainline
	and update assert.
	(using_thumb2): Likewise.
	(using_thumb2_bl): Update assert.
	(arch_has_arm_nop): Likewise.
	(bfd_arm_get_mach_from_attributes): Add case for Armv8.1-M Mainline.
	(tag_cpu_arch_combine): Add logic for Armv8.1-M Mainline merging.

*** binutils/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* readelf.c (arm_attr_tag_CPU_arch): Add entry for Armv8.1-M Mainline.

*** gas/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* config/tc-arm.c (cpu_arch_ver): Add entry for Armv8.1-M Mainline
	Tag_CPU_arch build attribute value.  Reindent.
	(get_aeabi_cpu_arch_from_fset): Update assert.
	(aeabi_set_public_attributes): Update assert for Tag_DIV_use logic.
	* testsuite/gas/arm/attr-march-armv8_1-m.main.d: New test.

*** include/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* elf/arm.h (TAG_CPU_ARCH_V8_1M_MAIN): new macro.
	(MAX_TAG_CPU_ARCH): Set value to above macro.
	* opcode/arm.h (ARM_EXT2_V8_1M_MAIN): New macro.
	(ARM_AEXT_V8_1M_MAIN): Likewise.
	(ARM_AEXT2_V8_1M_MAIN): Likewise.
	(ARM_ARCH_V8_1M_MAIN): Likewise.

*** ld/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* testsuite/ld-arm/attr-merge-13.attr: New test.
	* testsuite/ld-arm/attr-merge-13a.s: New test.
	* testsuite/ld-arm/attr-merge-13b.s: New test.

*** opcodes/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* arm-dis.c (select_arm_features): Add logic for Armv8.1-M Mainline.
2019-04-15 10:54:42 +01:00
Alan Modra c40e31a121 Automatic makefile dependencies for generated ld/e*.c
This patch modifies genscripts.sh to emit dependency info along with
the generated emulation e*.c files.  This is done by a new source_sh
function that records its arg to a file (.deps/e*.Tc), using the
function whenever a shell script is sourced.  Entries in the file are
made unique and written to .deps/e*.Pc.  These files are then
included by the Makefile.

	* Makefile.am (GENSCRIPTS): Pass LIB_PATH as a parameter.  Add
	DEPDIR parameter.
	(ELF_DEPS, ELF_GEN_DEPS, ELF_X86_DEPS): Delete.
	(ALL_EMULATION_SOURCES, ALL_64_EMULATION_SOURCES): Depend on
	$GEN_DEPENDS.
	(e*.c): Delete all dependencies, instead include dependencies
	from $DEPDIR/*.Pc.
	* Makefile.in: Regenerate.
	* configure.ac (source_sh): Define and use function.
	* configure: Regenerate.
	* emulparams/aarch64cloudabib.sh, * emulparams/aarch64elf32b.sh,
	* emulparams/aarch64elfb.sh, * emulparams/aarch64fbsdb.sh,
	* emulparams/aarch64linux32b.sh, * emulparams/aarch64linuxb.sh,
	* emulparams/arcelf.sh, * emulparams/arcelf_prof.sh,
	* emulparams/arclinux.sh, * emulparams/arclinux_nps.sh,
	* emulparams/arclinux_prof.sh, * emulparams/arcv2elf.sh,
	* emulparams/arcv2elfx.sh, * emulparams/armelf_fbsd.sh,
	* emulparams/armelf_linux_eabi.sh,
	* emulparams/armelf_linux_fdpiceabi.sh,
	* emulparams/armelf_nacl.sh, * emulparams/armelf_nbsd.sh,
	* emulparams/armelf_vxworks.sh, * emulparams/armelfb.sh,
	* emulparams/armelfb_fbsd.sh, * emulparams/armelfb_fuchsia.sh,
	* emulparams/armelfb_linux.sh, * emulparams/armelfb_linux_eabi.sh,
	* emulparams/armelfb_linux_fdpiceabi.sh,
	* emulparams/armelfb_nacl.sh, * emulparams/armelfb_nbsd.sh,
	* emulparams/armsymbian.sh, * emulparams/cskyelf_linux.sh,
	* emulparams/elf32_sparc_sol2.sh,
	* emulparams/elf32_sparc_vxworks.sh, * emulparams/elf32_tic6x_be.sh,
	* emulparams/elf32_tic6x_elf_be.sh,
	* emulparams/elf32_tic6x_elf_le.sh,
	* emulparams/elf32_tic6x_linux_be.sh,
	* emulparams/elf32_tic6x_linux_le.sh,
	* emulparams/elf32_x86_64.sh, * emulparams/elf32_x86_64_nacl.sh,
	* emulparams/elf32b4300.sh, * emulparams/elf32bfinfd.sh,
	* emulparams/elf32bmipn32.sh, * emulparams/elf32bsmip.sh,
	* emulparams/elf32btsmip.sh, * emulparams/elf32btsmip_fbsd.sh,
	* emulparams/elf32btsmipn32.sh, * emulparams/elf32btsmipn32_fbsd.sh,
	* emulparams/elf32ebmip.sh, * emulparams/elf32ebmipvxworks.sh,
	* emulparams/elf32elmip.sh, * emulparams/elf32elmipvxworks.sh,
	* emulparams/elf32frvfd.sh, * emulparams/elf32l4300.sh,
	* emulparams/elf32lm32fd.sh, * emulparams/elf32lmip.sh,
	* emulparams/elf32lppc.sh, * emulparams/elf32lppclinux.sh,
	* emulparams/elf32lppcnto.sh, * emulparams/elf32lppcsim.sh,
	* emulparams/elf32lr5900.sh, * emulparams/elf32lr5900n32.sh,
	* emulparams/elf32lriscv.sh, * emulparams/elf32lriscv_ilp32.sh,
	* emulparams/elf32lriscv_ilp32f.sh, * emulparams/elf32lsmip.sh,
	* emulparams/elf32ltsmip.sh, * emulparams/elf32ltsmip_fbsd.sh,
	* emulparams/elf32ltsmipn32.sh, * emulparams/elf32ltsmipn32_fbsd.sh,
	* emulparams/elf32microblazeel.sh, * emulparams/elf32or1k_linux.sh,
	* emulparams/elf32ppc.sh, * emulparams/elf32ppc_fbsd.sh,
	* emulparams/elf32ppccommon.sh, * emulparams/elf32ppclinux.sh,
	* emulparams/elf32ppcnto.sh, * emulparams/elf32ppcsim.sh,
	* emulparams/elf32ppcvxworks.sh, * emulparams/elf32ppcwindiss.sh,
	* emulparams/elf32tilegx_be.sh, * emulparams/elf64_ia64_fbsd.sh,
	* emulparams/elf64_sparc_fbsd.sh, * emulparams/elf64_sparc_sol2.sh,
	* emulparams/elf64alpha_fbsd.sh, * emulparams/elf64alpha_nbsd.sh,
	* emulparams/elf64bmip-defs.sh, * emulparams/elf64bmip.sh,
	* emulparams/elf64btsmip.sh, * emulparams/elf64btsmip_fbsd.sh,
	* emulparams/elf64lppc.sh, * emulparams/elf64lriscv-defs.sh,
	* emulparams/elf64lriscv.sh, * emulparams/elf64lriscv_lp64.sh,
	* emulparams/elf64lriscv_lp64f.sh, * emulparams/elf64ltsmip.sh,
	* emulparams/elf64ltsmip_fbsd.sh, * emulparams/elf64ppc.sh,
	* emulparams/elf64ppc_fbsd.sh, * emulparams/elf64rdos.sh,
	* emulparams/elf64tilegx_be.sh, * emulparams/elf_i386.sh,
	* emulparams/elf_i386_be.sh, * emulparams/elf_i386_fbsd.sh,
	* emulparams/elf_i386_ldso.sh, * emulparams/elf_i386_nacl.sh,
	* emulparams/elf_i386_sol2.sh, * emulparams/elf_i386_vxworks.sh,
	* emulparams/elf_iamcu.sh, * emulparams/elf_k1om.sh,
	* emulparams/elf_k1om_fbsd.sh, * emulparams/elf_l1om.sh,
	* emulparams/elf_l1om_fbsd.sh, * emulparams/elf_x86_64.sh,
	* emulparams/elf_x86_64_cloudabi.sh,
	* emulparams/elf_x86_64_fbsd.sh, * emulparams/elf_x86_64_nacl.sh,
	* emulparams/elf_x86_64_sol2.sh, * emulparams/h8300helf.sh,
	* emulparams/h8300helf_linux.sh, * emulparams/h8300hnelf.sh,
	* emulparams/h8300self.sh, * emulparams/h8300self_linux.sh,
	* emulparams/h8300snelf.sh, * emulparams/h8300sxelf.sh,
	* emulparams/h8300sxelf_linux.sh, * emulparams/h8300sxnelf.sh,
	* emulparams/hppanbsd.sh, * emulparams/hppaobsd.sh,
	* emulparams/m32rlelf.sh, * emulparams/m32rlelf_linux.sh,
	* emulparams/m68kelfnbsd.sh, * emulparams/mn10300.sh,
	* emulparams/msp430X.sh, * emulparams/nds32belf.sh,
	* emulparams/nds32belf16m.sh, * emulparams/nds32belf_linux.sh,
	* emulparams/pjlelf.sh, * emulparams/ppclynx.sh,
	* emulparams/score7_elf.sh, * emulparams/shelf_fd.sh,
	* emulparams/shelf_linux.sh, * emulparams/shelf_nbsd.sh,
	* emulparams/shelf_uclinux.sh, * emulparams/shelf_vxworks.sh,
	* emulparams/shl.sh, * emulparams/shlelf.sh,
	* emulparams/shlelf_fd.sh, * emulparams/shlelf_nbsd.sh,
	* emulparams/shlelf_vxworks.sh: Use source_sh.
	* genscripts.sh: Adjust for changed parameters.  Emit dependencies
	for e*.c to .deps/*.Pc.
	(source_sh): New function, use it throughout to source scripts.
	* genscrba.sh (source_em): Use source_sh.
2019-04-13 12:13:22 +09:30
Alan Modra 50ff67e6cf ld TDIRS substitution
It is no longer true that autoconf/automake cannot substitute vars
with embedded new-lines.

	* configure.ac (TDIRS): Build up tdirs in this variable and
	AC_SUBST, also using AM_SUBST_NOTMAKE.
	* configure: Regenerate.
	* Makefile.am (DISTCLEANFILES): Remove tdirs.
	* Makefile.in: Regenerate.
2019-04-13 12:12:43 +09:30
Nick Clifton 3bbec4bd95 Fix thinko in linker documentation.
PR 24450
	* ld.texi (Output Section Attributes): Add ALIGN_WITH_INPUT to
	example of section attributes.
2019-04-12 13:15:21 +01:00
Faraz Shahbazker 035801cebe ld: Add --no-print-map-discarded option
Add a new option to disable the listing of discarded sections
in map file output.  The use case stems from a large application
built with -ffunction-sections --gc-sections where the list of
discarded sections blows up the map file output.  The default
behaviour remains to print discarded sections,  but the new option
allows us to disable it.

ld/
	* NEWS: Mention new option --no-print-map-discarded.
	* ld.h (ld_config_type) <print_map_discarded>: New field.
	* ldlang.c (lang_map): Conditionally output discarded sections
	in map files based on configuration option.
	* ldlex.h (option_values) <OPTION_PRINT_MAP_DISCARDED,
	OPTION_NO_PRINT_MAP_DISCARDED>: New.
	* ldmain.c (main): Enabled print_map_discarded by default.
	* lexsup.c (ld_options): Add new command-line options.
	(parse_args) <OPTION_NO_PRINT_MAP_DISCARDED,
	OPTION_PRINT_MAP_DISCARDED>: New cases.
	* ld.texi: Document new options.
	* testsuite/ld-gc/gc.exp: Add new test.
	* testsuite/ld-gc/skip-map-discarded.s: New file.
	* testsuite/ld-gc/skip-map-discarded.d: New file.
	* testsuite/ld-gc/skip-map-discarded.map: New file.
2019-04-11 10:16:31 -07:00
H.J. Lu 233a00833b x86: Add -z cet-report=[none|warning|error]
Add -z cet-report=[none|warning|error] to report the missing Intel
Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK) properties
in input .note.gnu.property section.  -z cet-report=none, which is
the default, will make the linker not report missing properties in
input files.  -z cet-report=warning will make the linker issue a
warning for missing properties in input files.  -z cet-report=error
will make the linker issue an error for missing properties in input
files.  Note that -z ibt will turn off the missing IBT property report
and -z shstk will turn off the missing SHSTK property report.
Supported for Linux/i386 and Linux/x86_64.

bfd/

	* elf-linker-x86.h (elf_x86_cet_report): New.
	(elf_linker_x86_params): Add cet_report.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Report
	missing IBT and SHSTK properties if needed.

ld/

	* ld.texi: Document -z cet-report=[none|warning|error].
	* emulparams/cet.sh: Add -z cet-report=[none|warning|error].
	* testsuite/ld-i386/i386.exp: Run -z cet-report=[warning|error]
	tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/property-x86-cet1.d: New file.
	* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet2b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet3a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet3b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet4a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet4b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet6.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet.s: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet6-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet6.d: Likewise.
2019-04-11 08:21:30 -07:00
H.J. Lu b3d7a86748 ld: Add -static-pie tests
Add -static-pie tests for DT_INIT_ARRAY, DT_FINI_ARRAY, DT_PREINIT_ARRAY
and IFUNC.

	* testsuite/config/default.exp (STATIC_PIE_LDFLAGS): New.  Set
	to "-static-pie" if target compiler supports it.
	* testsuite/ld-elf/elf.exp: Run -static-pie tests if
	$STATIC_PIE_LDFLAGS isn't empty.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
2019-04-11 06:52:03 -07:00
Tamar Christina ce12121b63 AArch64: When DF_BIND_NOW don't use TLSDESC GOT value.
When using DF_BIND_NOW on AArch64 we don't reserve the GOT slot for a TLSDESC,
but we still emitted DT_TLSDESC_GOT and DT_TLSDESC_PLT.  This caused random
memory corruption as the "special" value of (bfd_vma)-1 would be set for
dt_tlsdesc_got.

Since we don't have a value of dt_tlsdesc_got I also don't emit DT_TLSDESC_PLT
now becuase it would point to an incomplete PLT. To be able to write the PLT
entry DT_TLSDESC_GOT is needed and since we don't have one we can't write the
PLT entry either.

It is my understanding that GLIBC doesn't need these two entries when not lazy
loading.  Conversely AArch32 does not reserve neither the GOT not the PLT slot
when doing DF_BIND_NOW.

AArch32 does not need these checks because these values are initialized to 0
and so the if (...) checks don't pass, but on AArch64 these are initialized
to (bfd_vma)-1 and thus we need some extra checks.

bfd/ChangeLog:

	PR ld/24302
	* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Don't emit
	DT_TLSDESC_GOT and DT_TLSDESC_PLT when DF_BIND_NOW.
	(elfNN_aarch64_finish_dynamic_sections): Don't write PLT if DF_BIND_NOW.

ld/ChangeLog:

	PR ld/24302
	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
	* testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: New test.
2019-04-11 11:30:03 +01:00
H.J. Lu 795e3bb7de ld: Don't define __rel[a]_iplt_start/__rel[a]_iplt_end in PIE
__rel[a]_iplt_start and __rel[a]_iplt_end are defined to handle IFUNC in
static executables.  For PIE, since IFUNC is handled as the part of the
normal dynamic relocation processing, there is no need to define these
symbols in PIE.

	* scripttempl/elf.sc (CREATE_PIC): New.  Set for CREATE_SHLIB or
	CREATE_PIE.
	(__rel_iplt_start): Don't define for CREATE_PIC.
	(__rel_iplt_end): Likewise.
	(__rela_iplt_start): Likewise.
	(__rela_iplt_end): Likewise.
2019-04-10 18:36:22 -07:00
Alan Modra e6aded7c34 Re: XFAIL PR ld/20995 tests for lynxos and nto targets
* testsuite/ld-elf/shared.exp: Don't xfail PR ld/20995 for
	powerpc-nto.
2019-04-10 15:32:56 +09:30
Alan Modra 53b81c6de1 cskyelf.em branch stub handling
This fixes the csky-elf ld-elf/pr21884 and ld-unique/pr21529 failures,
by disabling branch stubs for binary (and other non-csky) output.
The csky-linux target gets branch stubs off by default because
presumably there are reasons why branch stubs were disabled, but
rather than killing the support completely it can be enabled by
--branch-stub.

	* emultempl/cskyelf.em (csk_elf_before_parse): New function,
	setting use_branch_stub false for linux.
	(csky_elf_create_output_section_statements): Do emit this
	function and all others in the file for linux, plus the branch
	option control.  Disable branch stubs when non-ELF.
2019-04-10 13:30:32 +09:30
Alan Modra c55b17b809 Fix some ld dependencies
In looking at the csky-elf vs. csky-linux differences, the first thing
I compared was csky_elf.sh and cskyelf_linux.sh.  Those files are
mostly the same but besides the real differences, annoyingly have some
lines ordered differently.  It's better in such cases to have one file
source the other, making differences plain.  This patch does that for
csky and microblaze, removes an unused variable defined in a few
places, and fixes ld makefile dependencies.

	* Makefile.am (eskyelf.c, eskyelf_linux.c): Depend on cskyelf.em.
	(ecskyelf_linux.c): Depend on cskyelf.sh.
	(eelf32microblazeel.c): Depend on elf32microblaze.sh.
	* Makefile.in: Regenerate.
	* emulparams/cskyelf.sh: Comment regarding cskelf_linux.sh.
	(PAGE_SIZE): Don't define.
	* emulparams/cskyelf_linux.sh: Source sckyelf.sh, leaving just
	the differing variable defs/undefs.
	* emulparams/elf32mcore.sh (PAGE_SIZE): Don't define.
	* emulparams/elf32microblaze.sh: Comment re. elf32microblazeel.sh.
	(OUTPUT_FORMAT): Use BIG_OUTPUT_FORMAT.
	(PAGE_SIZE): Don't define.
	* emulparams/elf32microblazeel.sh: Source elf32microblaze.sh,
	leaving just the differing OUTPUT_FORMAT.
2019-04-10 13:30:32 +09:30
Alan Modra 6feda62721 Regen BLD-POTFILES.in
* po/BLD-POTFILES.in: Regenerate.
2019-04-10 13:30:32 +09:30
H.J. Lu c93c0e7f3f XFAIL PR ld/20995 tests for lynxos and nto targets
lynxos and nto targets don't support RELRO.

	* testsuite/ld-elf/shared.exp: XFAIL PR ld/20995 tests for
	lynxos and nto targets.
2019-04-08 13:55:37 -07:00
H.J. Lu 3ae61bb67d x86: Remove i386-*-kaos* and i386-*-chaos targets
Remove i386-*-kaos* and i386-*-chaos targets since they are no longer
supported by config.sub:

$ .../config.sub i386-kaos
Invalid configuration `i386-kaos': system `kaos' not recognized
$ .../config.sub i386-chaos
Invalid configuration `i386-chaos': system `chaos' not recognized
$

bfd/

	* config.bfd: Remove i[3-7]86-*-kaos* and i[3-7]86-*-chaos targets.

gas/

	* configure.tgt: Remove i386-*-kaos* and i386-*-chaos targets.
	* testsuite/gas/i386/i386.exp: Remove *-*-caos* and "*-*-kaos*
	check.

ld/

	* Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_chaos.c.
	(eelf_i386_chaos.c): Removed.
	* Makefile.in: Regenerated.
	* configure.tgt: Remove i[3-7]86-*-kaos*.
	* emulparams/elf_i386_chaos.sh: Removed.
2019-04-08 11:58:51 -07:00
H.J. Lu da9b5f7be7 Use elf-x86.em for i386-moss and i386-beos
* emulparams/elf_i386_be.sh (EXTRA_EM_FILE): New.
	* emulparams/i386moss.sh (EXTRA_EM_FILE): Likewise.
2019-04-08 11:27:57 -07:00
Alan Modra d970ee2bae Fix i386-lynxos and other runtime linker fails
Segfaults due to htab->params being NULL.

	* emulparams/elf64rdos.sh (EXTRA_EM_FILE): Define.
	* emulparams/i386lynx.sh (EXTRA_EM_FILE): Define.
	* emulparams/i386nto.sh (EXTRA_EM_FILE): Define.
2019-04-08 14:11:57 +09:30
H.J. Lu 5b9c07b278 x86: Move x86-specific linker options to elf_linker_x86_params
Remove x86-specific linker options from bfd_link_info and put them in
elf_linker_x86_params.  Add _bfd_elf_linker_x86_set_options to pass
x86-specific linker options from ld to bfd.

bfd/

	* elf-linker-x86.h: New file.
	* elf32-i386.c (elf_i386_convert_load_reloc): Use htab->params
	to get x86-specific linker options.
	* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
	(elf_x86_64_check_relocs): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Likewise.
	(_bfd_x86_elf_link_setup_gnu_properties): Likewise.
	(_bfd_elf_linker_x86_set_options): New function.
	* elfxx-x86.h: Include "elf-linker-x86.h".
	(elf_x86_link_hash_table): Add params.

include/

	* bfdlink.h (bfd_link_info): Remove x86-specific linker options.

ld/

	* Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emultempl/elf-x86.em.
	(eelf_i386_sol2.c): Also depend on
	$(srcdir)/emultempl/solaris2-x86.em.
	(eelf_x86_64_sol2.c): Likewise.
	* Makefile.in: Regenerated.
	* emulparams/call_nop.sh: Set x86-specific linker options via
	params.
	* emulparams/cet.sh: Likewise.
	* emulparams/reloc_overflow.sh: Likewise.
	* emulparams/elf32_x86_64.sh (EXTRA_EM_FILE): New.  Set to
	"elf-x86".
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_i386_be.sh: Likewise.
	* emulparams/elf_i386_chaos.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_i386_vxworks.sh: Likewise.
	* emulparams/elf_iamcu.sh: Likewise.
	* emulparams/elf_k1om.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/elf_i386_sol2.sh (EXTRA_EM_FILE): Changed to
	"solaris2-x86".
	* emulparams/elf_x86_64_sol2.sh: Likewise.
	* emultempl/elf-x86.em: New file.
	* emultempl/solaris2-x86.em: Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't
	set link_info.call_nop_byte.
2019-04-06 07:25:31 -07:00
Alan Modra c2b1c27545 PowerPC disassembler: Don't emit trailing spaces
When an instruction has operands, the PowerPC disassembler prints
spaces after the opcode so as to line up operands.  If the operands
are all optional and all default value, then no operands are printed,
leaving trailing spaces.  This patch fixes that.

opcodes/
	* ppc-dis.c (print_insn_powerpc): Delay printing spaces after
	opcode until first operand is output.
gas/
	* testsuite/gas/ppc/476.d: Remove trailing spaces.
	* testsuite/gas/ppc/a2.d: Likewise.
	* testsuite/gas/ppc/booke.d: Likewise.
	* testsuite/gas/ppc/booke_xcoff.d: Likewise.
	* testsuite/gas/ppc/e500.d: Likewise.
	* testsuite/gas/ppc/e500mc.d: Likewise.
	* testsuite/gas/ppc/e6500.d: Likewise.
	* testsuite/gas/ppc/htm.d: Likewise.
	* testsuite/gas/ppc/power6.d: Likewise.
	* testsuite/gas/ppc/power8.d: Likewise.
	* testsuite/gas/ppc/power9.d: Likewise.
	* testsuite/gas/ppc/vle.d: Likewise.
ld/
	* testsuite/ld-powerpc/tlsexe32.d: Remove trailing spaces.
	* testsuite/ld-powerpc/tlsopt5.d: Likewise.
	* testsuite/ld-powerpc/tlsopt5_32.d: Likewise.
2019-04-05 12:20:49 +10:30
Alan Modra 1c6aafe894 PR24411, Division is not accepted in MEMORY length expression
Let's hope no one has section names starting with '/' in scripts.  If
they do, this change to fix parsing of '/' in expressiongs will break
their project.

	PR 24411
	ldlex.l (SYMBOLNAMECHAR1): Don't match '/'.
	(<EXPRESSION>"/DISCARD/"): New.
2019-04-03 13:01:49 +10:30
Alan Modra 092da96ac4 ldlex.l tidy
Underscore was specified twice in all these patterns, and backslash
twice in some.  Flex warned about the $SYSROOT rule, which is covered
by earlier rules:  "ldlex.l:386: warning, rule cannot be matched".

	* ldlex.l: Formatting.
	(CMDFILENAMECHAR, CMDFILENAMECHAR1): Delete.
	(FILENAMECHAR1, SYMBOLNAMECHAR1, FILENAMECHAR, WILDCHAR),
	(NOCFILENAMECHAR): Remove duplicate chars.  Reorder.
	(SYMBOLCHARN): Likewise.  Rename to SYMBOLNAMECHAR.
	(<INPUTLIST>"$SYSROOT"..): Delete rule.
2019-04-03 13:01:32 +10:30
Max Filippov 2487ef07c2 bfd: xtensa: fix shrink_dynamic_reloc_sections for export-dynamic
shrink_dynamic_reloc_sections must remove PLT entry that was created for
an undefined weak symbol in the presence of --export-dynamic option when
relaxation coalesces literals pointing to that symbol. This fixes the
following assertion:

  ld: BFD (GNU Binutils) 2.31.1 internal error, aborting at
  elf32-xtensa.c:3292 in elf_xtensa_finish_dynamic_sections

2019-03-29  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (shrink_dynamic_reloc_sections): Add
	info->export_dynamic to the conditional.

ld/
	* testsuite/ld-xtensa/relax-undef-weak-pie-export-dynamic.d: New
	test definition.
	* testsuite/ld-xtensa/xtensa.exp
	(relax-undef-weak-pie-export-dynamic): Add new test.
2019-03-29 10:02:10 -07:00
marxin 7ea79cb3af Provide string description of definition, visibility and resolution in LTO plug-in.
ld/ChangeLog:

2019-02-26  Martin Liska  <mliska@suse.cz>

	* plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str,
	lto_visibility_str and use then to inform about plugin-symbols.
	* testsuite/ld-plugin/plugin-12.d: Adjust expected pattern.
2019-03-26 15:22:01 +01:00
Tamar Christina 796d6298bb Arm: Fix Arm disassembler mapping symbol search.
Similar to the AArch64 patches the Arm disassembler has the same issues with
out of order sections but also a few short comings.

For one thing there are multiple code blocks to determine mapping symbols, and
they all work slightly different, and neither fully correct.  The first thing
this patch does is centralise the mapping symbols search into one function
mapping_symbol_for_insn.  This function is then updated to perform a search in
a similar way as AArch64.

Their used to be a value has_mapping_symbols which was used to determine the
default disassembly for objects that have no mapping symbols.  The problem with
the approach was that it was determining this value in the same loop that needed
it, which is why this field could take on the states -1, 0, 1 where -1 means
"don't know".  However this means that until you actually find a mapping symbol
or reach the end of the disassembly glob, you don't know if you did the right
action or not, and if you didn't you can't correct it anymore.

This is why the two jump-reloc-veneers-* testcases end up disassembling some
insn as data when they shouldn't.

Out of order here refers to an object file where sections are not listed in a
monotonic increasing VMA order.

The ELF ABI for Arm [1] specifies the following for mapping symbols:

  1) A text section must always have a corresponding mapping symbol at it's
     start.
  2) Data sections do not require any mapping symbols.
  3) The range of a mapping symbol extends from the address it starts on up to
     the next mapping symbol (exclusive) or section end (inclusive).

However there is no defined order between a symbol and it's corresponding
mapping symbol in the symbol table.  This means that while in general we look
up for a corresponding mapping symbol, we have to make at least one check of
the symbol below the address being disassembled.

When disassembling different PCs within the same section, the search for mapping
symbol can be cached somewhat.  We know that the mapping symbol corresponding to
the current PC is either the previous one used, or one at the same address as
the current PC.

However this optimization and mapping symbol search must stop as soon as we
reach the end or start of the section.  Furthermore if we're only disassembling
a part of a section, the search is a allowed to search further than the current
chunk, but is not allowed to search past it (The mapping symbol if there, must
be at the same address, so in practice we usually stop at PC+4).

lastly, since only data sections don't require a mapping symbol the default
mapping type should be DATA and not INSN as previously defined, however if the
binary has had all its symbols stripped than this isn't very useful.  To fix
this we determine the default based on the section flags.  This will allow the
disassembler to be more useful on stripped binaries.  If there is no section
than we assume you to be disassembling INSN.

[1] https://developer.arm.com/docs/ihi0044/latest/elf-for-the-arm-architecture-abi-2018q4-documentation#aaelf32-table4-7

binutils/ChangeLog:

	* testsuite/binutils-all/arm/in-order-all.d: New test.
	* testsuite/binutils-all/arm/in-order.d: New test.
	* testsuite/binutils-all/arm/objdump.exp: Support .d tests.
	* testsuite/binutils-all/arm/out-of-order-all.d: New test.
	* testsuite/binutils-all/arm/out-of-order.T: New test.
	* testsuite/binutils-all/arm/out-of-order.d: New test.
	* testsuite/binutils-all/arm/out-of-order.s: New test.

ld/ChangeLog:

	* testsuite/ld-arm/jump-reloc-veneers-cond-long.d: Update disassembly.
	* testsuite/ld-arm/jump-reloc-veneers-long.d: Update disassembly.

opcodes/ChangeLog:

	* arm-dis.c (struct arm_private_data): Remove has_mapping_symbols.
	(mapping_symbol_for_insn): Implement new algorithm.
	(print_insn): Remove duplicate code.
2019-03-25 15:05:53 +00:00
Sudakshina Das 4e5391148d [BFD, AArch64, x86] Improve warning for --force-bti
The AArch64 linker option to turn on BTI (--force-bti) warns in case there are
input objects which have a missing GNU NOTE section for BTI. This patch is trying
to improve the warnings that come out.

In order to do so, I propose adding a new argument to elf_merge_gnu_properties
and the backend function merge_gnu_properties. This new argument makes sure
that we now pass both the objects along with the properties to which they
belong to. The x86 backend function has also been updated to match this
change.

*** bfd/ChangeLog ***

2019-03-21  Sudakshina Das  <sudi.das@arm.com>

	* elf-bfd.h (struct elf_backend_data): Add argument to
	merge_gnu_properties.
	* elf-properties.c (elf_merge_gnu_properties): Add argument to
	itself and while calling bed->merge_gnu_properties.
	(elf_merge_gnu_property_list): Update the calls for
	elf_merge_gnu_properties.
	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
	of --force-bti warning and add argument.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
	warning.
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
	* elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
	declaration.

*** ld/ChangeLog ***

2019-03-21  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
	* testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
	* testsuite/ld-aarch64/bti-plt-6.d: Update warning.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: New test.
2019-03-21 16:20:21 +00:00
Alan Modra f84bd4655c Adjust pr14156 test for m68hc1*
The test section alignment is unnecessarily high, overflowing the
m68hc11 page used by .init code.

	* testsuite/ld-elf/fini2.s: Reduce alignment.
	* testsuite/ld-elf/fini3.s: Likewise.
	* testsuite/ld-elf/finin.s: Likewise.
	* testsuite/ld-elf/init2.s: Likewise.
	* testsuite/ld-elf/init3.s: Likewise.
	* testsuite/ld-elf/initn.s: Likewise.
	* testsuite/ld-elf/pr14156a.d: Don't xfail m68hc1*-* or xgate-*.
	* testsuite/ld-elf/pr14156b.d: Don't xfail xgate-*.
2019-03-21 22:19:51 +10:30
Alan Modra 2d3181c7c4 Add SORT_NONE to .init and .fini in scripts
The special case for .init and .fini in update_wild_statements is
ineffective for .init or .fini wildcards inside other output sections.
The special case needs to be on the wildcard, not the output section.
This patch is belt and braces, both fixing update_wild_statements and
the scripts.

	* scripttempl/alpha.sc, * scripttempl/armbpabi.sc,
	* scripttempl/crisaout.sc, * scripttempl/elf32cr16.sc,
	* scripttempl/elf32crx.sc, * scripttempl/elf32xc16x.sc,
	* scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc,
	* scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc,
	* scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc,
	* scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc,
	* scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc,
	* scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc,
	* scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc,
	* scripttempl/ft32.sc, * scripttempl/i386beos.sc,
	* scripttempl/iq2000.sc, * scripttempl/mcorepe.sc,
	* scripttempl/mep.sc, * scripttempl/mips.sc, * scripttempl/moxie.sc,
	* scripttempl/pe.sc, * scripttempl/pep.sc, * scripttempl/ppcpe.sc,
	* scripttempl/tic4xcoff.sc, * scripttempl/tic80coff.sc,
	* scripttempl/v850.sc, * scripttempl/v850_rh850.sc,
	* scripttempl/visium.sc, * scripttempl/xstormy16.sc: Add KEEP and
	SORT_NONE to .init and .fini wildcards.
	* scripttempl/elf32xc16x.sc,
	* scripttempl/elf32xc16xl.sc,
	* scripttempl/elf32xc16xs.sc: Add .fini wildcard.
	* scripttempl/elf_chaos.sc: Add .init output section.
	* scripttempl/elfd30v.sc: Remove duplicate .init.
	* scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc,
	* scripttempl/elfm9s12z.sc, * scripttempl/elfxgate.sc: Remove
	duplicate .init, and add .fini wildcard.
	* scripttempl/ppcpe.sc (INIT, FINI): Delete.
	* ldlang.c (update_wild_statements): Special case .init and
	.fini in the wildcard, not the output section.
2019-03-21 22:19:20 +10:30
Alan Modra 980a2e42f7 lm32-linux ld testsuite fails
A number of the fails are due to ld supporting the creation of shared
libraries but not allowing linking against them without using an
option like -Bdynamic.
FAIL: Symbol export class test (final shared object)
FAIL: PROVIDE_HIDDEN test 4
FAIL: PROVIDE_HIDDEN test 6
FAIL: PROVIDE_HIDDEN test 10
FAIL: PROVIDE_HIDDEN test 12
FAIL: Build pr22471b.so
FAIL: Build pr22649-2b.so
FAIL: Build pr22649-2d.so
FAIL: PR ld/20828 dynamic symbols with section GC (plain)
FAIL: PR ld/20828 dynamic symbols with section GC (version script)
FAIL: PR ld/20828 dynamic symbols with section GC (versioned)
FAIL: PR ld/21233 dynamic symbols with section GC (--undefined)
FAIL: PR ld/21233 dynamic symbols with section GC (--require-defined)
FAIL: PR ld/21233 dynamic symbols with section GC (EXTERN)
FAIL: Build pr22150
FAIL: PR ld/14170
FAIL: Link using broken linker script
FAIL: pr17068 link --as-needed lib in group
FAIL: ld-gc/pr20022

	* emulparams/elf32lm32fd.sh (DYNAMIC_LINK): Undef.
2019-03-21 08:57:30 +10:30
Alan Modra 3b6c196682 Fix some dlx fails
Generic linker ELF targets using CREATE_OBJECT_SYMBOLS in their
scripts run into a problem.  The file symbols are created by
_bfd_generic_link_output_symbols in each object file, in the section
corresponding to the CREATE_OBJECT_SYMBOLS section, typically .text.
If it so happens that the output .text section is stripped due to
being empty, then elf.c:assign_section_numbers won't assign an ELF
section number and swap_out_syms will report "unable to find
equivalent output section" for the object symbols.  Fix this by
always keeping an output section with CREATE_OBJECT_SYMBOLS.

	* ldlang.c (lang_size_sections_1): Set SEC_KEEP on
	create_object_symbols_section.
	* testsuite/ld-elf/pr22319.d: Don't xfail dlx.
2019-03-21 08:45:28 +10:30
Alan Modra 28a66f07f0 csky ld testsuite fixes
* testsuite/ld-elf/merge.d: Remove csky from xfails, add moxie.
	* testsuite/ld-elf/pr21884.d: Remove csky from xfails.
	* testsuite/ld-elf/shared.exp: Add csky to list not xfailing pr22374.
	* testsuite/ld-unique/pr21529.d: Remove csky from xfails
2019-03-18 22:37:26 +10:30
Nick Clifton 1c82ed745b Update the documentation describing where the linker will attempt to locate plugins.
PR 24262
	* ld.texi (-plugin): Correct the path used to locate linker
	plugins.
2019-03-15 12:08:56 +00:00
Sudakshina Das 1dbade7441 [BFD, LD, AArch64, 3/3] Add --pac-plt to enable PLTs protected with PAC.
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.

1) This patch adds new definitions of PAC enabled PLTs
and both BTI and PAC enabled PLTs.
2) It also defines the new dynamic tag DT_AARCH64_PAC_PLT
for the PAC enabled PLTs.
3) This patch adds a new ld command line option: --pac-plt.
In the presence of this option, the linker uses the PAC
enabled PLTs and marks with DT_AARCH64_PAC_PLT.
4) In case both BTI and PAC are enabled the linker should
pick PLTs enabled with both and also use dynamic tags for both.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4

*** bfd/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elfnn-aarch64.c (PLT_PAC_ENTRY_SIZE, PLT_PAC_SMALL_ENTRY_SIZE): New.
	(PLT_BTI_PAC_ENTRY_SIZE, PLT_BTI_PAC_SMALL_ENTRY_SIZE): New.
	(setup_plt_values): Account for PAC or PAC and BTI enabled PLTs.
	(elfNN_aarch64_size_dynamic_sections): Add checks for PLT_BTI_PAC
	and PLT_PAC_PLT.
	(elfNN_aarch64_finish_dynamic_sections): Account for PLT_BTI_PAC.
	(get_plt_type): Add case for DT_AARCH64_PAC_PLT.
	(elfNN_aarch64_plt_sym_val): Add cases for PLT_BTI_PAC and PLT_PAC.

*** binutils/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* readelf.c (get_aarch64_dynamic_type): Add case for
	DT_AARCH64_PAC_PLT.
	(dynamic_section_aarch64_val): Likewise.

*** include/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elf/aarch64.h (DT_AARCH64_PAC_PLT): New.

*** ld/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Document --pac-plt.
	* emultempl/aarch64elf.em (OPTION_PAC_PLT): New.
	(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add pac-plt.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_PAC_PLT.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add the following tests.
	* testsuite/ld-aarch64/bti-pac-plt-1.d: New test.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: New test.
	* testsuite/ld-aarch64/pac-plt-1.d: New test.
	* testsuite/ld-aarch64/pac-plt-2.d: New test.
	* testsuite/ld-aarch64/bti-plt-1.s: Add .ifndef directive.
2019-03-13 11:47:33 +00:00
Sudakshina Das 37c18eedff [BFD, LD, AArch64, 2/3] Add --force-bti to enable BTI and to select BTI enabled PLTs
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.

1) This patch adds a new ld command line option: --force-bti.
In the presence of this option, the linker enables BTI with the
GNU_PROPERTY_AARCH64_FEATURE_1_BTI feature. This gives out warning
in case of missing gnu notes for BTI in inputs.
2) It also defines a new set of BTI enabled PLTs. These are used either
when all the inputs are marked with GNU_PROPERTY_AARCH64_FEATURE_1_BTI
or when the new --force-bti option is used. This required adding new
fields in elf_aarch64_link_hash_table so that we could make the PLT
related information more generic.
3) It also defines a dynamic tag DT_AARCH64_BTI_PLT. The linker uses
this whenever it picks BTI enabled PLTs.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4

*** bfd/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* bfd-in.h (aarch64_plt_type, aarch64_enable_bti_type): New.
	(aarch64_bti_pac_info): New.
	(bfd_elf64_aarch64_set_options): Add aarch64_bti_pac_info argument.
	(bfd_elf32_aarch64_set_options): Likewise.
	* bfd-in2.h: Regenerate
	* elfnn-aarch64.c (PLT_BTI_ENTRY_SIZE): New.
	(PLT_BTI_SMALL_ENTRY_SIZE, PLT_BTI_TLSDESC_ENTRY_SIZE): New.
	(elfNN_aarch64_small_plt0_bti_entry): New.
	(elfNN_aarch64_small_plt_bti_entry): New.
	(elfNN_aarch64_tlsdesc_small_plt_bti_entry): New.
	(elf_aarch64_obj_tdata): Add no_bti_warn and plt_type fields.
	(elf_aarch64_link_hash_table): Add plt0_entry, plt_entry and
	tlsdesc_plt_entry_size fields.
	(elfNN_aarch64_link_hash_table_create): Initialise the new fields.
	(setup_plt_values): New helper function.
	(bfd_elfNN_aarch64_set_options): Use new bp_info to set plt sizes and
	bti enable type.
	(elfNN_aarch64_allocate_dynrelocs): Use new size members instead of
	fixed macros.
	(elfNN_aarch64_size_dynamic_sections): Likewise and add checks.
	(elfNN_aarch64_create_small_pltn_entry): Use new generic pointers
	to plt stubs instead of fixed ones and update filling them according
	to the need for bti.
	(elfNN_aarch64_init_small_plt0_entry): Likewise.
	(elfNN_aarch64_finish_dynamic_sections): Likewise.
	(get_plt_type, elfNN_aarch64_get_synthetic_symtab): New.
	(elfNN_aarch64_plt_sym_val): Update size accordingly.
	(elfNN_aarch64_link_setup_gnu_properties): Set up plts if BTI GNU NOTE
	is set.
	(bfd_elfNN_get_synthetic_symtab): Define.
	(elfNN_aarch64_merge_gnu_properties): Give out warning with --force-bti
	and mising BTI NOTE SECTION.

*** binutils/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* readelf.c (get_aarch64_dynamic_type): New.
	(get_dynamic_type): Use above for EM_AARCH64.
	(dynamic_section_aarch64_val): New.
	(process_dynamic_section): Use above for EM_AARCH64.

*** include/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* elf/aarch64.h (DT_AARCH64_BTI_PLT): New.

*** ld/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* NEWS: Document --force-bti.
	* emultempl/aarch64elf.em (plt_type, bti_type, OPTION_FORCE_BTI): New.
	(PARSE_AND_LIST_SHORTOPTS, PARSE_AND_LIST_OPTIONS): Add force-bti.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_FORCE_BTI.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add all the tests below.
	* testsuite/ld-aarch64/bti-plt-1.d: New test.
	* testsuite/ld-aarch64/bti-plt-1.s: New test.
	* testsuite/ld-aarch64/bti-plt-2.s: New test.
	* testsuite/ld-aarch64/bti-plt-2.d: New test.
	* testsuite/ld-aarch64/bti-plt-3.d: New test.
	* testsuite/ld-aarch64/bti-plt-4.d: New test.
	* testsuite/ld-aarch64/bti-plt-5.d: New test.
	* testsuite/ld-aarch64/bti-plt-6.d: New test.
	* testsuite/ld-aarch64/bti-plt-7.d: New test.
	* testsuite/ld-aarch64/bti-plt-so.s: New test.
	* testsuite/ld-aarch64/bti-plt.ld: New test.
2019-03-13 11:47:07 +00:00
Sudakshina Das cd702818c6 [BFD, LD, AArch64, 1/3] Add support for GNU PROPERTIES in AArch64 for BTI and PAC
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.

This patch implements the following:
1) This extends in the gnu property support in the linker for
AArch64 by defining backend hooks for elf_backend_setup_gnu_properties,
elf_backend_merge_gnu_properties and elf_backend_parse_gnu_properties.
2) It defines AArch64 specific GNU property
GNU_PROPERTY_AARCH64_FEATURE_1_AND and 2 bit for BTI and PAC in it.
3) It also adds support in readelf.c to read and print these new
GNU properties in AArch64.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4

*** bfd/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Exclude
	linker created inputs from merge.
	* elfnn-aarch64.c (struct elf_aarch64_obj_tdata): Add field for
	GNU_PROPERTY_AARCH64_FEATURE_1_AND properties.
	(elfNN_aarch64_link_setup_gnu_properties): New.
	(elfNN_aarch64_merge_gnu_properties): New.
	(elf_backend_setup_gnu_properties): Define for AArch64.
	(elf_backend_merge_gnu_properties): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Define.
	(_bfd_aarch64_elf_parse_gnu_properties): Define.
	(_bfd_aarch64_elf_merge_gnu_properties): Define.
	* elfxx-aarch64.h (_bfd_aarch64_elf_link_setup_gnu_properties): Declare.
	(_bfd_aarch64_elf_parse_gnu_properties): Declare.
	(_bfd_aarch64_elf_merge_gnu_properties): Declare.
	(elf_backend_parse_gnu_properties): Define for AArch64.

*** binutils/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* readelf.c (decode_aarch64_feature_1_and): New.
	(print_gnu_property_note): Add case for AArch64 gnu notes.

*** include/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elf/common.h (GNU_PROPERTY_AARCH64_FEATURE_1_AND): New.
	(GNU_PROPERTY_AARCH64_FEATURE_1_BTI): New.
	(GNU_PROPERTY_AARCH64_FEATURE_1_PAC): New.

*** ld/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Document GNU_PROPERTY_AARCH64_FEATURE_1_BTI and
	GNU_PROPERTY_AARCH64_FEATURE_1_PAC.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add run commands for new tests.
	* testsuite/ld-aarch64/property-bti-pac1.d: New test.
	* testsuite/ld-aarch64/property-bti-pac1.s: New test.
	* testsuite/ld-aarch64/property-bti-pac2.d: New test.
	* testsuite/ld-aarch64/property-bti-pac2.s: New test.
	* testsuite/ld-aarch64/property-bti-pac3.d: New test.
2019-03-13 11:47:00 +00:00
H.J. Lu 44b27f959a x86: Properly set IBT and SHSTK properties for -z ibt/shstk
There should be no AND properties if some input doesn't have them.  We
should set IBT and SHSTK properties for -z ibt and -z shstk if needed.

bfd/

	PR ld/24322
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Properly
	merge GNU_PROPERTY_X86_FEATURE_1_[IBT|SHSTK].

ld/

	PR ld/24322
	* testsuite/ld-i386/i386.exp: Run PR ld/24322 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr24322a.d: New file.
	* testsuite/ld-i386/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.d: Likewise.
	* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.s: Likewise.
	* testsuite/ld-x86-64/pr24322b.s: Likewise.
	* testsuite/ld-x86-64/pr24322c.s: Likewise.
2019-03-13 14:38:29 +08:00
Nick Bowler 912ebfa0d7 Allow the use of the ORIGIN and LENGTH attributes in expressions inside MEMORY regions.
PR 24289
	* ldexp.c (fold_name): Allow lookups of the LENGTH and ORIGIN
	attributes during the first phase.
2019-03-06 15:20:29 +00:00
Andreas Krebbel 24801b1576 Revert "Add support to GNU ld to separate got related plt entries"
bfd/ChangeLog:

2019-03-01  Andreas Krebbel  <krebbel@linux.ibm.com>

	This reverts commit 5a12586d44.
	2019-01-14  Maamoun Tarsha  <maamountk@hotmail.com>

	PR 20113
	* elf32-s390.c (allocate_dynrelocs): Update comment.

ld/ChangeLog:

2019-03-01  Andreas Krebbel  <krebbel@linux.ibm.com>

	This reverts commit 5a12586d44.
	2019-01-14  Maamoun Tarsha  <maamountk@hotmail.com>

	PR 20113
	* emulparams/elf64_s390.sh (SEPARATE_GOTPLT): Define.
	* emulparams/elf_s390.sh (SEPARATE_GOTPLT): Define.
	* testsuite/ld-s390/gotreloc_31-1.dd: Update expected output.
	* testsuite/ld-s390/tlsbin.dd: Likewise.
	* testsuite/ld-s390/tlsbin.rd: Likewise.
	* testsuite/ld-s390/tlsbin.sd: Likewise.
	* testsuite/ld-s390/tlsbin_64.dd: Likewise.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.
	* testsuite/ld-s390/tlsbin_64.sd: Likewise.
	* testsuite/ld-s390/tlspic.dd: Likewise.
	* testsuite/ld-s390/tlspic.rd: Likewise.
	* testsuite/ld-s390/tlspic.sd: Likewise.
	* testsuite/ld-s390/tlspic_64.dd: Likewise.
	* testsuite/ld-s390/tlspic_64.rd: Likewise.
	* testsuite/ld-s390/tlspic_64.sd: Likewise.
	* testsuite/ld-s390/s390.exp: Skip s390 tests for tpf targets.
2019-03-01 15:35:00 +01:00
H.J. Lu 5cfe428cd1 x86-64: Skip protected check on symbol defined by linker
Skip symbol defined by linker when checking copy reloc on protected
symbol.

bfd/

	PR ld/24276
	* elf64-x86-64.c (elf_x86_64_check_relocs): Skip symbol defined
	by linker when checking copy reloc on protected symbol.

ld/

	PR ld/24276
	* testsuite/ld-i386/i386.exp: Run PR ld/24276 test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr24276.dso: New file.
	* testsuite/ld-i386/pr24276.warn: Likewise.
	* testsuite/ld-x86-64/pr24276.dso: Likewise.
	* testsuite/ld-x86-64/pr24276.warn: Likewise.
2019-02-27 11:53:27 -08:00
Max Filippov eed62915fd bfd: xtensa: fix callx relaxation
Big section alignment requirements between source and destination of a
long call can result in making call range bigger than what's reachable
by the call opcode. Add biggest section alignment of sections between
the call site and call destination to the call distance when making
long call relaxation decision.

2019-02-20  Eric Tsai  <erictsai@cadence.com>
bfd/
	* elf32-xtensa.c (is_resolvable_asm_expansion): Scan output
	sections between the call site and call destination and adjust
	call distance by the largest alignment.

ld/
	* testsuite/ld-xtensa/call_overflow.d: New test definition.
	* testsuite/ld-xtensa/call_overflow1.s: New test source.
	* testsuite/ld-xtensa/call_overflow2.s: New test source.
	* testsuite/ld-xtensa/call_overflow3.s: New test source.
	* testsuite/ld-xtensa/xtensa.exp: Add call_overflow test.
2019-02-20 02:51:01 -08:00
Thomas Schwinge abc163a464 [ld, hurd] Remove 'ld-elf/elf.exp' XFAILs
... as a follow-up to commit d981640286 "Run more
ld tests when not native", which replaced by a proper solution the following
mess before present in 'ld/configure.host':

    -*-*-gnu*)
    -  # When creating static executables, we ought to use crt0.o instead of crt1.o,
    -  # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>,
    -  # but the testing infrastructure is not prepared for that.  This is not
    -  # relevant for most tests, and the few remaining ones have been XFAILed.
    -  HOSTING_CRT0='[...]'
    -  HOSTING_LIBS='[...]'

	ld/
	* testsuite/ld-elf/elf.exp: Remove Hurd XFAILs.
2019-02-14 17:51:22 +01:00
Nick Clifton e486594504 Updated French translation for ld/ and gold/ subdirectories 2019-02-12 13:22:42 +00:00
Claudiu Zissulescu a0e90a73f0 [ARC] don't force _init/_fini as DT_INIT/DT_FINI.
Recent gcc commit b4371b277f1e ("[ARC] Enable init_array support")
inhibits DT_"INIT,FINI} in favor of DT_{INIT,FINI}ARRAY.

Even prior to that, it seems ARC port is the only one with this
special DT_INIT/FINI handling in linker emulation. Removing it
doesn't seem to change any uClibc/glibc testsuite results,
so this can RIP anyways.

bfd/
    2019-02-01  Vineet Gupta <vgupta@synopsys.com>

           * elf32-arc.c: Delete init_str, fini_str

ld/
    2019-02-01  Vineet Gupta <vgupta@synopsys.com>

           * emultempl/arclinux.em : Delete special INIT/FINI handling.
2019-02-09 11:07:42 +01:00
Nick Clifton 5d3db3e297 Fix typo in description of --start-group/--end-group options.
PR 24175
	* ld.texi (Options): Add missing word to the description of the
	--start-group option.
2019-02-07 14:54:58 +00:00
Alan Modra 4249a53cce Fix some ldscripts/pr24008 fails
These targets were all failing due to extra symbols.
pdp11-dec-aout  +FAIL: ld-scripts/pr24008
powerpc-aix5.1  +FAIL: ld-scripts/pr24008
powerpc-aix5.2  +FAIL: ld-scripts/pr24008
rs6000-aix4.3.3  +FAIL: ld-scripts/pr24008
rs6000-aix5.1  +FAIL: ld-scripts/pr24008
rs6000-aix5.2  +FAIL: ld-scripts/pr24008

Some fails remain, those I saw were segfaults or assertion fails that
indicate target bugs.

	PR ld/24008
	* testsuite/ld-scripts/pr24008.d: Pass with extra target
	defined symbols.
2019-02-06 17:33:54 +10:30
H.J. Lu 83924b3846 x86-64: Restore PIC check for PCREL reloc against protected symbol
commit bd7ab16b45
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Feb 13 07:34:22 2018 -0800

    x86-64: Generate branch with PLT32 relocation

removed check R_X86_64_PC32 relocation against protected symbols in
shared objects.  Since elf_x86_64_check_relocs is called after we
have seen all input files, we can check for PC-relative relocations in
elf_x86_64_check_relocs.  We should not allow PC-relative relocations
against protected symbols since address of protected function and
location of protected data may not be in the shared object.

bfd/

	PR ld/24151
	* elf64-x86-64.c (elf_x86_64_need_pic): Check
	SYMBOL_DEFINED_NON_SHARED_P instead of def_regular.
	(elf_x86_64_relocate_section): Move PIC check for PC-relative
	relocations to ...
	(elf_x86_64_check_relocs): Here.
	(elf_x86_64_finish_dynamic_symbol): Use SYMBOL_DEFINED_NON_SHARED_P
	to check if a symbol is defined in a non-shared object.
	* elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): New.

ld/

	PR ld/24151
	* testsuite/ld-x86-64/pr24151a-x32.d: New file.
	* testsuite/ld-x86-64/pr24151a.d: Likewise.
	* testsuite/ld-x86-64/pr24151a.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr24151a and pr24151a-x32.
2019-02-05 18:45:34 -08:00
Alan Modra 4f4690cd42 Document ld -t behaviour
* NEWS: Mention -t change.
	* ld.texi (--trace/-t): Expand documentation a little.
2019-01-31 11:37:44 +10:30
H.J. Lu ad0f979c9d Add a testcase for PR ld/24008
PR ld/24008
	* testsuite/ld-scripts/defined.exp: Run pr24008.
	* testsuite/ld-scripts/pr24008.d: New file.
	* testsuite/ld-scripts/pr24008.map: Likewise.
	* testsuite/ld-scripts/pr24008.s: Likewise.
	* testsuite/ld-scripts/pr24008.t: Likewise.
2019-01-29 06:07:42 -08:00
Eric Botcazou c49829c3c3 Skip ld/pr23169 on SPARC.
The test is already skipped on PowerPC and Aarch64 because it's invalid.

	* testsuite/ld-ifunc/ifunc.exp: Skip pr23169 on SPARC.
2019-01-29 10:11:01 +01:00
Alan Modra 6a84624340 PR24008, Wrong value of ternary expression in map file
PR 24008
	* ldexp.h (lang_phase_type): Add lang_fixed_phase_enum.
	* ldexp.c (fold_name): Move expld.assign_name check later to
	avoid an extra lookup.
	(exp_fold_tree_1): When lang_fixed_phase_enum, don't change symbol
	values, and don't clear expld.assign_name.
	* ldlang.c (lang_map): Set expld.phase to lang_fixed_phase_enum.
	(print_assignment): Resolve entire assignment expression.
	Don't access symbol u.def unless symbol is defined.
2019-01-28 09:59:29 +10:30
Nick Clifton 9ed1348c20 Updated Bulgarian and Russian translations for some of the binutils sub-directories 2019-01-25 11:48:55 +00:00
Sebastian Huber 6406a2701b ld: Add LTO warning to --wrap documentation
ld/

	* ld.texi (--wrap): Add warning that LTO may make this feature
	ineffective.
2019-01-23 09:47:28 +01:00
Nick Clifton a6c9b40429 Updated Brazilian Portuguese translation for the ld/ subdirectory. 2019-01-21 13:05:44 +00:00
Nick Clifton 375cd4233d Updated translations for various binutils subdirectories. 2019-01-21 12:59:20 +00:00
Yuri Chornoivan acef8081ec Fix spelling mistakes in BFD library.
PR 24108
bfd	* elf32-nds32.c (nds32_relocate_section): Add space between words
	in error message.
	* elfnn-riscv.c (riscv_version_mismatch): Fix spelling mistake in
	error message.
	(riscv_i_or_e_p): Likewise.
	(riscv_merge_arch_attr_info): Likewise.

ld	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Update
	expected error message.
2019-01-21 12:39:24 +00:00
Nick Clifton f48dfe417e Change version to 2.32.51 and regenerate configure and pot files. 2019-01-19 16:51:42 +00:00
Nick Clifton f974f26cb1 Add markers for 2.32 branch to NEWS and ChangeLog files. 2019-01-19 15:55:50 +00:00
Jim Wilson 7d7a7d7ccf RISC-V: Merge ELF attribute for ld.
2019-01-16  Kito Cheng  <kito@andestech.com>
		    Nelson Chu  <nelson@andestech.com>

	bfd/
	* elfnn-riscv.c (in_subsets): New.
	(out_subsets): Likewise.
	(merged_subsets): Likewise.
	(riscv_std_ext_p): Likewise.
	(riscv_non_std_ext_p): Likewise.
	(riscv_std_sv_ext_p): Likewise.
	(riscv_non_std_sv_ext_p): Likewise.
	(riscv_version_mismatch): Likewise.
	(riscv_i_or_e_p): Likewise.
	(riscv_merge_std_ext): Likewise.
	(riscv_merge_non_std_and_sv_ext): Likewise.
	(riscv_merge_arch_attr_info): Likewise.
	(riscv_merge_attributes): Likewise.
	(_bfd_riscv_elf_merge_private_bfd_data): Merge attribute.
	ld/
	* testsuite/ld-elf/orphan-region.d: XFAIL for RISC-V, because add new
	section.
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Add new tests.
	* testsuite/ld-riscv-elf/attr-merge-arch-01.d: New test.
	* testsuite/ld-riscv-elf/attr-merge-arch-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-01b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-failed-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-failed-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-failed.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05b.s: Likewise.
2019-01-16 13:28:35 -08:00
Nick Clifton f466c3053d Correct PR number in prevvious delta 2019-01-14 16:04:18 +00:00
Maamoun Tarsha 5a12586d44 Add support to GNU ld to separate got related plt entries from normal ones in order to be able to switch the non-plt got entries to read-only after startup, conforming to revised Linux for zSeries ABI.
PR 20133
	* emulparams/elf64_s390.sh (SEPARATE_GOTPLT): Define.
	* emulparams/elf_s390.sh (SEPARATE_GOTPLT): Define.
	* testsuite/ld-s390/gotreloc_31-1.dd: Update expected output.
	* testsuite/ld-s390/tlsbin.dd: Likewise.
	* testsuite/ld-s390/tlsbin.rd: Likewise.
	* testsuite/ld-s390/tlsbin.sd: Likewise.
	* testsuite/ld-s390/tlsbin_64.dd: Likewise.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.
	* testsuite/ld-s390/tlsbin_64.sd: Likewise.
	* testsuite/ld-s390/tlspic.dd: Likewise.
	* testsuite/ld-s390/tlspic.rd: Likewise.
	* testsuite/ld-s390/tlspic.sd: Likewise.
	* testsuite/ld-s390/tlspic_64.dd: Likewise.
	* testsuite/ld-s390/tlspic_64.rd: Likewise.
	* testsuite/ld-s390/tlspic_64.sd: Likewise.
	* testsuite/ld-s390/s390.exp: Skip s390 tests for tpf targets.
2019-01-14 16:00:14 +00:00
Sebastian Huber 4ea904edb7 ld: Clarify --wrap documentation
ld/

	* ld.texi (--wrap): Add example to emphasise that only undefined
	references are replaced by the linker.
2019-01-14 08:24:44 +01:00
Nick Clifton 8379fac67e Updated Spanish translation for the ld sub-directory.
* po/es.po: Updated Spanish translation.
2019-01-09 12:34:28 +00:00
Andrew Paprocki 3107326d3d Adjust bfd/warning.m4 egrep patterns
Adjust the `bfd/warning.m4` `egrep` patterns to handle preprocessors
that do not define `__GNUC__`, leaving the string in the output.

bfd/
	* warning.m4: Adjust egrep pattern for non-GNU compilers.
	* configure: Regenerate.
binutils/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gold/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
ld/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
2019-01-09 13:51:08 +10:30
Alan Modra 171b8e1957 run_dump_test source in build directory
Some existing tests build .s and .d files for run_dump_test, using an
absolute #source: line in the .d file.  This patch changes that scheme
a little to instead use "#source: ./..." in .d files rather than
"#source: $objdir/...", which is more useful in cases where the .d
file is not generated.

This allows RX gas test files to be built in the build directory,
rather than in a source directory (which might be read-only).

binutils/
	* testsuite/lib/binutils-common.exp (run_dump_test): Don't prepend
	$srcdir/$subdir to source file name if it starts with "./".
gas/
	* testsuite/gas/rx/rx.exp: Create generated test source in
	current directory.
	* testsuite/gas/rx/Xtod.d, * testsuite/gas/rx/abs.d,
	* testsuite/gas/rx/adc.d, * testsuite/gas/rx/add.d,
	* testsuite/gas/rx/and.d, * testsuite/gas/rx/bclr.d,
	* testsuite/gas/rx/bcnd.d, * testsuite/gas/rx/bfmov.d,
	* testsuite/gas/rx/bmcnd.d, * testsuite/gas/rx/bnot.d,
	* testsuite/gas/rx/bra.d, * testsuite/gas/rx/brk.d,
	* testsuite/gas/rx/bset.d, * testsuite/gas/rx/bsr.d,
	* testsuite/gas/rx/btst.d, * testsuite/gas/rx/clrpsw.d,
	* testsuite/gas/rx/cmp.d, * testsuite/gas/rx/dabs.d,
	* testsuite/gas/rx/dadd.d, * testsuite/gas/rx/dbt.d,
	* testsuite/gas/rx/dcmp.d, * testsuite/gas/rx/ddiv.d,
	* testsuite/gas/rx/div.d, * testsuite/gas/rx/divu.d,
	* testsuite/gas/rx/dmov.d, * testsuite/gas/rx/dmul.d,
	* testsuite/gas/rx/dneg.d, * testsuite/gas/rx/dpopm.d,
	* testsuite/gas/rx/dpushm.d, * testsuite/gas/rx/dround.d,
	* testsuite/gas/rx/dsqrt.d, * testsuite/gas/rx/dsub.d,
	* testsuite/gas/rx/dtoX.d, * testsuite/gas/rx/emaca.d,
	* testsuite/gas/rx/emsba.d, * testsuite/gas/rx/emul.d,
	* testsuite/gas/rx/emula.d, * testsuite/gas/rx/emulu.d,
	* testsuite/gas/rx/fadd.d, * testsuite/gas/rx/fcmp.d,
	* testsuite/gas/rx/fdiv.d, * testsuite/gas/rx/fmul.d,
	* testsuite/gas/rx/fsqrt.d, * testsuite/gas/rx/fsub.d,
	* testsuite/gas/rx/ftoi.d, * testsuite/gas/rx/ftou.d,
	* testsuite/gas/rx/gprel.d, * testsuite/gas/rx/int.d,
	* testsuite/gas/rx/itof.d, * testsuite/gas/rx/jmp.d,
	* testsuite/gas/rx/jsr.d, * testsuite/gas/rx/machi.d,
	* testsuite/gas/rx/maclh.d, * testsuite/gas/rx/maclo.d,
	* testsuite/gas/rx/max.d, * testsuite/gas/rx/min.d,
	* testsuite/gas/rx/mov.d, * testsuite/gas/rx/movco.d,
	* testsuite/gas/rx/movli.d, * testsuite/gas/rx/movu.d,
	* testsuite/gas/rx/msbhi.d, * testsuite/gas/rx/msblh.d,
	* testsuite/gas/rx/msblo.d, * testsuite/gas/rx/mul.d,
	* testsuite/gas/rx/mulhi.d, * testsuite/gas/rx/mullh.d,
	* testsuite/gas/rx/mullo.d, * testsuite/gas/rx/mvfacgu.d,
	* testsuite/gas/rx/mvfachi.d, * testsuite/gas/rx/mvfaclo.d,
	* testsuite/gas/rx/mvfacmi.d, * testsuite/gas/rx/mvfc.d,
	* testsuite/gas/rx/mvfcp.d, * testsuite/gas/rx/mvfdc.d,
	* testsuite/gas/rx/mvfdr.d, * testsuite/gas/rx/mvtacgu.d,
	* testsuite/gas/rx/mvtachi.d, * testsuite/gas/rx/mvtaclo.d,
	* testsuite/gas/rx/mvtc.d, * testsuite/gas/rx/mvtcp.d,
	* testsuite/gas/rx/mvtdc.d, * testsuite/gas/rx/neg.d,
	* testsuite/gas/rx/nop.d, * testsuite/gas/rx/not.d,
	* testsuite/gas/rx/opecp.d, * testsuite/gas/rx/or.d,
	* testsuite/gas/rx/pop.d, * testsuite/gas/rx/popc.d,
	* testsuite/gas/rx/popm.d, * testsuite/gas/rx/push.d,
	* testsuite/gas/rx/pushc.d, * testsuite/gas/rx/pushm.d,
	* testsuite/gas/rx/r-bcc.d, * testsuite/gas/rx/r-bra.d,
	* testsuite/gas/rx/racl.d, * testsuite/gas/rx/racw.d,
	* testsuite/gas/rx/rdacl.d, * testsuite/gas/rx/rdacw.d,
	* testsuite/gas/rx/revl.d, * testsuite/gas/rx/revw.d,
	* testsuite/gas/rx/rmpa.d, * testsuite/gas/rx/rolc.d,
	* testsuite/gas/rx/rorc.d, * testsuite/gas/rx/rotl.d,
	* testsuite/gas/rx/rotr.d, * testsuite/gas/rx/round.d,
	* testsuite/gas/rx/rstr.d, * testsuite/gas/rx/rte.d,
	* testsuite/gas/rx/rtfi.d, * testsuite/gas/rx/rts.d,
	* testsuite/gas/rx/rtsd.d, * testsuite/gas/rx/sat.d,
	* testsuite/gas/rx/satr.d, * testsuite/gas/rx/save.d,
	* testsuite/gas/rx/sbb.d, * testsuite/gas/rx/sccnd.d,
	* testsuite/gas/rx/scmpu.d, * testsuite/gas/rx/setpsw.d,
	* testsuite/gas/rx/shar.d, * testsuite/gas/rx/shll.d,
	* testsuite/gas/rx/shlr.d, * testsuite/gas/rx/smovb.d,
	* testsuite/gas/rx/smovf.d, * testsuite/gas/rx/smovu.d,
	* testsuite/gas/rx/sstr.d, * testsuite/gas/rx/stnz.d,
	* testsuite/gas/rx/stz.d, * testsuite/gas/rx/sub.d,
	* testsuite/gas/rx/suntil.d, * testsuite/gas/rx/swhile.d,
	* testsuite/gas/rx/tst.d, * testsuite/gas/rx/utof.d,
	* testsuite/gas/rx/wait.d, * testsuite/gas/rx/xchg.d,
	* testsuite/gas/rx/xor.d: Add #source line.
ld/
	* testsuite/ld-elf/sec64k.exp: Use . rather than $objdir in
	generated source file names.
	* testsuite/ld-m68k/m68k-got.exp: Likewise.
2019-01-08 18:50:54 +10:30
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Alan Modra d5c04e1bf8 ChangeLog rotation 2019-01-01 21:25:40 +10:30
Alan Modra 8fd04a4255 PR24042, Global-buffer-overflow problem in output_rel_find
place_orphan handled ELF SHT_REL/SHT_RELA specially, output_rel_find
didn't.  This mismatch was a bug and also meant it was possible to
craft an object where ld accessed section->name out of bounds.

	PR 24042
	* emultempl/elf32.em (output_rel_find): Drop "sec" param.  Add
	"rela".
	(gld${EMULATION_NAME}_place_orphan): Use sh_type to calculate
	"rela" param of output_rel_find when ELF.  Tidy uses of elfinput.
2018-12-31 17:56:32 +10:30
H.J. Lu b9519cfe98 x86: Properly handle PLT expression in directive
For PLT expressions, we should subtract the PLT relocation size only for
jump instructions.  Since PLT relocations are PC relative, we only allow
"symbol@PLT" in PLT expression.

gas/

	PR gas/23997
	* config/tc-i386.c (x86_cons): Check for invalid PLT expression.
	(md_apply_fix): Subtract the PLT relocation size only for jump
	instructions.
	* testsuite/gas/i386/reloc32.s: Add test for invalid PLT
	expression.
	* testsuite/gas/i386/reloc64.s: Likewise.
	* testsuite/gas/i386/ilp32/reloc64.s: Likewise.
	* testsuite/gas/i386/reloc32.l: Updated.
	* testsuite/gas/i386/reloc64.l: Likewise.
	* testsuite/gas/i386/ilp32/reloc64.l: Likewise.

ld/

	PR gas/23997
	* testsuite/ld-i386/i386.exp: Run PR gas/23997 test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-x86-64/pr23997a.s: New file.
	* testsuite/ld-x86-64/pr23997b.c: Likewise.
	* testsuite/ld-x86-64/pr23997c.c: Likewise.
2018-12-19 12:22:12 -08:00
H.J. Lu fc999e8020 Rename PR ld/22842 run-time test to "Run pr22842"
* testsuite/ld-x86-64/x86-64.exp: Rename PR ld/22842 run-time
	test to "Run pr22842".
2018-12-19 11:51:08 -08:00
H.J. Lu 0a59decbb8 elf: Add PT_GNU_PROPERTY segment type
Linkers group input note sections with the same name into one output
note section with the same name.  One output note section is placed in
one PT_NOTE segment.  New linkers merge all input .note.gnu.property
sections into one output .note.gnu.property section with a single
NT_GNU_PROPERTY_TYPE_0 note in a single PT_NOTE segment.  Since older
linkers treat input .note.gnu.property section as a generic note section
and just concatenate all input .note.gnu.property sections into one
output .note.gnu.property section without merging them, we may
see one or more NT_GNU_PROPERTY_TYPE_0 notes in PT_NOTE segment, which
are invalid.

GNU_PROPERTY_X86_UINT32_VALID was defined to address this issue such
that linker sets the bit for non-relocatable outputs.  But it isn't
sufficient:

1. It doesn't cover generic properties.
2. When -mx86-used-note=yes is passed to x86 assembler, the
GNU_PROPERTY_X86_UINT32_VALID bit is set in GNU_PROPERTY_X86_ISA_1_USED
property in object file and older linkers generate invalid
NT_GNU_PROPERTY_TYPE_0 notes with the GNU_PROPERTY_X86_UINT32_VALID bit
set.

I am proposing the following changes:

1. Add PT_GNU_PROPERTY segment type:

 # define PT_GNU_PROPERTY (PT_LOOS + 0x474e553)

which covers .note.gnu.property section.
2. Remove GNU_PROPERTY_X86_UINT32_VALID.

bfd/

	PR ld/23900
	* elf.c (get_program_header_size): Add a PT_GNU_PROPERTY
	segment for NOTE_GNU_PROPERTY_SECTION_NAME.
	(_bfd_elf_map_sections_to_segments): Create a PT_GNU_PROPERTY
	segment for NOTE_GNU_PROPERTY_SECTION_NAME.
	* elfxx-x86.c (_bfd_elf_link_setup_gnu_properties): Don't set
	GNU_PROPERTY_X86_UINT32_VALID.

binutils/

	PR ld/23900
	* readelf.c (get_segment_type): Support PT_GNU_PROPERTY.
	(decode_x86_isa): Don't check GNU_PROPERTY_X86_UINT32_VALID.
	(decode_x86_feature_1): Likewise.
	(decode_x86_feature_2): Likewise.
	(print_gnu_property_note): Remove GNU_PROPERTY_X86_UINT32_VALID
	check.
	* testsuite/binutils-all/i386/empty.d: Updated.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/i386/pr21231b.s: Change
	GNU_PROPERTY_X86_ISA_1_USED bits to 0x7fffffff.
	* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.

gas/

	PR ld/23900
	* config/tc-i386.c (x86_cleanup): Don't set
	GNU_PROPERTY_X86_UINT32_VALID.
	* testsuite/gas/i386/property-1.s: Change
	GNU_PROPERTY_X86_ISA_1_USED bits to 0.

include/

	PR ld/23900
	* elf/common.h (PT_GNU_PROPERTY): New.
	(GNU_PROPERTY_X86_UINT32_VALID): Removed.

ld/

	PR ld/23900
	* testsuite/ld-elf/elf.exp: Run PR ld/23900 test.
	* testsuite/ld-elf/pr23900-1-32.rd: New file.
	* testsuite/ld-elf/pr23900-1-64.rd: Likewise.
	* testsuite/ld-elf/pr23900-1.d: Likewise.
	* testsuite/ld-elf/pr23900-1.s: Likewise.
	* testsuite/ld-elf/pr23900-2.s: Likewise.
	* testsuite/ld-elf/pr23900-2a.d: Likewise.
	* testsuite/ld-elf/pr23900-2b.d: Likewise.
	* testsuite/ld-i386/ibt-plt-1.d: Adjusted.
	* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
	* testsuite/ld-i386/pr23372c.d: Expect <None>
	for GNU_PROPERTY_X86_ISA_1_USED.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23372d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372d.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5a.s: Change
	GNU_PROPERTY_X86_ISA_1_USED bits to 0.
	* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
2018-12-14 04:55:34 -08:00
H.J. Lu 550892eb5a Fix a typo in scripttempl/elf32xc16x.sc
* scripttempl/elf32xc16x.sc: Fix a typo.
2018-12-11 06:18:12 -08:00
H.J. Lu fbcc8bafeb Override the previous definition from IR object
Mark the previous definition from IR object as undefined so that the
generic linker will override it.

bfd/

	PR ld/23958
	* elflink.c (_bfd_elf_add_default_symbol): Override the previous
	definition from IR object.

ld/

	PR ld/23958
	* testsuite/ld-plugin/lto.exp: Run PR ld/23958 test.
	* testsuite/ld-plugin/pr23958.c: New file.
	* testsuite/ld-plugin/pr23958.t: Likewise.
2018-12-07 15:40:02 -08:00
H.J. Lu d2ef37ebd9 elf: Report property change when merging properties
With merging properties, report property change in linker map file, like

Merging program properties

Removed property 0xc0010000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x0) and /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o (0x0)
Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x3) and x.o (not found)
Removed property 0xc0000000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)
Removed property 0xc0000001 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)

bfd/

	* elf-properties.c (elf_find_and_remove_property): Add a
	bfd_boolean argument to indicate if the property should be
	removed.
	(elf_merge_gnu_property_list): Updated.  Report
	property change in linker map file.
	(elf_get_gnu_property_section_size): Skip property_remove
	properties.
	(elf_write_gnu_properties): Likewise.
	(_bfd_elf_link_setup_gnu_properties): Report property merge
	in linker map file.  Pass abfd to elf_merge_gnu_property_list.

include/

	* bfdlink.h (bfd_link_info): Add has_map_file.

ld/

	* NEWS: Updated for property change report.
	* ld.texi: Document property change report.
	* ldmain.c (main): Set link_info.has_map_file to TRUE when
	linker map file is used.
	* testsuite/ld-scripts/rgn-over1.d: Updated.
	* testsuite/ld-scripts/rgn-over2.d: Likewise.
	* testsuite/ld-scripts/rgn-over3.d: Likewise.
	* testsuite/ld-scripts/rgn-over4.d: Likewise.
	* testsuite/ld-scripts/rgn-over5.d: Likewise.
	* testsuite/ld-scripts/rgn-over6.d: Likewise.
	* testsuite/ld-scripts/rgn-over7.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Check linker map
	file.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.map: New file.
2018-12-07 08:30:43 -08:00
H.J. Lu fde51dd189 x86: Don't remove empty GNU_PROPERTY_X86_UINT32_OR_AND properties
For GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND
properties, a bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields and this property is present in all
relocatable input files.  A missing property implies that its bits have
unknown values.  When all bits in the the output pr_data field are zero,
this property should not be removed from output to indicate it has zero
in all bits.

bfd/

	PR ld/23372
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Don't remove
	empty properties for GNU_PROPERTY_X86_COMPAT_ISA_1_USED and
	GNU_PROPERTY_X86_UINT32_OR_AND.
	(_bfd_x86_elf_link_fixup_gnu_properties): Likewise.

ld/

	PR ld/23372
	* testsuite/ld-i386/pr23372a.d: Updated.
	* testsuite/ld-i386/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372a.d: Likewise.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
2018-12-04 06:01:14 -08:00
H.J. Lu b44ee3a8cf x86: Delay setting the iplt section alignment
Delay setting its alignment until we know it is non-empty.  Otherwise an
empty iplt section may change vma and lma of the following sections, which
triggers moving dot of the following section backwards, resulting in a
warning and section lma not being set properly.  It later leads to a
"File truncated" error.

bfd/

	PR ld/23930
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Update
	the iplt section alignment if it is non-empty.
	(_bfd_x86_elf_link_setup_gnu_properties): Set plt.iplt_alignment
	and delay setting the iplt section alignment.
	* elfxx-x86.h (elf_x86_plt_layout): Add iplt_alignment.

ld/

	PR ld/23930
	* testsuite/ld-i386/i386.exp: Run pr23930.
	* testsuite/ld-i386/pr23930.d: New file.
	* testsuite/ld-x86-64/pr23930-32.t: Likewise.
	* testsuite/ld-x86-64/pr23930-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23930.d: Likewise.
	* testsuite/ld-x86-64/pr23930.t: Likewise.
	* testsuite/ld-x86-64/pr23930a.s: Likewise.
	* testsuite/ld-x86-64/pr23930b.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr23930 and pr23930-x32.
2018-12-01 06:35:03 -08:00
Alan Modra ba85c15dab PR23937, powerpc64le local ifunc IRELATIVE relocs are wrong
IFUNC resolvers must always be called via their global entry point.
They will be called from ld.so rather than from the local executable.

	PR 23937
bfd/
	* elf64-ppc.c (write_plt_relocs_for_local_syms): Don't add local
	entry offset for ifuncs.
ld/
	* testsuite/ld-powerpc/pr23937.d,
	* testsuite/ld-powerpc/pr23937.s: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.
2018-11-30 16:18:58 +10:30
Thomas Preud'homme e368bf56d3 Document purpose of each ld statement lists
When discovering the statement lists via their header variable
statement_list, file_chain and input_file_chain it can be confusing to
figure out what they are for. They can point to the same initial
statement and the relation between the next field they use is not
obvious from the name.

This commit adds comment for each of those statement list header to
explain what they are for and what next field they use. It also rewrite
the comment for the next fields to simply redirect the reader to the
list header to avoid duplication of documentation.

2018-11-29  Thomas Preud'homme  <thomas.preudhomme@linaro.org>

ld/
	* ldlang.c (statement_list): Document purpose and what next field it
	uses.
	(file_chain): Likewise.
	(input_file_chain): Likewise.
	* ldlang.h (lang_statement_header_type): Document statement list header
	the next pointer correspond to.
	(lang_statement_header_type): Replace comment for next and
	next_real_file field to refer the reader to their corresponding
	statement list header.
2018-11-29 13:42:49 +00:00
Maciej W. Rozycki 3c7687b9cd MIPS/LD: Accept high-part relocations in PIC code with absolute symbols
Accept R_MIPS_HI16, R_MIPS_HIGHER and R_MIPS_HIGHEST relocations and
their compressed counterparts in PIC code where the symbol referred is
absolute.  Such an operation is meaningful, because an absolute symbol
effectively is a constant the calculation of the value of which has been
deferred to the static link time, and which is not going to change any
further at the dynamic load time.  Therefore there is no need ever to
refuse the use of these relocations with such symbols, as the resulting
run-time value observed by the program will be correct even in PIC code.

This is not the case with R_MIPS_26 and its compressed counterparts,
because the run-time value calculated by the instructions these
relocations are used with depends on the address of the instruction
itself, and that can change according to the base address used by the
dynamic loader.  Therefore these relocations have to continue being
rejected in PIC code even with absolute symbols.

This allows successful linking of code that relies on previous linker
behavior up to commit 861fb55ab5 ("Defer allocation of R_MIPS_REL32
GOT slots"), <https://sourceware.org/ml/binutils/2008-08/msg00096.html>,
which introduced the problematic check missing this special exception
for absolute symbols.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_HI16>
	<R_MIPS_HI16, R_MIPS_HIGHER, R_MIPS_HIGHEST, R_MICROMIPS_HI16>
	<R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST>: Also accept an
	absolute symbol in PIC code.

	ld/
	* testsuite/ld-mips-elf/pic-reloc-0.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-1.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-2.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-3.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-4.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-absolute-hi.ld: New test
	linker script.
	* testsuite/ld-mips-elf/pic-reloc-absolute-lo.ld: New test
	linker script.
	* testsuite/ld-mips-elf/pic-reloc-ordinary.ld: New test linker
	script.
	* testsuite/ld-mips-elf/pic-reloc-j.s: New test source.
	* testsuite/ld-mips-elf/pic-reloc-lui.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-11-27 16:34:03 +00:00
Maciej W. Rozycki a5990ada63 LD: Convert `%P: %H:' to `%H:' in error messages
Similarly to commit 174d0a74a2 ("PowerPC/BFD: Convert `%P: %H:' to
`%H:' in error messages") convert linker relocation error messages to
use `%H:' rather `%P: %H:', removing inconsistent message composition
like:

$ cat reloc-j.s
	.text
	.globl	foo
	.ent	foo
foo:
	j	bar
	j	bar
	.end	foo
$ cat reloc-j.ld
SECTIONS
{
  bar = 0x12345678;
  .text : { *(.text) }
  /DISCARD/ : { *(*) }
}
$ as -o reloc-j.o reloc-j.s
$ ld -T reloc-j.ld -o reloc-j reloc-j.o
ld: tmpdir/reloc-j.o: in function `foo':
(.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
ld: (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
$

where subsequent lines referring to issues within a single function have
the name of the linker executable prepended, but the first one does not.

As noted with the commit referred this breaks a GNU Coding Standard's
requirement that error messages from compilers should look like this:

source-file-name:lineno: message

also quoted in `vfinfo' code handling these specifiers.

Remove the linker name prefix then, making the messages now look like:

$ ld -T reloc-j.ld -o reloc-j reloc-j.o
tmpdir/reloc-j.o: in function `foo':
(.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
(.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
$

instead.

	ld/
	* ldmain.c (reloc_overflow): Use `%H:' rather than `%P: %H:'
	with `einfo'.
	(reloc_dangerous): Likewise.
	(unattached_reloc): Likewise.
2018-11-27 16:34:03 +00:00
Tamar Christina 9fca35fc34 AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)
The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed
into MOVZ, however this causes issues for the erratum code.

The erratum code scans the input sections looking for ADRP instructions
and notes their location in the stream.

It then later tries to find them again in order to generate the linker
stubs.  Due to the relaxation it instead finds a MOVZ and hard aborts.

Since this relaxation is a valid one, and in which case the erratum no
longer applies, it shouldn't abort but instead just continue.

This changes the TLS relaxation code such that when it finds an ADRP and
it relaxes it, it removes the erratum entry from the work list by changing
the stub type into none so the stub is ignored.

The entry is not actually removed as removal is a more expensive operation
and we have already allocated the memory anyway.

The clearing is done for IE->LE and GD->LE relaxations, and a testcase is
added for the IE case. The GD case I believe to be impossible to get together
with the erratum sequence due to the required BL which would break the sequence.
However to cover all basis I have added the guard there as well.

build on native hardware and regtested on
  aarch64-none-elf, aarch64-none-elf (32 bit host),
  aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)

Cross-compiled and regtested on
  aarch64-none-linux-gnu, aarch64_be-none-linux-gnu

Testcase in PR23940 tested and works as expected now and benchmarks ran on A53
showing no regressions and no issues.

bfd/ChangeLog:

	PR ld/23904
	* elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants.
	(_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p.
	(struct erratum_835769_branch_to_stub_clear_data): New.
	(_bfd_aarch64_erratum_843419_clear_stub): New.
	(clear_erratum_843419_entry): New.
	(elfNN_aarch64_tls_relax): Use it.
	(elfNN_aarch64_relocate_section): Pass input_section.
	(aarch64_map_one_stub): Handle branch type none as valid.

ld/ChangeLog:

	PR ld/23904
	* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie.
	* testsuite/ld-aarch64/erratum843419_tls_ie.d: New test.
	* testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.
2018-11-27 12:42:22 +00:00
Nick Clifton 81c688d54f (Another) Updated Spanish translation for the ld subdirectory.
* po/es.po: Updated Spanish translation.
2018-11-16 11:36:08 +00:00
Nick Clifton 92b3642af0 Updated Spanish translation for the ld subdirectory.
ld	* po/es.po: Updated Spanish translation.
2018-11-15 11:55:24 +00:00
H.J. Lu f77984e974 i386: Accept both .plt.got and .plt.sec sections
Glibc commit:

commit a15529fda8d132621328c3fe32997a3d9c55aef4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon May 14 09:23:55 2018 -0700

    i386: Replace PREINIT_FUNCTION@PLT with *%eax in call

    Since we have loaded address of PREINIT_FUNCTION into %eax, we can
    avoid extra branch to PLT slot.

changed __gmon_start__ relocations in crt1.o from

00000015  0000092b R_386_GOT32X           00000000   __gmon_start__
0000001e  00000904 R_386_PLT32            00000000   __gmon_start__

to

00000015  00000a2b R_386_GOT32X           00000000   __gmon_start__

As the result, .plt.sec section may be generated instead of .plt.got
section, depending on __gmon_start__ relocations.

	* testsuite/ld-i386/plt-main-ibt.dd: Accept both .plt.got and
	.plt.sec sections.
2018-11-12 09:29:49 -08:00
Nick Clifton 8a758655b3 Update documentation describing how the linker chooses a start address.
PR 10865
	* ld.texi (Entry Point): Make it clear that the text refers to
	PE-based systems rather than just a PE system.
2018-11-12 15:12:15 +00:00
Nick Clifton d1b603a74e Updated Spanish translation for the ld subdirectory.
ld	* po/es.po: Updated Spanish translation.
2018-11-12 11:24:18 +00:00
Nick Clifton fda57deda7 Updated French translation for the ld subdirectory.
* po/fr.po: Updated French translation.
2018-11-09 14:18:02 +00:00
Claudiu Zissulescu 0d0b0a378e [ARC] Update ld tests.
ld/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* testsuite/ld-arc/tls_gd-01.d: Update test.
	* testsuite/ld-arc/arclinux-nps.d: Add cpu option.
2018-11-09 13:24:29 +02:00
Marc 73af69e749 Allow for compilers that do not produce aligned .rdat sections in PE format files.
PR 23872
	* scripttempl/pep.sc (pe.sc): Ensure rdata_runtime_pseudo_relocs
	are aligned.
	* scripttempl/pep.sc (pep.sc): Likewise.
2018-11-09 11:13:50 +00:00
H.J. Lu 8a6b075bc0 elfedit: Add --enable-x86-feature/--disable-x86-feature
Add --enable-x86-feature and --disable-x86-feature options to elfedit
to set and clear the IBT and SHSTK bits in program property in ELF
executables and shared objects.

binutils/

	* doc/binutils.texi: Document --enable-x86-feature and
	--disable-x86-feature options for elfedit.
	* elfedit.c: Include "config.h" and <sys/mman.h>.
	(enable_x86_features): New.
	(disable_x86_features): Likewise.
	(update_gnu_property): Likewise.
	(elf_x86_feature): Likewise.
	(process_file): Call update_gnu_property on ET_EXEC or ET_DYN
	file.
	(command_line_switch): Add OPTION_ENABLE_X86_FEATURE and
	OPTION_DISABLE_X86_FEATURE.
	(options): Add--enable-x86-feature and --disable-x86-feature.
	(usage): Likewise.
	(main): Handle OPTION_ENABLE_X86_FEATURE and
	OPTION_DISABLE_X86_FEATURE.

ld/

	* testsuite/config/default.exp (ELFEDIT): New.
	* testsuite/ld-elf/linux-x86.exp (elfedit_test): New proc.
	Run elfedit tests.
	* testsuite/ld-elf/x86-feature-1a.rd: New file.
	* testsuite/ld-elf/x86-feature-1b.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1c.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1d.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1e.rd: Likewise.
2018-11-06 09:38:51 -08:00
H.J. Lu a4749e56ca Correct ChangeLog entries for PR gas/23854 commit
commit e60f4d3bda
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Nov 5 09:01:26 2018 -0800

    x86: Disable GOT relaxation with data prefix

    Since linker GOT relaxation isn't valid for 16-bit GOT access, we should
    disable GOT relaxation with data prefix.
2018-11-05 11:13:30 -08:00
H.J. Lu e60f4d3bda x86: Disable GOT relaxation with data prefix
Since linker GOT relaxation isn't valid for 16-bit GOT access, we should
disable GOT relaxation with data prefix.

gas/

	PR gas/r23854
	* config/tc-i386.c (output_disp): Disable GOT relaxation with
	data prefix.
	* testsuite/gas/i386/mixed-mode-reloc32.d: Updated.

ld/

	PR gas/r23854
	* testsuite/ld-i386/i386.exp: Run pr23854.
	* testsuite/ld-x86-64/x86-64.exp: Likewwise.
	* testsuite/ld-i386/pr23854.d: New file.
	* testsuite/ld-i386/pr23854.s: Likewwise.
	* testsuite/ld-i386/pr23854.d: Likewwise.
	* testsuite/ld-x86-64/pr23854.d: Likewwise.
	* testsuite/ld-x86-64/pr23854.s: Likewwise.
2018-11-05 09:01:43 -08:00
Thomas Preud'homme 33ea299c25 Fix ld action in run_dump_test
run_dump_test proposes an ld action but when trying to make use of it in
a gas test it gave me some Tcl error. It turns out that it references
the check_shared_lib_support procedure and ld_elf_shared_opt variable
both only available in ld-lib.exp. I've thus moved the procedure in
binutils-common.exp and defined the variable needed in the various
default.exp of testsuite that seem to be using run_dump_test.

Since check_shared_lib_support itself references the ld variable not
defined in binutils-common I've defined it from LD in run_dump_test and
fixed LD and LDFLAGS to be defined as expected by run_dump_test in the
various default.exp of testsuite using run_dump_test.

2018-11-01  Thomas Preud'homme  <thomas.preudhomme@linaro.org>

binutils/
	* testsuite/config/default.exp: Define LD, LDFLAGS and
	ld_elf_shared_opt.
	* testsuite/lib/binutils-common.exp (check_shared_lib_support): Moved
	from ld-lib.exp.
	(run_dump_test): Set ld to $LD.

gas/
	* testsuite/config/default.exp: Define LD, LDFLAGS and
	ld_elf_shared_opt.

ld/
	* testsuite/lib/ld-lib.exp (check_shared_lib_support): Moved to
	binutils-common.exp.
2018-11-01 17:19:17 +00:00
Alan Modra 727a29badd Report scripts and libraries searched for ld --trace
The idea of this change is to make -t output useful for users wanting
to package all the object files involved in linking for a bug report.

Something like the following should do the trick.
gcc hello.c -save-temps -Wl,-t | xargs realpath | sort | uniq > files
tar cJf test.tar.xz `cat files`

	* ldlang.c (load_symbols): When -t, print file names for script
	files and archives.
	* ldmain.c (trace_files): Make an int.
	(add_archive_element): Print archive elements only with multiple
	-t options, or when archive is thin.
	* ldmain.h (trace_files): Update.
	* ldmisc.c (vfinfo): Don't print both original path and path in
	sysroot.
	* lexsup.c (parse_args <t>): Increment trace_files.
2018-10-29 18:21:05 +10:30
Alan Modra 5c87f94bb8 Remove some ld --trace output
This output really belongs in ld --verbose.

	* ldmain.c (main): Print emulation mode and "deleting executable"
	for --verbose, not --trace.
	(add_archive_element): Only print "no new IR symbols" for --verbose.
2018-10-29 18:21:05 +10:30
Alan Modra 55d5520ae3 Simplify --sysroot=/
Prepending '/' to absolute paths doesn't gain us much, and results in
the current implementation of --trace emitting silly path-in-sysroot
output, eg.
/lib/ld-linux-x86-64.so.2 (//lib/ld-linux-x86-64.so.2)

	* ldmain.c (get_sysroot): Return "" for "--sysroot=/".
2018-10-29 18:21:05 +10:30
Alan Modra c2e863866d ld -r script fixes
For ld -r, we generally set the VMA of sections to zero.  This is done
to make the output of ld -r most similar to that output by the
assembler, which generally has sections starting at VMA zero.  In some
cases that covers for backend bugs which would mis-handle relocatable
object files with non-zero section VMAs.

This patch fixes a few sections that didn't have zero VMAs for ld -r.
A missing zero on .note.gnu.build-id and .eh_frame_hdr doesn't matter
much since these are linker generated symbols only output on final
link, but it's good to be consistent.

	* Makefile.am (ei386beos.c, ei386go32.c): Correct dependencies.
	* Makefile.in: Regenerate.
	* scripttempl/elf.sc (.note.gnu.build-id, .eh_frame_hdr): Set
	address with ${RELOCATING-0}.
	* scripttempl/arclinux.sc: Likewise.
	* scripttempl/armbpabi.sc: Likewise.
	* scripttempl/avr.sc: Likewise.
	* scripttempl/elf64hppa.sc: Likewise.
	* scripttempl/elf_chaos.sc: Likewise.
	* scripttempl/elfarc.sc: Likewise.
	* scripttempl/elfxtensa.sc: Likewise.
	* scripttempl/mep.sc: Likewise.
	* scripttempl/nds32elf.sc: Likewise.
	* scripttempl/pru.sc: Likewise.
	* scripttempl/elf32msp430.sc: Likewise, and for other sections.
	* scripttempl/epiphany_4x4.sc: Similarly.
2018-10-29 17:50:40 +10:30
Christoph Conrads b69e1ff350 ELF: update ld man page on `--gc-sections`
Commit 91ae256e33 fixes the behavior of ld when `--gc-sections` and
`--gc-keep-exported` are both given on the linker command line.  This
updates the ld documentation to suit.

	* ld.texi (--gc-sections): Update.
2018-10-26 09:01:36 +10:30
H.J. Lu 0a640d7196 ELF: Hide symbols defined in discarded input sections
When assigning symbol version, we should hide debug symbols defined in
discarded sections from IR objects so that they can be removed later.

bfd/

	PR ld/23818
	* elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols
	defined in discarded input sections.

ld/

	PR ld/23818
	* testsuite/ld-plugin/lto.exp: Run PR ld/23818 test.
	* testsuite/ld-plugin/pr23818.d: New file.
	* testsuite/ld-plugin/pr23818.t: Likewise.
	* testsuite/ld-plugin/pr23818a.c: Likewise.
	* testsuite/ld-plugin/pr23818b.c: Likewise.
2018-10-24 18:08:24 -07:00
Alan Modra 8e3152af14 alpha testsuite fixes
Fixes a couple of ERROR results due to .set difference on alpha.

	* testsuite/ld-elf/shared.exp: Don't build pr19073 test on alpha.
	* testsuite/ld-elf/pr18720b.c: Don't use .set on alpha.
2018-10-23 21:09:09 +10:30
Alan Modra 91ae256e33 Relax a -r --gc-sections requirement
A symbol root is not needed if --gc-keep-exported is also given.

	* ldlang.c (lang_end): Don't error if no --entry or --undefined
	is given with -r -gc-sections if --gc-keep-exported.
2018-10-20 19:46:43 +10:30
Jim Wilson 640be958cd RISC-V: Adjust __global_pointer$ value to reduce code size.
ld/
	* emulparams/elf32lriscv-defs.sh (DATA_START_SYMBOLS): New.
	(SDATA_START_SYMBOLS): Define __SDATA_BEGIN__.  Don't define
	__global_pointer$.
	(OTHER_END_SYMBOLS): New.  Define __global_pointer$.
	* testsuite/ld-riscv-elf/pcrel-lo-addend-2.d (#ld): Add --no-relax.
2018-10-15 16:00:28 -07:00
Alan Modra bf2dd8d7cf BFD_INIT_MAGIC
This patch performs a run-time test that a shared libbfd.so has been
compiled with the same size bfd_vma as that of apps using the library.
On a 32-bit host it is easily possible to have one libbfd.so compiled
to support 64-bit targets (or configured with --enable-64-bit-bfd)
while another only supports 32-bit targets.  The two libraries will
have differently sized bfd_vma types, and if the wrong one is loaded
all sorts of weird behaviour might be seen.

bfd/
	PR 23534
	* init.c (BFD_INIT_MAGIC): Define.
	(bfd_init): Return BFD_INIT_MAGIC.
	bfd-in2.h: Regenerate.
binutils/
	PR 23534
	* addr2line.c (main): Exit with fatal error if bfd_init
	returns an unexpected value.
	* ar.c (main): Likewise.
	* dlltool.c (identify_dll_for_implib): Likewise.
	* nm.c (main): Likewise.
	* objcopy.c (main): Likewise.
	* objdump.c (main): Likewise.
	* size.c (main): Likewise.
	* strings.c (main): Likewise.
	* windmc.c (main): Likewise.
	* windres.c (main): Likewise.
gas/
	PR 23534
	* as.c (main): Exit with fatal error if bfd_init returns an
	unexpected value.
ld/
	PR 23534
	* ldmain.c (main): Exit with fatal error if bfd_init returns
	an unexpected value.
2018-10-15 22:11:58 +10:30
Alan Modra 2bf2bf23da ELF ld -r scripts
"ld -r" generally should not combine object file sections with
different names.  For example, "ld -r" should not combine ".text",
".text.hot" and ".text.cold" into an output ".text" section.  An
exception needs to be made for linker created sections, for example,
branch trampoline sections that might be created even for ld -r.

"ld -r" also should not define symbols in linker scripts.  Any
definitions are likely to conflict with those defined at final link.

A MEMORY spec is also not needed for ld -r.

	* Makefile.am (eelf32btsmip_fbsd.c, eelf32btsmipn32_fbsd.c),
	(eelf32epiphany.c, eelf32epiphany_4x4.c, eelf32ltsmip_fbsd.c),
	(eelf32ltsmipn32_fbsd.c, eelf32xc16x.c, eelf32xc16xl.c),
	(eelf32xc16xs.c, emcorepe.c, enios2elf.c, enios2linux.c),
	(eelf64btsmip_fbsd.c, eelf64ltsmip_fbsd.c): Correct dependencies.
	* Makefile.in: Regenerate.
	* emulparams/aarch64cloudabi.sh, * emulparams/aarch64fbsd.sh,
	* emulparams/aarch64linux.sh, * emulparams/aarch64linux32.sh,
	* emulparams/arc-nps.sh, * emulparams/elf32_spu.sh,
	* emulparams/elf32_tic6x_le.sh, * emulparams/elf32bmip.sh,
	* emulparams/elf32btsmipn32.sh, * emulparams/elf32lr5900n32.sh,
	* emulparams/elf32mep.sh, * emulparams/elf32metag.sh,
	* emulparams/elf64btsmip.sh, * emulparams/shelf_vxworks.sh,
	* emulparams/shlelf_fd.sh, * scripttempl/DWARF.sc,
	* scripttempl/alpha.sc, * scripttempl/alphavms.sc,
	* scripttempl/arclinux.sc, * scripttempl/armbpabi.sc,
	* scripttempl/avr.sc, * scripttempl/dlx.sc, * scripttempl/elf.sc,
	* scripttempl/elf32cr16.sc, * scripttempl/elf32cr16c.sc,
	* scripttempl/elf32crx.sc, * scripttempl/elf32msp430.sc,
	* scripttempl/elf32msp430_3.sc, * scripttempl/elf32xc16x.sc,
	* scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc,
	* scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc,
	* scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc,
	* scripttempl/elfd10v.sc, * scripttempl/elfd30v.sc,
	* scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc,
	* scripttempl/elfm9s12z.sc, * scripttempl/elfmicroblaze.sc,
	* scripttempl/elfxgate.sc, * scripttempl/elfxtensa.sc,
	* scripttempl/epiphany_4x4.sc, * scripttempl/ft32.sc,
	* scripttempl/hppaelf.sc, * scripttempl/ia64vms.sc,
	* scripttempl/ip2k.sc, * scripttempl/iq2000.sc,
	* scripttempl/mep.sc, * scripttempl/mmo.sc,
	* scripttempl/nds32elf.sc, * scripttempl/pru.sc,
	* scripttempl/sh.sc, * scripttempl/v850.sc,
	* scripttempl/v850_rh850.sc, * scripttempl/visium.sc,
	* scripttempl/xstormy16.sc: Condition various parts of scripts on
	${RELOCATABLE} in order to prevent ld -r merging sections or
	defining symbols.  Remove MEMORY and VERSION definitions from
	ld -r scripts too.
	* testsuite/ld-elf/group2.d, * testsuite/ld-elf/group4.d,
	* testsuite/ld-elf/group5.d, * testsuite/ld-elf/group6.d,
	* testsuite/ld-elf/group7.d, * testsuite/ld-elf/group8a.d,
	* testsuite/ld-elf/group8b.d, * testsuite/ld-elf/group9a.d,
	* testsuite/ld-elf/group9b.d, * testsuite/ld-elf/pr17550a.d,
	* testsuite/ld-elf/pr17550b.d,
	* testsuite/ld-elf/pr17550d.d: Don't xfail cr16 and crx.
	* testsuite/ld-elf/init-fini-arrays.d,
	* testsuite/ld-elf/pr22677.d: Likewise, and dont' xfail mep.
2018-10-13 20:33:23 +10:30
H.J. Lu 80f3ac5d61 x86: Don't add GNU_PROPERTY_X86_FEATURE_2_NEEDED for -z separate-code
With

commit 64029e9368
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Oct 5 11:40:54 2018 +0930

    Separate header PT_LOAD for -z separate-code

there is no need to add a GNU_PROPERTY_X86_ISA_1_USED note to force
program header in in non-code PT_LOAD segment when -z separate-code
is used.

bfd/

	PR ld/23428
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't
	add GNU_PROPERTY_X86_FEATURE_2_NEEDED to force program header
	in non-code PT_LOAD segment.

ld/

	PR ld/23428
	* testsuite/ld-i386/property-x86-4a.d: Updated.
	* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
2018-10-08 05:14:13 -07:00
H.J. Lu f3e660db14 ELF: Properly group and place orphan note sections
Properly group orphan note sections.  When placing orphan note section
as the first note section, place it after the section before all note
sections.

	PR ld/23658
	* ldlang.c (lang_insert_orphan): Properly group and place orphan
	note sections.  Properly handle orphan note section before all
	note sections.
	* testsuite/ld-elf/pr23658-1.d: Renamed to ...
	* testsuite/ld-elf/pr23658-1a.d: This.  Updated.
	* testsuite/ld-elf/pr23658-1b.d: New test.
	* testsuite/ld-elf/pr23658-1c.d: Likewise.
2018-10-08 04:39:21 -07:00
Alan Modra 64029e9368 Separate header PT_LOAD for -z separate-code
This patch, along with previous patches in the series, supports
putting the ELF file header and program headers in a PT_LOAD without
sections.

Logic governing whether headers a loaded has changed a little:  The
primary reason to include headers is now the presence of
SIZEOF_HEADERS in a linker script.  However, to support scripts that
may have reserved space for headers by hand, we continue to add
headers whenever the first section address is past the end of headers
modulo page size.

include/
	* bfdlink.h (struct bfd_link_info): Add load_phdrs field.
bfd/
	* elf-nacl.c (nacl_modify_segment_map): Cope with header PT_LOAD
	lacking sections.
	* elf.c (_bfd_elf_map_sections_to_segments): Assume file and
	program headers are required when info->load_phdrs.  Reorganize
	code handling program headers.  Generate a mapping without
	sections just for file and program headers when -z separate-code
	would indicate they should be on a different page to the first
	section.
ld/
	* ldexp.c (fold_name <SIZEOF_HEADERS>): Set link_info.load_phdrs.
	* testsuite/ld-elf/loadaddr1.d: Pass -z noseparate-code.
	* testsuite/ld-elf/loadaddr2.d: Likewise.
	* testsuite/ld-i386/vxworks2.sd: Adjust expected output.
	* testsuite/ld-powerpc/vxworks2.sd: Likewise.
	* testsuite/ld-elf/overlay.d: Remove spu xfail.
	* testsuite/ld-spu/ovl.lnk: Don't use SIZEOF_HEADERS.
	* testsuite/ld-tic6x/dsbt-be.ld: Likewise.
	* testsuite/ld-tic6x/dsbt-inrange.ld: Likewise.
	* testsuite/ld-tic6x/dsbt-overflow.ld: Likewise.
	* testsuite/ld-tic6x/dsbt.ld: Likewise.
2018-10-08 20:26:08 +10:30
Alan Modra 7358942661 ld insert_os_after ignoring first assignment
Some time ago the pr19593 test was xfailed for alpha.  This turned out
to be the wrong course of action since the test exposed a bug in
orphan section placement.  On alpha, orphan sections were being
inserted before ". = SIZEOF_HEADERS" due to the test having two
assignments, and on alpha, an output section statement from
-Ttext-segment being passed to ld.

	* ldlang.c (insert_os_after): Clear ignore_first on assignment to
	dot, not any assignment.  Clear ignore_first on output section
	statement contents too.
	* testsuite/ld-elf/pr19539.d: Remove alpha xfail.
2018-10-08 20:26:08 +10:30
Alan Modra 1b9e270b09 No PT_INTERP when .interp is zero size
Some targets don't set a default interpreter, resulting in an empty
.interp section unless --dynamic-linker is passed to ld.  A PT_INTERP
without a path is rather useless.

The testsuite change fixes a failure on microblaze-linux.

bfd/
	* elf.c (get_program_header_size): Don't count PT_INTERP if
	.interp is empty.
	(_bfd_elf_map_sections_to_segments): Don't create PT_INTERP if
	.interp is empty.
ld/
	* testsuite/ld-elf/pr22423.d: Pass --dynamic-linker to ld.
2018-10-08 20:26:08 +10:30
Stafford Horne c8e98e3692 or1k: Add the l.adrp insn and supporting relocations
This patch adds the new instruction and relocation as per proposal:
   https://openrisc.io/proposals/ladrp

This is to be added to the spec in an upcoming revision.  The new instruction
l.adrp loads the page offset of the current instruction offset by
a 21-bit immediate shifted left 13-bits.  This is meant to be used with
a 13-bit lower bit page offset.  This allows us to free up the got
register r16.

  l.adrp  r3, foo
  l.ori   r4, r3, po(foo)
  l.lbz   r5, po(foo)(r3)
  l.sb    po(foo)(r3), r6

The relocations we add are:

 - BFD_RELOC_OR1K_PLTA26	For PLT jump relocation with PLT entry
   asm: plta()			implemented using l.ardp, meaning
				no need for r16 (the GOT reg)

 - BFD_RELOC_OR1K_GOT_PG21	Upper 21-bit Page offset got address
   asm: got()
 - BFD_RELOC_OR1K_TLS_GD_PG21	Upper 21-bit Page offset with TLS General
   asm: tlsgd()			Dynamic calculation
 - BFD_RELOC_OR1K_TLS_LDM_PG21	Upper 21-bit Page offset with TLS local
   asm: tlsldm()		dynamic calculation
 - BFD_RELOC_OR1K_TLS_IE_PG21	Upper 21-bit Page offset with TLS Initial
   asm: gottp() 		Executable calculation
 - BFD_RELOC_OR1K_PCREL_PG21	Default relocation for disp21 (l.adrp
				instructions)

 - BFD_RELOC_OR1K_LO13		low 13-bit page offset relocation
   asm: po()			i.e. mem loads, addi etc
 - BFD_RELOC_OR1K_SLO13		low 13-bit page offset relocation
   asm: po()			i.e. mem stores, with split immediate
 - BFD_RELOC_OR1K_GOT_LO13,	low 13-bit page offset with GOT calcs
   asm: gotpo()
 - BFD_RELOC_OR1K_TLS_GD_LO13	Lower 13-bit offset with TLS GD calcs
   asm: tlsgdpo()
 - BFD_RELOC_OR1K_TLS_LDM_LO13	Lower 13-bit offset with TLS LD calcs
   asm: tlsldmpo()
 - BFD_RELOC_OR1K_TLS_IE_LO13	Lower 13-bit offset with TLS IE calcs
   asm: gottppo()

bfd/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* bfd-in2.h: Regenerated.
	* elf32-or1k.c: (or1k_elf_howto_table): Fix formatting for
	R_OR1K_PLT26, Add R_OR1K_PCREL_PG21, R_OR1K_GOT_PG21,
	R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21, R_OR1K_TLS_IE_PG21,
	R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13, R_OR1K_TLS_LDM_LO13,
	R_OR1K_TLS_IE_LO13, R_OR1K_SLO13, R_OR1K_PLTA26.
	(or1k_reloc_map): Add BFD_RELOC_OR1K_PCREL_PG21,
	BFD_RELOC_OR1K_GOT_PG21, BFD_RELOC_OR1K_TLS_GD_PG21,
	BFD_RELOC_OR1K_TLS_LDM_PG21, BFD_RELOC_OR1K_TLS_IE_PG21,
	BFD_RELOC_OR1K_LO13, BFD_RELOC_OR1K_GOT_LO13,
	BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_GD_LO13,
	BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_LO13,
	BFD_RELOC_OR1K_SLO13, BFD_RELOC_OR1K_PLTA26.
	(elf_or1k_link_hash_table): Add field saw_plta.
	(or1k_final_link_relocate): Add value calculations for new relocations.
	(or1k_elf_relocate_section): Add section relocations for new
	relocations.
	(or1k_write_plt_entry): New function.
	(or1k_elf_finish_dynamic_sections): Add support for PLTA relocations
	using new l.adrp instruction.  Cleanup PLT relocation code generation.
	* libbfd.h: Regenerated.
	* reloc.c: Add BFD_RELOC_OR1K_PCREL_PG21, BFD_RELOC_OR1K_LO13,
	BFD_RELOC_OR1K_SLO13, BFD_RELOC_OR1K_GOT_PG21, BFD_RELOC_OR1K_GOT_LO13,
	BFD_RELOC_OR1K_PLTA26, BFD_RELOC_OR1K_TLS_GD_PG21,
	BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_PG21,
	BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_PG21,
	BFD_RELOC_OR1K_TLS_IE_LO13.

cpu/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* or1k.opc (parse_disp26): Add support for plta() relocations.
	(parse_disp21): New function.
	(or1k_rclass): New enum.
	(or1k_rtype): New enum.
	(or1k_imm16_relocs): Define new PO and SPO relocation mappings.
	(parse_reloc): Add new po(), gotpo() and gottppo() for LO13 relocations.
	(parse_imm16): Add support for the new 21bit and 13bit relocations.
	* or1korbis.cpu (f-disp26): Don't assume SI.
	(f-disp21): New pc-relative 21-bit 13 shifted to right.
	(insn-opcode): Add ADRP.
	(l-adrp): New instruction.

gas/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* config/tc-or1k.c (or1k_apply_fix): Add BFD_RELOC_OR1K_TLS_GD_PG21,
	BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_PG21,
	BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_PG21,
	BFD_RELOC_OR1K_TLS_IE_LO13.
	* testsuite/gas/or1k/allinsn.s: Add test for l.adrp.
	* testsuite/gas/or1k/allinsn.d: Add test results for new
	instructions.
	* testsuite/gas/or1k/reloc-1.s: Add tests to generate
	R_OR1K_PLTA26, R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21,
	R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13,
	R_OR1K_TLD_LDM_LO13, R_OR1K_TLS_IE_LO13, R_OR1K_LO13, R_OR1K_SLO13
	relocations.
	* testsuite/gas/or1k/reloc-1.d: Add relocation results for
	tests.
	* testsuite/gas/or1k/reloc-2.s: Add negative tests for store to
	gotpo().
	* testsuite/gas/or1k/reloc-2.l: Add expected error test results.

ld/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* testsuite/ld-or1k/or1k.exp: Add test cases for plt generation.
	* testsuite/ld-or1k/plt1.dd: New file.
	* testsuite/ld-or1k/plt1.s: New file.
	* testsuite/ld-or1k/plt1.x.dd: New file.
	* testsuite/ld-or1k/plta1.dd: New file.
	* testsuite/ld-or1k/plta1.s: New file.
	* testsuite/ld-or1k/pltlib.s: New file.

include/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* elf/or1k.h (elf_or1k_reloc_type): Add R_OR1K_PCREL_PG21,
	R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21,
	R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13,
	R_OR1K_TLS_GD_LO13, R_OR1K_TLS_LDM_LO13, R_OR1K_TLS_IE_LO13,
	R_OR1K_SLO13, R_OR1K_PLTA26.

opcodes/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* or1k-asm.c: Regenerated.
	* or1k-desc.c: Regenerated.
	* or1k-desc.h: Regenerated.
	* or1k-dis.c: Regenerated.
	* or1k-ibld.c: Regenerated.
	* or1k-opc.c: Regenerated.
	* or1k-opc.h: Regenerated.
	* or1k-opinst.c: Regenerated.
2018-10-05 11:41:41 +09:00
Richard Henderson 1c4f3780f7 or1k: Add relocations for high-signed and low-stores
This patch adds the following target relocations:

 - BFD_RELOC_HI16_S		High 16-bit relocation, for used with signed
   asm: ha()			lower.
 - BFD_RELOC_HI16_S_GOTOFF	High 16-bit GOT offset relocation for local
   asm: gotoffha()		symbols, for use with signed lower.
 - BFD_RELOC_OR1K_TLS_IE_AHI16	High 16-bit TLS relocation with initial
   asm: gottpoffha()		executable calculation, for use with signed
				lower.
 - BFD_RELOC_OR1K_TLS_LE_AHI16	High 16-bit TLS relocation for local executable
   asm: tpoffha()		variables, for use with signed lower.

 - BFD_RELOC_OR1K_SLO16		Split lower 16-bit relocation, used with
   asm: lo()			OpenRISC store instructions.
 - BFD_RELOC_OR1K_GOTOFF_SLO16	Split lower 16-bit GOT offset relocation for
   asm: gotofflo()		local symbols, used with OpenRISC store
				instructions.
 - BFD_RELOC_OR1K_TLS_LE_SLO16	Split lower 16-bit relocation for TLS local
   asm: tpofflo()		executable variables, used with OpenRISC store
				instructions.

bfd/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>
	    Stafford Horne  <shorne@gmail.com>

	* bfd-in2.h: Regenerated.
	* elf32-or1k.c (N_ONES): New macro.
	(or1k_elf_howto_table): Fix R_OR1K_PLT26 to complain on overflow.
	Add definitions for R_OR1K_TLS_TPOFF, R_OR1K_TLS_DTPOFF,
	R_OR1K_TLS_DTPMOD, R_OR1K_AHI16, R_OR1K_GOTOFF_AHI16,
	R_OR1K_TLS_IE_AHI16, R_OR1K_TLS_LE_AHI16, R_OR1K_SLO16,
	R_OR1K_GOTOFF_SLO16, R_OR1K_TLS_LE_SLO16.
	(or1k_reloc_map): Add entries for BFD_RELOC_HI16_S,
	BFD_RELOC_LO16_GOTOFF, BFD_RELOC_HI16_GOTOFF, BFD_RELOC_HI16_S_GOTOFF,
	BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_LE_AHI16,
	BFD_RELOC_OR1K_SLO16, BFD_RELOC_OR1K_GOTOFF_SLO16,
	BFD_RELOC_OR1K_TLS_LE_SLO16.
	(or1k_reloc_type_lookup): Change search loop to start ad index 0 and
	also check results before returning.
	(or1k_reloc_name_lookup): Simplify loop to use R_OR1K_max as index
	limit.
	(or1k_final_link_relocate): New function.
	(or1k_elf_relocate_section): Add support for new AHI and SLO
	relocations.  Use or1k_final_link_relocate instead of generic
	_bfd_final_link_relocate.
	(or1k_elf_check_relocs): Add support for new AHI and SLO relocations.
	* reloc.c: Add new enums for BFD_RELOC_OR1K_SLO16,
	BFD_RELOC_OR1K_GOTOFF_SLO16, BFD_RELOC_OR1K_TLS_IE_AHI16,
	BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_LE_AHI16,
	BFD_RELOC_OR1K_TLS_LE_SLO16.  Remove unused BFD_RELOC_OR1K_GOTOFF_HI16
	and BFD_RELOC_OR1K_GOTOFF_LO16.
	* libbfd.h: Regenerated.

cpu/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* or1k.opc: Add RTYPE_ enum.
	(INVALID_STORE_RELOC): New string.
	(or1k_imm16_relocs): New array array.
	(parse_reloc): New static function that just does the parsing.
	(parse_imm16): New static function for generic parsing.
	(parse_simm16): Change to just call parse_imm16.
	(parse_simm16_split): New function.
	(parse_uimm16): Change to call parse_imm16.
	(parse_uimm16_split): New function.
	* or1korbis.cpu (simm16-split): Change to use new simm16_split.
	(uimm16-split): Change to use new uimm16_split.

gas/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* testsuite/gas/or1k/allinsn.d (l_ha): Add result for ha() relocation.
	* testsuite/gas/or1k/allinsn.s (l_ha): Add test for ha() relocations.
	* testsuite/gas/or1k/allinsn.exp: Renamed to or1k.exp.
	* testsuite/gas/or1k/or1k.exp: Add reloc-2 list test.
	* testsuite/gas/or1k/reloc-1.d: New file.
	* testsuite/gas/or1k/reloc-1.s: New file.
	* testsuite/gas/or1k/reloc-2.l: New file.
	* testsuite/gas/or1k/reloc-2.s: New file.

include/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* elf/or1k.h (elf_or1k_reloc_type): Add R_OR1K_AHI16,
	R_OR1K_GOTOFF_AHI16, R_OR1K_TLS_IE_AHI16, R_OR1K_TLS_LE_AHI16,
	R_OR1K_SLO16, R_OR1K_GOTOFF_SLO16, R_OR1K_TLS_LE_SLO16.

ld/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* testsuite/ld-or1k/offsets1.d: New file.
	* testsuite/ld-or1k/offsets1.s: New file.
	* testsuite/ld-or1k/or1k.exp: New file.

opcodes/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>

	* or1k-asm.c: Regenerate.
2018-10-05 11:41:40 +09:00
H.J. Lu b35334aa98 pr23658-1.d: Also xfail ft32-* and xgate-*
Since ft32-* and xgate-* use generic linker, SHT_NOTE sections aren't
grouped nor sorted.

	PR ld/23658
	* testsuite/ld-elf/pr23658-1.d: Also xfail ft32-* and xgate-*.
2018-10-04 12:06:33 -07:00
H.J. Lu fb9bbfd7f2 ELF: Add testcases for PR ld/23658
Add testcases to verify that all SHT_NOTE sections with the same section
alignment are placed in a single PT_NOTE segment.

	PR ld/23658
	* testsuite/ld-elf/pr23658-1.d: New file.
	* testsuite/ld-elf/pr23658-1a.s: Likewise.
	* testsuite/ld-elf/pr23658-1b.s: Likewise.
	* testsuite/ld-elf/pr23658-1c.s: Likewise.
	* testsuite/ld-elf/pr23658-1d.s: Likewise.
	* testsuite/ld-elf/pr23658-2.rd: Likewise.
	* testsuite/ld-elf/pr23658-3.d: Likewise.
	* testsuite/ld-elf/pr23658-3.s: Likewise.
	* testsuite/ld-elf/pr23658-3.t: Likewise.
	* testsuite/ld-elf/shared.exp: Run PR ld/23658 tests.
2018-10-03 14:11:53 -07:00
H.J. Lu 1887ae7304 ELF: Group and sort output note sections by section alignments
To support putting all adjacent SHT_NOTE sections with the same section
alignment into a single PT_NOTE segment, lang_insert_orphan must group
and sort output note sections by section alignments in both output
section list as well as output section statement list.

	PR ld/23658
	* ldlang.c (lang_insert_orphan): Group and sort output note
	sections by section alignments.
2018-10-03 13:25:30 -07:00
Eric Botcazou e95bc8bb1d Couple of minor tweaks to the linker testsuite.
This gets rid of the couple of linker failures for visium-elf:

FAIL: ld-elf/pr14156b
FAIL: ld-elf/pr22677

by tweaking the respective testcases.  The first tweak is the same as the
one made to the sibling testcase ld-elf/pr14156a.d about one year ago and
the  second tweak adds the usual main/start/_start/__start symbols.

ld/
	* testsuite/ld-elf/pr14156b.d: Adjust for extra symbols.
	* testsuite/ld-elf/pr22677.s: Define main/start/_start/__start.
2018-09-25 08:15:36 +02:00
Jim Wilson 551703cfd4 RISC-V: Allow pcrel_lo addends, error on addend overflow.
bfd/
	* elfnn-riscv.c (riscv_resolve_pcrel_lo_relocs): Add check for reloc
	overflow with addend.  Use reloc_dangerous instead of reloc_overflow.
	Add strings for the two errors handled here.
	(riscv_elf_relocate_section) In case R_RISCV_PCREL_LO12_I, rewrite
	comment.  Only give error with addend when used with section symbol.
	In case bfd_reloc_dangerous, update error string.

	ld/
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run pcrel-lo-addend-2.
	* testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend-2.d: New.
	* testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend-2.s: New.
	* testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend.d: Update name
	and error string.
2018-09-24 14:05:32 -07:00
Alan Modra be9a9af906 Fix more fallout from 17f6ade235
gas/
	* testsuite/gas/avr/large-debug-line-table.d: Update.
ld/
	* testsuite/ld-avr/gc-section-debugline.d: Update.
2018-09-21 09:55:38 +09:30
H.J. Lu 3def145413 ld: Add the entry symbol, _main, for LynxOS targets
Add the entry symbol, _main, to fix:

FAIL: ld-elf/64ksec
FAIL: ld-elf/comm-data4
FAIL: ld-elf/comm-data5
FAIL: ld-elf/eh5
FAIL: ld-elf/empty
FAIL: ld-elf/empty2
FAIL: ld-elf/endsym
FAIL: ld-elf/exclude3a
FAIL: ld-elf/linkonce2
FAIL: ld-elf/orphan3
FAIL: ld-elf/pr12851
FAIL: ld-elf/pr14156a
FAIL: ld-elf/pr14156b
FAIL: ld-elf/pr14926
FAIL: ld-elf/pr20513a
FAIL: ld-elf/pr20513b
FAIL: ld-elf/stab
FAIL: ld-elf/var1
FAIL: ld-elf/warn3
FAIL: section size overflow

for i386-lynxos target.

	* testsuite/ld-checks/over2.s: Add "_main" for LynxOS targets.
	* testsuite/ld-elf/comm-data4.s: Likewise.
	* testsuite/ld-elf/comm-data5.s: Likewise.
	* testsuite/ld-elf/eh5b.s: Likewise.
	* testsuite/ld-elf/empty.s: Likewise.
	* testsuite/ld-elf/empty2.s: Likewise.
	* testsuite/ld-elf/exclude3.s: Likewise.
	* testsuite/ld-elf/fini0.s: Likewise.
	* testsuite/ld-elf/init0.s: Likewise.
	* testsuite/ld-elf/linkonce1b.s: Likewise.
	* testsuite/ld-elf/orphan3a.s: Likewise.
	* testsuite/ld-elf/pr14926.s: Likewise.
	* testsuite/ld-elf/pr20513a.s: Likewise.
	* testsuite/ld-elf/sec64k.exp: Likewise.
	* testsuite/ld-elf/start.s: Likewise.
	* testsuite/ld-elf/var1.s: Likewise.
2018-09-20 12:31:20 -07:00
Jim Wilson dbfcd05365 RISC-V: Fix library search path for rv32.
2018-09-19  Kito Cheng  <kito@andestech.com>
ld/
	* emulparams/elf32lriscv.sh: Correct the library search path.
	* emulparams/elf32lriscv_ilp32.sh: Likewise.
	* emulparams/elf32lriscv_ilp32f.sh: Likewise.
2018-09-20 12:06:28 -07:00
Nick Clifton fbaf61ad52 Andes Technology has good news for you, we plan to update the nds32 port of binutils on upstream!
We have not only removed all unsupported and obsolete code, but also supported lost of new features,
including better link-time relaxations and TLS implementations. Besides, the files generated by the
newly assembler and linker usually get higher performance and more optimized code size.

ld	* emultempl/nds32elf.em (hyper_relax): New variable.
	(nds32_elf_create_output_section_statements):
	the parameters of bfd_elf32_nds32_set_target_option
	(PARSE_AND_LIST_PROLOGUE, PARSE_AND_LIST_OPTIONS,
	PARSE_AND_LIST_ARGS_CASES): Add new option --mhyper-relax.
	* emultempl/nds32elf.em (nds32_elf_after_open): Updated.
	* emultempl/nds32elf.em (tls_desc_trampoline): New variable.
	* (nds32_elf_create_output_section_statements): Updated.
	* (nds32_elf_after_parse): Disable relaxations when PIC is enable.
	* (PARSE_AND_LIST_PROLOGUE, PARSE_AND_LIST_OPTIONS,
	PARSE_AND_LIST_ARGS_CASES): Add new option --m[no-]tlsdesc-trampoline.

include	* elf/nds32.h: Remove the unused target features.
	* dis-asm.h (disassemble_init_nds32): Declared.
	* elf/nds32.h (E_NDS32_NULL): Removed.
	(E_NDS32_HAS_DSP_INST, E_NDS32_HAS_ZOL): New.
	* opcode/nds32.h: Ident.
	(N32_SUB6, INSN_LW): New macros.
	(enum n32_opcodes): Updated.
	* elf/nds32.h: Doc fixes.
	* elf/nds32.h: Add R_NDS32_LSI.
	* elf/nds32.h: Add new relocations for TLS.

gas 	* config/tc-nds32.c: Remove the unused target features.
	(nds32_relax_relocs, md_pseudo_table, nds32_elf_record_fixup_exp,
	nds32_set_elf_flags_by_insn, nds32_insert_relax_entry,
	nds32_apply_fix): Likewise.
	(nds32_no_ex9_begin): Removed.
	* config/tc-nds32.c (add_mapping_symbol_for_align,
	make_mapping_symbol, add_mapping_symbol): New functions.
	* config/tc-nds32.h (enum mstate): New.
	(nds32_segment_info_type): Likewise.
	* configure.ac (--enable-dsp-ext, --enable-zol-ext): New options.
	* config.in: Regenerated.
	* configure: Regenerated.
	* config/tc-nds32.c (nds32_dx_regs):
	Set the value according to the configuration.
	(nds32_perf_ext, nds32_perf_ext2, nds32_string_ext, nds32_audio_ext):
	Likewise.
	(nds32_dsp_ext): New variable. Set the value according to the
	configuration.
	(nds32_zol_ext): Likewise.
	(asm_desc, nds32_pseudo_opcode_table): Make them static.
	(nds32_set_elf_flags_by_insn): Updated.
	(nds32_check_insn_available): Updated.
	(nds32_str_tolower): New function.
	* config/tc-nds32.c (relax_table): Updated.
	(md_begin): Updated.
	(md_assemble): Use XNEW macro to allocate space for `insn.info',
	and then remember to free it.
	(md_section_align): Cast (-1) to ValueT.
	(nds32_get_align): Cast (~0U) to addressT.
	(nds32_relax_branch_instructions): Updated.
	(md_convert_frag): Add new local variable `final_r_type'.
	(invalid_prev_frag): Add new bfd_boolean parameter `relax'.
	All callers changed.
	* config/tc-nds32.c (struct nds32_relocs_pattern): Add `insn' field.
	(struct nds32_hint_map): Add `option_list' field.
	(struct suffix_name, suffix_table): Remove the unused `pic' field.
	(do_pseudo_b, do_pseudo_bal): Remove the suffix checking.
	(do_pseudo_la_internal, do_pseudo_pushpopm): Indent.
	(relax_hint_bias, relax_hint_id_current): New static variables.
	(reset_bias, relax_hint_begin): New variables.
	(nds_itoa): New function.
	(CLEAN_REG, GET_OPCODE): New macros.
	(struct relax_hint_id): New.
	(nds32_relax_hint): For .relax_hint directive, we can use `begin'
	and `end' to mark the relax pattern without giving exactly id number.
	(nds32_elf_append_relax_relocs): Handle the case that the .relax_hint
	directives are attached to pseudo instruction.
	(nds32_elf_save_pseudo_pattern): Change the second parameter from
	instruction's opcode to byte code.
	(nds32_elf_build_relax_relation): Add new bfd_boolean parameter
	`pseudo_hint'.
	(nds32_lookup_pseudo_opcode): Fix the overflow issue.
	(enum nds32_insn_type): Add N32_RELAX_ALU1 and N32_RELAX_16BIT.
	(nds32_elf_record_fixup_exp, relax_ls_table, hint_map,
	nds32_find_reloc_table, nds32_match_hint_insn, nds32_parse_name):
	Updated.
	* config/tc-nds32.h (MAX_RELAX_NUM): Extend it to 6.
	(enum nds32_relax_hint_type): Merge NDS32_RELAX_HINT_LA and
	NDS32_RELAX_HINT_LS into NDS32_RELAX_HINT_LALS. Add
	NDS32_RELAX_HINT_LA_PLT, NDS32_RELAX_HINT_LA_GOT and
	NDS32_RELAX_HINT_LA_GOTOFF.
	* config/tc-nds32.h (relax_ls_table): Add floating load/store
	to gp relax pattern.
	(hint_map, nds32_find_reloc_table): Likewise.
	* configure.ac: Define NDS32_LINUX_TOOLCHAIN.
	* configure: Regenerated.
	* config.in: Regenerated.
	* config/tc-nds32.h (enum nds32_ramp): Updated.
	(enum nds32_relax_hint_type): Likewise.
	* config/tc-nds32.c: Include "errno.h" and "limits.h".
	(relax_ls_table): Add TLS relax patterns.
	(nds32_elf_append_relax_relocs): Attach BFD_RELOC_NDS32_GROUP on
	each instructions of TLS patterns.
	(nds32_elf_record_fixup_exp): Updated.
	(nds32_apply_fix): Likewise.
	(suffix_table): Add TLSDESC suffix.

binutils* testsuite/binutils-all/objcopy.exp: Set the unsupported reloc number
	from 215 to 255 for NDS32.

bfd	* elf32-nds32.c (nds32_elf_relax_loadstore):
	Remove the unused target features.
	(bfd_elf32_nds32_set_target_option): Remove the unused parameters.
	(nds32_elf_relax_piclo12, nds32_elf_relax_letlslo12,
	nds32_elf_relax_letlsadd, nds32_elf_relax_letlsls,
	nds32_elf_relax_pltgot_suff, nds32_elf_relax_got_suff
	nds32_elf_relax_gotoff_suff, calculate_plt_memory_address,
	calculate_plt_offset, calculate_got_memory_address,
	nds32_elf_check_dup_relocs): Removed.
	All callers changed.
	* elf32-nds32.h: Remove the unused macros and defines.
	(elf_nds32_link_hash_table): Remove the unused variable.
	(bfd_elf32_nds32_set_target_option): Update prototype.
	(nds32_elf_ex9_init): Removed.
	* elf32-nds32.c (nds32_convert_32_to_16): Updated.
	* elf32-nds32.c (HOWTO2, HOWTO3): Define new HOWTO macros
	to initialize array nds32_elf_howto_table in any order
	without lots of EMPTY_HOWTO.
	(nds32_reloc_map): Updated.
	* reloc.c: Add BFD_RELOC_NDS32_LSI.
	* bfd-in2.h: Regenerated.
	* bfd/libbfd.h: Regenerated.
	* elf32-nds32.c (nds32_elf_relax_howto_table): Add R_NDS32_LSI.
	(nds32_reloc_map): Likewise.
	(nds32_elf_relax_flsi): New function.
	(nds32_elf_relax_section): Support floating load/store relaxation.
	* elf32-nds32.c (NDS32_GUARD_SEC_P, elf32_nds32_local_gp_offset):
	New macro.
	(struct elf_nds32_link_hash_entry): New `offset_to_gp' field.
	(struct elf_nds32_obj_tdata): New `offset_to_gp' and `hdr_size' fields.
	(elf32_nds32_allocate_local_sym_info, nds32_elf_relax_guard,
	nds32_elf_is_target_special_symbol, nds32_elf_maybe_function_sym):
	New functions.
	(nds32_info_to_howto_rel): Add BFD_ASSERT.
	(bfd_elf32_bfd_reloc_type_table_lookup, nds32_elf_link_hash_newfunc,
	nds32_elf_link_hash_table_create, nds32_elf_relocate_section,
	nds32_elf_relax_loadstore, nds32_elf_relax_lo12, nds32_relax_adjust_label,
	bfd_elf32_nds32_set_target_option, nds32_fag_mark_relax): Updated.
	(nds32_elf_final_sda_base): Improve it to find the better gp value.
	(insert_nds32_elf_blank): Must consider `len' when inserting blanks.
	* elf32-nds32.h (bfd_elf32_nds32_set_target_option): Update prototype.
	(struct elf_nds32_link_hash_table): Add new variable `hyper_relax'.
	* elf32-nds32.c (elf32_nds32_allocate_dynrelocs): New function.
	(create_got_section): Likewise.
	(allocate_dynrelocs, nds32_elf_size_dynamic_sections,
	nds32_elf_relocate_section, nds32_elf_finish_dynamic_symbol): Updated.
	(nds32_elf_check_relocs): Fix the issue that the shared library may
	has TEXTREL entry in the dynamic section.
	(nds32_elf_create_dynamic_sections): Enable to call readonly_dynrelocs
	since the TEXTREL issue is fixed in the nds32_elf_check_relocs.
	(nds32_elf_finish_dynamic_sections): Update and add DT_RELASZ
	dynamic entry.
	(calculate_offset): Remove the unused parameter `pic_ext_target' and
	related codes.
	All callers changed.
	(elf_backend_dtrel_excludes_plt): Disable it temporarily since it
	will cause some errors for our test cases.
	* elf32-nds32.c (nds32_elf_merge_private_bfd_data): Allow to link the
	generic object.
	* reloc.c: Add TLS relocations.
	* libbfd.h: Regenerated.
	* bfd-in2.h: Regenerated.
	* elf32-nds32.h (struct section_id_list_t): New.
	(elf32_nds32_lookup_section_id, elf32_nds32_check_relax_group,
	elf32_nds32_unify_relax_group, nds32_elf_unify_tls_model):
	New prototypes.
	(elf32_nds32_compute_jump_table_size, elf32_nds32_local_tlsdesc_gotent):
	New macro.
	(nds32_insertion_sort, bfd_elf32_nds32_set_target_option,
	elf_nds32_link_hash_table): Updated.
	* elf32-nds32.c (enum elf_nds32_tls_type): New.
	(struct elf32_nds32_relax_group_t, struct relax_group_list_t): New.
	(elf32_nds32_add_dynreloc, patch_tls_desc_to_ie, get_tls_type,
	fls, ones32, list_insert, list_insert_sibling, dump_chain,
	elf32_nds32_check_relax_group, elf32_nds32_lookup_section_id,
	elf32_nds32_unify_relax_group, nds32_elf_unify_tls_model): New functions.
	(elf_nds32_obj_tdata): Add new fields.
	(elf32_nds32_relax_group_ptr, nds32_elf_local_tlsdesc_gotent): New macros.
	(nds32_elf_howto_table): Add TLS relocations.
	(nds32_reloc_map): Likewise.
	(nds32_elf_copy_indirect_symbol, nds32_elf_size_dynamic_sections,
	nds32_elf_finish_dynamic_symbol, elf32_nds32_allocate_local_sym_info,
	nds32_elf_relocate_section, bfd_elf32_nds32_set_target_option,
	nds32_elf_check_relocs, allocate_dynrelocs): Updated.
	(nds32_elf_relax_section): Call nds32_elf_unify_tls_model.
	(dtpoff_base): Rename it to `gottpof' and then update it.

opcodes	* nds32-asm.c (operand_fields): Remove the unused fields.
	(nds32_opcodes): Remove the unused instructions.
	* nds32-dis.c (nds32_ex9_info): Removed.
	(nds32_parse_opcode): Updated.
	(print_insn_nds32): Likewise.
	* nds32-asm.c (config.h, stdlib.h, string.h): New includes.
	(LEX_SET_FIELD, LEX_GET_FIELD): Update defines.
	(nds32_asm_init, build_operand_hash_table, build_keyword_hash_table,
	build_opcode_hash_table): New functions.
	(nds32_keyword_table, nds32_keyword_count_table, nds32_field_table,
	nds32_opcode_table): New.
	(hw_ktabs): Declare it to a pointer rather than an array.
	(build_hash_table): Removed.
	* nds32-asm.h (enum): Add SYN_INPUT, SYN_OUTPUT, SYN_LOPT,
	SYN_ROPT and upadte HW_GPR and HW_INT.
	* nds32-dis.c (keywords): Remove const.
	(match_field): New function.
	(nds32_parse_opcode): Updated.
	* disassemble.c (disassemble_init_for_target):
	Add disassemble_init_nds32.
	* nds32-dis.c (eum map_type): New.
	(nds32_private_data): Likewise.
	(get_mapping_symbol_type, is_mapping_symbol, nds32_symbol_is_valid,
	nds32_add_opcode_hash_table, disassemble_init_nds32): New functions.
	(print_insn_nds32): Updated.
	* nds32-asm.c (parse_aext_reg): Add new parameter.
	(parse_re, parse_re2, parse_aext_reg): Only reduced registers
	are allowed to use.
	All callers changed.
	* nds32-asm.c (keyword_usr, keyword_sr): Updated.
	(operand_fields): Add new fields.
	(nds32_opcodes): Add new instructions.
	(keyword_aridxi_mx): New keyword.
	* nds32-asm.h (enum): Add NASM_ATTR_DSP_ISAEXT, HW_AEXT_ARIDXI_MX
	and NASM_ATTR_ZOL.
	(ALU2_1, ALU2_2, ALU2_3): New macros.
	* nds32-dis.c (nds32_filter_unknown_insn): Updated.
2018-09-20 13:32:58 +01:00
Alan Modra 7e00df65a4 PR23648 testcase
PR 23648
	* testsuite/ld-elf/pr23648.d,
	* testsuite/ld-elf/pr23648.s,
	* testsuite/ld-elf/pr23648.t: New test.
2018-09-19 17:38:46 +09:30
Alan Modra 7f0cfc6eb8 PR23648, Symbols based on MEMORY regions confuse --gc-sections
Running lang_do_memory_regions earlier seems a reasonable solution to
gaining better values for symbols prior to lang_gc_sections.

	PR ld/23648
	* ldlang.c (lang_process): Move lang_do_memory_regions earlier.
	Comment on lang_do_assignments call.
	* ldgram.y (origin_exp): Don't assign region->current.
2018-09-19 15:08:48 +09:30
Alan Modra aa654ee8f8 Tweak map file output for pei386_auto_import
* ldmain.c (add_archive_element): Handle auto-inport symbols
	when printing map.
2018-09-19 15:08:48 +09:30
Alan Modra 0b1352e04c A few hppa testcase tidies
binutils/
	* testsuite/lib/binutils-common.exp (is_som_format): New proc.
	(run_dump_test): Correct target test for alternate .comm syntax.
	(get_standard_section_names): Handle som format.
	* testsuite/lib/utils-lib.exp (default_binutils_assemble_flags):
	Correct target test for alternate .comm syntax.
gas/
	* testsuite/gas/all/gas.exp (redef3): Don't xfail for hppa.
	(octa): Run for hppa.
	* testsuite/gas/elf/elf.exp (common1, common2): Likewise.
	* testsuite/gas/elf/symver.d: Delete notarget.
ld/
	* testsuite/ld-elf/comm-data5.d: Remove notarget for hppa.
	* testsuite/ld-scripts/defined6.d: Likewise.
2018-09-17 23:17:14 +09:30
Nick Clifton a0a8a9340d Ensure that binutils test names are unique.
binutils* testsuite/binutils-all/compress.exp: Rename second "objcopy
	zlib-gnu compress debug sections 3" test to "objcopy zlib-gabi
	compress debug sections 3" and use gabi object files instead
	of gnu object files.
	* testsuite/binutils-all/objcopy.exp: Add suffix to the names
	of the "ELF group" tests.
	* testsuite/binutils-all/readelf.exp (proc readelf_find_size):
	Add an iteration parameter and include it in the name of the
	test.  Update callers to include an iteration count.

gas	* testuite/gas/elf/group0a.d: Add extra details to the test
	name.
	* testuite/gas/elf/group0b.d: Likewise.
	* testuite/gas/elf/group1a.d: Likewise.
	* testuite/gas/elf/group1b.d: Likewise.
	* testuite/gas/elf/group0b.d: Likewise.
	* testuite/gas/elf/section9.d: Likewise.
	* testuite/gas/i386/ilp32/lns/lns-common-1.d: Likewise.
	* testuite/gas/i386/ilp32/lns/lns-duplicate-1.d: Likewise.

ld	* testuite/ld/ld-elf/audit.exp: Differentiate the names of the
	two "Run with shared with --audit" tests.
	* testuite/ld/ld-elf/compress.exp: Differentiate the zlib
	compressed debug output test names.
	* testuite/ld/ld-i386/tlspie1.d: Add extra details to the test
	name.
	* testuite/ld/ld-i386/tlspie2.d: Likewise.
	* testuite/ld/ld-size/size.exp: Add missing escapes to the end
	of lines in the size-3e test.
	* testuite/ld/ld-unique/unique.exp: Differentiate the names of
	the two "Checking unique PIC object" tests.
	* testuite/ld/ld-x86-64/tlspie1.d: Add extra details to the test
	name.
2018-09-17 10:10:47 +01:00
Alan Modra 8ffb70eb57 Consolidate run_dump_test
This merges the three versions of run_dump_test.  Improved warning
handling versus the old gas version shows up a number of tests that
need their disassembly updating:
arm-linuxeabi  +FAIL: ARM v1 instructions
arm-linuxeabi  +FAIL: Accepted v8-a with ARMv8.1 AdvSIMD.
arm-linuxeabi  +FAIL: bl local instructions for v4t.
arm-linuxeabi  +FAIL: UDF
and some that now fail due to detecting assembly warnings:
h8300-elf  +FAIL: binutils-all/strip-13
h8300-elf  +FAIL: binutils-all/strip-14
h8300-elf  +FAIL: binutils-all/strip-15

I've generally kept the union of all run_dump_test features, except
that the ld target aliases "cfi" and "shared" have disappeared, as has
the binutils substitution of $srcdir as $scrdir/$subdir.

binutils/
	* testsuite/binutils-all/add-symbol.d: Add "section_subst: no".
	* testsuite/binutils-all/elfedit.exp: Don't set tempfile or copyfile.
	* testsuite/binutils-all/symbols-1.d,
	* testsuite/binutils-all/symbols-2.d,
	* testsuite/binutils-all/symbols-3.d,
	* testsuite/binutils-all/symbols-4.d: Quote '*' and '!'.
	* testsuite/binutils-all/add-empty-section.d,
	* testsuite/binutils-all/add-section.d,
	* testsuite/binutils-all/elfedit.exp,
	* testsuite/binutils-all/note-1.d,
	* testsuite/binutils-all/pr23633.d: Add $subdir after $srcdir.
	* testsuite/config/default.exp (AS, ASFLAGS): Define.
	* testsuite/config/hppa.sed: Handle all common symbols.
	* testsuite/lib/binutils-common.exp (run_dump_test): New proc,
	merged from three other versions.
	(slurp_options, file_contents, set_file_contents): Likewise.
	(big_or_little_endian, get_standard_section_names): Likewise.
	* testsuite/lib/utils-lib.exp (run_dump_test): Delete.
	(slurp_options, proc file_contents): Delete.
	(get_standard_section_names): Delete.
gas/
	* testsuite/config/default.exp: Make tmpdir.
	* testsuite/lib/gas-defs.exp (run_dump_test): Delete.
	(get_standard_section_names, slurp_options): Delete.
ld/
	* testsuite/ld-d10v/reloc-007.d,
	* testsuite/ld-d10v/reloc-008.d,
	* testsuite/ld-d10v/reloc-015.d,
	* testsuite/ld-d10v/reloc-016.d: Remove "error:".
	* testsuite/ld-elf/eh-frame-hdr.d,
	* testsuite/ld-elf/eh5.d,
	* testsuite/ld-gc/personality.d: Replace "cfi" and "shared" in
	target list with appropriate proc.
	* testsuite/ld-elf/frame.exp: Use check_shared_lib_support rather
	than "istarget shared".
	* testsuite/lib/ld-lib.exp (proc big_or_little_endian): Delete.
	(run_dump_test, slurp_options, file_contents): Delete.
	(set_file_contents, istarget): Delete.
2018-09-15 16:56:55 +09:30
Alan Modra 99bcaeaf0f run_dump_test replace PROG with DUMPPROG in gas and ld
To be compatible with the binutils version, that uses PROG for the
tool under test and DUMPPROG for the dump tool.

gas/
	* testsuite/gas/mips/aent-2.d,
	* testsuite/gas/mips/aent-mdebug-2.d,
	* testsuite/gas/mips/attr-gnu-4-0.d,
	* testsuite/gas/mips/attr-gnu-4-1.d,
	* testsuite/gas/mips/attr-gnu-4-2.d,
	* testsuite/gas/mips/attr-gnu-4-3.d,
	* testsuite/gas/mips/attr-gnu-4-5.d,
	* testsuite/gas/mips/attr-gnu-4-6.d,
	* testsuite/gas/mips/attr-gnu-4-7.d,
	* testsuite/gas/mips/attr-none-double.d,
	* testsuite/gas/mips/attr-none-o32-fp64-nooddspreg.d,
	* testsuite/gas/mips/attr-none-o32-fp64.d,
	* testsuite/gas/mips/attr-none-o32-fpxx.d,
	* testsuite/gas/mips/attr-none-single-float.d,
	* testsuite/gas/mips/attr-none-soft-float.d,
	* testsuite/gas/mips/elf-rel27.d,
	* testsuite/gas/mips/loc-swap-2.d,
	* testsuite/gas/mips/loc-swap-3.d,
	* testsuite/gas/mips/loc-swap.d,
	* testsuite/gas/mips/micromips@loc-swap-2.d,
	* testsuite/gas/mips/micromips@loc-swap.d,
	* testsuite/gas/mips/micromips@stabs-symbol-type.d,
	* testsuite/gas/mips/mips16-intermix.d,
	* testsuite/gas/mips/mips16@loc-swap-2.d,
	* testsuite/gas/mips/mips16@loc-swap.d,
	* testsuite/gas/mips/mips16@stabs-symbol-type.d,
	* testsuite/gas/mips/mips16e@loc-swap.d,
	* testsuite/gas/mips/no-odd-spreg.d,
	* testsuite/gas/mips/odd-spreg.d,
	* testsuite/gas/mips/r6-attr-none-double.d,
	* testsuite/gas/mips/stabs-symbol-type.d,
	* testsuite/lib/gas-defs.exp (run_dump_test): Replace PROG
	with DUMPPROG.
ld/
	* testsuite/lib/ld-lib.exp (run_dump_test): Replace PROG
	with DUMPPROG.
2018-09-15 16:24:18 +09:30
Alan Modra 04ade4bc66 Remove run_dump_test support for objcopy as a dump program
We have three copies of run_dump_test in the testsuite.  This is a first
step towards consolidating them.

A few tests use objcopy to convert to verilog or srec output, then
check that output is as expected.  Those tests can just as easily use
objdump, keeping the set of dump programs (addr2line, nm, objdump,
readelf, size) separate from utilities under test.  That in turn makes
auto-detecting the dump program possible in more places.

binutils/
	* testsuite/binutils-all/group-7a.d,
	* testsuite/binutils-all/group-7b.d,
	* testsuite/binutils-all/group-7c.d,
	* testsuite/binutils-all/symbols-1.d,
	* testsuite/binutils-all/symbols-2.d,
	* testsuite/binutils-all/symbols-3.d,
	* testsuite/binutils-all/symbols-4.d: Remove DUMPPROG.
gas/
	* testsuite/gas/mri/char.d: Don't objcopy to srec, objdump instead.
	* testsuite/gas/mri/float.d: Likewise.
	* testsuite/lib/gas-defs.exp (run_dump_test): Remove support
	for objcopy as a dump tool.
ld/
	* testsuite/ld-elf/interleave-0.d,
	* testsuite/ld-elf/interleave-4.d: Don't objcopy to srec,
	objdump instead.
	* testsuite/ld-gc/all-debug-sections.d,
	* testsuite/ld-scripts/provide-4.d,
	* testsuite/ld-scripts/provide-5.d,
	* testsuite/ld-scripts/provide-6.d,
	* testsuite/ld-scripts/provide-7.d,
	* testsuite/ld-scripts/provide-8.d,
	* testsuite/ld-scripts/segment-start.d: Remove PROG, specify
	nm instead.
	* testsuite/lib/ld-lib.exp (run_dump_test): Remove support
	for objcopy as a dump tool.
2018-09-15 16:24:18 +09:30
Maciej W. Rozycki 982d0151e9 PR ld/21375: MIPS: Add test cases for undefined weaks resolving to zero
Define a new procedure, `run_mips_undefweak_test', and use it to iterate
over several scenarios involving undefined weak symbols resolving to
zero, verifying expected regular MIPS, MIPS16 and microMIPS code, GOT
and dynamic symbol table generation, as well as the setting of the
EI_ABIVERSION field in the ELF file header.  In particular ensure that
symbol versioning works and that `__gnu_absolute_zero' gets assigned a
version (any will do) even if it has not been listed for exportation in
a linker version script.

	ld/
	PR ld/21375
	* testsuite/ld-mips-elf/pr21375-abi.hd: New test.
	* testsuite/ld-mips-elf/pr21375-noabi.hd: New test.
	* testsuite/ld-mips-elf/pr21375.dd: New test.
	* testsuite/ld-mips-elf/pr21375h.dd: New test.
	* testsuite/ld-mips-elf/pr21375p.dd: New test.
	* testsuite/ld-mips-elf/pr21375ph.dd: New test.
	* testsuite/ld-mips-elf/pr21375s.dd: New test.
	* testsuite/ld-mips-elf/pr21375s-n32.dd: New test.
	* testsuite/ld-mips-elf/pr21375s-n64.dd: New test.
	* testsuite/ld-mips-elf/pr21375sh.dd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n32.dd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n64.dd: New test.
	* testsuite/ld-mips-elf/pr21375shg.dd: New test.
	* testsuite/ld-mips-elf/pr21375sx.dd: New test.
	* testsuite/ld-mips-elf/pr21375sxh.dd: New test.
	* testsuite/ld-mips-elf/pr21375sm16.dd: New test.
	* testsuite/ld-mips-elf/pr21375sm16h.dd: New test.
	* testsuite/ld-mips-elf/pr21375su.dd: New test.
	* testsuite/ld-mips-elf/pr21375su-n32.dd: New test.
	* testsuite/ld-mips-elf/pr21375su-n64.dd: New test.
	* testsuite/ld-mips-elf/pr21375suh.dd: New test.
	* testsuite/ld-mips-elf/pr21375suh-n32.dd: New test.
	* testsuite/ld-mips-elf/pr21375suh-n64.dd: New test.
	* testsuite/ld-mips-elf/pr21375sux.dd: New test.
	* testsuite/ld-mips-elf/pr21375suxh.dd: New test.
	* testsuite/ld-mips-elf/pr21375.gd: New test.
	* testsuite/ld-mips-elf/pr21375h.gd: New test.
	* testsuite/ld-mips-elf/pr21375p.gd: New test.
	* testsuite/ld-mips-elf/pr21375ph.gd: New test.
	* testsuite/ld-mips-elf/pr21375s.gd: New test.
	* testsuite/ld-mips-elf/pr21375s-n32.gd: New test.
	* testsuite/ld-mips-elf/pr21375s-n64.gd: New test.
	* testsuite/ld-mips-elf/pr21375sh.gd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n32.gd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n64.gd: New test.
	* testsuite/ld-mips-elf/pr21375shg.gd: New test.
	* testsuite/ld-mips-elf/pr21375shl.gd: New test.
	* testsuite/ld-mips-elf/pr21375shv.gd: New test.
	* testsuite/ld-mips-elf/pr21375sx.gd: New test.
	* testsuite/ld-mips-elf/pr21375sxh.gd: New test.
	* testsuite/ld-mips-elf/pr21375.sd: New test.
	* testsuite/ld-mips-elf/pr21375-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375h.sd: New test.
	* testsuite/ld-mips-elf/pr21375h-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375p.sd: New test.
	* testsuite/ld-mips-elf/pr21375p-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375ph.sd: New test.
	* testsuite/ld-mips-elf/pr21375ph-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375s.sd: New test.
	* testsuite/ld-mips-elf/pr21375s-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375s-n32.sd: New test.
	* testsuite/ld-mips-elf/pr21375s-n32-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375s-n64.sd: New test.
	* testsuite/ld-mips-elf/pr21375s-n64-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375sh.sd: New test.
	* testsuite/ld-mips-elf/pr21375sh-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n32.sd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n32-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n64.sd: New test.
	* testsuite/ld-mips-elf/pr21375sh-n64-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375shg.sd: New test.
	* testsuite/ld-mips-elf/pr21375shg-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375shl.sd: New test.
	* testsuite/ld-mips-elf/pr21375shl-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375shv.sd: New test.
	* testsuite/ld-mips-elf/pr21375shv-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375sx.sd: New test.
	* testsuite/ld-mips-elf/pr21375sx-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375sxh.sd: New test.
	* testsuite/ld-mips-elf/pr21375sxh-irix.sd: New test.
	* testsuite/ld-mips-elf/pr21375.ld: New test linker script.
	* testsuite/ld-mips-elf/pr21375-xgot.ld: New test linker script.
	* testsuite/ld-mips-elf/pr21375.ver: New test version script.
	* testsuite/ld-mips-elf/pr21375v.ver: New test version script.
	* testsuite/ld-mips-elf/pr21375.s: New test source.
	* testsuite/ld-mips-elf/pr21375-mips16.s: New test source.
	* testsuite/ld-mips-elf/pr21375-n32.s: New test source.
	* testsuite/ld-mips-elf/pr21375-n64.s: New test source.
	* testsuite/ld-mips-elf/pr21375-xgot.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp (run_mips_undefweak_test):
	New procedure; run the new tests.
2018-09-14 20:22:57 +01:00
Maciej W. Rozycki 47275900ad PR ld/21375: MIPS: Fix non-zero run-time value for undefined weaks
We have an issue in the MIPS backend, with the handling of undefined
hidden and internal weak symbols.  References to such symbols are
supposed to resolve to 0 according to the ELF gABI[1]:

"Unresolved weak symbols have a zero value."

and the 64-bit MIPS psABI[2]:

"If a symbol with one of these [hidden or internal] attributes has no
definition within the executable/DSO being linked, then it must be
resolved to allocated space if common, resolved to zero if weak, or an
error reported otherwise."

however if a GOT relocation is used, then a local GOT entry is created
and used to satisfy the reference.  Such an entry is then (in DSO and
PIE binaries) subject to the usual load-time relocation, which means a
non-zero value will be returned if the base address is non-zero.  This
will defeat the usual run-time sequence like:

void a (void) __attribute__ ((visibility ("hidden"), weak));

void
x (void)
{
  if (a)
    a ();
}

This can be reproduced with this simple code:

$ cat libtest.c
extern int a __attribute__ ((visibility ("hidden"), weak));

int *
x (void)
{
  return &a;
}
$ cat test.c

int *x (void);

int
main (void)
{
  printf ("a: %p\n", x ());

  return 0;
}
$ gcc -shared -fPIC -o libtest.so libtest.c
$ gcc -o test test.c -Wl,-rpath,$(pwd) libtest.so
$ ./test
a: 0x77184000
$

The usual approach targets take is making all the steps required to
assign a GOT entry for the symbol referred, and then leave its contents
at zero with no dynamic relocation attached, therefore ensuring that the
value does not change at load time.  However this is not going to work
with the implicitly relocated GOT the MIPS psABI specifies[3]:

"The dynamic linker relocates the global offset table by first adding
the difference between the base where the shared object is loaded and
the value of the dynamic tag DT_MIPS_BASE_ADDRESS to all local global
offset table entries."

and we cannot therefore use the local GOT part.

And we cannot offhand use the global part either, as the symbol would
then have to be exported and possibly wrongly preempt symbols in other
modules involved in the dynamic load, because as per the ELF gABI[1] we
are not allowed to enter a hidden or internal symbol into the dynamic
symbol table (and then use its associated GOT entry):

"A hidden symbol contained in a relocatable object must be either
removed or converted to STB_LOCAL binding by the link-editor when the
relocatable object is included in an executable file or shared object."

and:

"An internal symbol contained in a relocatable object must be either
removed or converted to STB_LOCAL binding by the link-editor when the
relocatable object is included in an executable file or shared object."

So we have to choose something else.

Our choice is further limited by the need for the reference associated
with the GOT relocation to stay within the signed 16-bit limit from the
GOT pointer base register, while being compliant with the ELF gABI and
the MIPS psABI.  However as Alan Modra has observed[4] one possibility
is to edit (relax) the code such that the GOT reference is removed
altogether.

Based on these observations then modify MIPS BFD linker backend code to:

1. Interpret code associated with GOT relocations and relax the usual LW
   or LD instructions into a corresponding immediate load operation that
   places the value of 0 in the intended register, while leaving the GOT
   entry allocated and initialized as usually.

2. Leave any other instructions associated with GOT relocations in place
   and instead redirect the reference to a global GOT entry associated
   with a special `__gnu_absolute_zero' symbol created for this purpose,
   whose value is 0, SHN_ABS section marks it absolute, binding is
   global and export class protected, ensuring that the locally provided
   value is always used at load time, and that the value is not
   relocated by the dynamic loader.

3. Adjust any high-part GOT relocation used, typically associated with
   a LUI instruction, accordingly, so that run-time consistency is
   maintained, either by resolving to the original entry if the
   instruction associated with the corresponding low-part GOT relocation
   has been relaxed to an immediate load (in which case the value loaded
   with LUI will be overwritten), or by also redirecting the reference
   to `__gnu_absolute_zero' to complete the GOT access sequence if that
   symbol has been used.

4. Add a target `elf_backend_hide_symbol' hook, for the three MIPS ABIs,
   which prevents the `__gnu_absolute_zero' symbol from being forced
   local, to ensure that the redirection works and the symbol remains
   global/protected with existing linker scripts unchanged.

5. Observing the issue with handling SHN_ABS symbols in the GNU dynamic
   loader, covered by glibc PR 19818, set the EI_ABIVERSION field in the
   ELF file header produced to 4 (ABI_ABSOLUTE) if `__gnu_absolute_zero'
   symbol has been produced and the target configured indicates the GNU
   operating system, so that broken versions of the GNU dynamic loader
   gracefully reject the file in loading rather than going astray.  Keep
   EI_ABIVERSION at the original value for other operating systems or if
   no `__gnu_absolute_zero' symbol has been made.

The name of the special `__gnu_absolute_zero' has no meaning other than
how a human reader can interpret it, as it is ignored in dynamic loading
in the handling of the scenarios concerned.  This is because the symbol
resolves locally, and it's only the symbol's attributes that matter so
that the associated GOT entry remains unchanged at load time.

Therefore the name is somewhat arbitrary, observing however the need to
use the name space reserved for the system so that it does not conflict
with a possible user symbol, and hence the leading underscore, and also
the `gnu' infix to denote a GNU feature.  Other implementations wishing
to address the problem in a similar way may choose a different name and
have the solution still work, possibly with a mixture of modules used in
a dynamic having symbols of different names provided, which will however
not interact with each other due to the protected export class.

The symbol can be referred explicitly, however the name is an internal
implementation detail rather than a part of the ABI, and therefore no
specific semantics is guaranteed.

One limitation of this change is that if `__gnu_absolute_zero' has been
already defined, then we do not wipe the old definition and all kinds of
odd behavior can result.  This is however like with other symbols we
internally define, such as `_GLOBAL_OFFSET_TABLE_' or `__rld_map', and
therefore left as a possible future enhancement.

As an optimization the relaxation of LW and LD instructions to a load of
immediate zero is always made, even SVR4 PIC code for code that will end
up in a regular (non-PIE) executable, because there is a cache advantage
with the avoidance of a load from the GOT, even if it is otherwise
guaranteed to remain zero.  It does not reliably happen though, due to a
symbol exportation issue affecting executables, covered by PR ld/21805.

One existing test case needs to be updated, as it triggers relaxation
introduced with this change and consequently linker output does not
match expectations anymore.  As we want to keep the original issue
covered with the test case modify it then to use the LWL instruction in
place of LW, and adjust the output expected accordingly.

References:

[1] "System V Application Binary Interface - DRAFT - 19 October 2010",
    The SCO Group, Section "Symbol Table",
    <http://www.sco.com/developers/gabi/2012-12-31/ch4.symtab.html>

[2] "64-bit ELF Object File Specification, Draft Version 2.5", MIPS
    Technologies / Silicon Graphics Computer Systems, Order Number
    007-4658-001, Section 2.5 "Symbol Table", p. 22,
    <http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf>

[3] "SYSTEM V APPLICATION BINARY INTERFACE, MIPS RISC Processor
    Supplement, 3rd Edition", Section "Global Offset Table", p. 5-10,
    <http://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf>

[4] "Undo dynamic symbol state after regular object sym type mismatch",
    <https://sourceware.org/ml/binutils/2017-07/msg00265.html>

	bfd/
	PR ld/21375
	* elfxx-mips.h (_bfd_mips_elf_hide_symbol): New prototype.
	(_bfd_mips_elf_linker_flags): Update prototype.
	* elf32-mips.c (elf_backend_hide_symbol): New macro.
	* elf64-mips.c (elf_backend_hide_symbol): Likewise.
	* elfn32-mips.c (elf_backend_hide_symbol): Likewise.
	* elfxx-mips.c (mips_elf_link_hash_table): Add
	`use_absolute_zero' and `gnu_target' members.
	(mips_elf_record_global_got_symbol): Call
	`_bfd_mips_elf_hide_symbol' rather than
	`_bfd_elf_link_hash_hide_symbol'.
	(mips_use_local_got_p): Return FALSE if the symbol is absolute.
	(mips_elf_obtain_contents): Reorder function.
	(mips_elf_nullify_got_load): New function.
	(mips_elf_calculate_relocation): Add `contents' parameter.
	Nullify GOT loads or if it is not possible, then redirect GOT
	relocations to the `__gnu_absolute_zero' symbol, for references
	that are supposed to resolve to zero.
	(mips_elf_define_absolute_zero): New function.
	(_bfd_mips_elf_check_relocs): Prepare for arrangements made in
	`mips_elf_calculate_relocation' for references made via the GOT
	that are supposed to resolve to zero.
	(_bfd_mips_elf_hide_symbol): New function.
	(_bfd_mips_elf_linker_flags): Add the `gnu_target' parameter,
	set the `gnu_target' member of the MIPS hash table.
	(MIPS_LIBC_ABI_ABSOLUTE): New enumeration constant.
	(_bfd_mips_post_process_headers): Use it.

	ld/
	PR ld/21375
	* emultempl/mipself.em: Set `gnu_target' according to ${target}.
	(mips_create_output_section_statements): Update call to
	`_bfd_mips_elf_linker_flags'.
	* testsuite/ld-mips-elf/pr21334.s: Use LWL rather than LW.
	* testsuite/ld-mips-elf/pr21334.dd: Update accordingly.
2018-09-14 20:22:56 +01:00
Maciej W. Rozycki 6057dc97e4 LD: Always make a SEGMENT_START expression section-relative
Fix an issue with the SEGMENT_START builtin function where its result is
absolute when taken from the default supplied, and section-relative when
taken from a `-T' command-line override.  This is against documentation,
inconsistent and unexpected, and with PIE executables gives an incorrect
result with the `__executable_start' symbol.

Make the result of SEGMENT_START always section-relative then.

	ld/
	* ldexp.c (fold_binary): Always make the result of SEGMENT_START
	section-relative.
	* testsuite/ld-scripts/segment-start.d: New test.
	* testsuite/ld-scripts/segment-start.ld: New test linker script.
	* testsuite/ld-scripts/segment-start.s: New test source.
	* testsuite/ld-scripts/script.exp: Run the new test.
2018-09-14 20:22:56 +01:00
Maciej W. Rozycki a000f8817b LD: Avoid a division by zero page size with SEGMENT_START handling
Avoid a division by zero and thus a linker crash in SEGMENT_START script
builtin function handling, by not checking the value supplied with a
`-T' command-line override against the maximum page size if that has not
been set.

	ld/
	* ldexp.c (fold_binary): Check that `config.maxpagesize' is
	non-zero before using it as a divisor.
2018-09-14 20:22:56 +01:00
Nick Clifton b6f00d89c7 Updated Finnish translation for the ld sub-directory.
* po/fi.po: Updated Finnish translation.
2018-09-03 13:40:32 +01:00
Alan Modra 0d9a433be4 Re: ld: Lookup section in output with the same name
Fixes pr23591 test failures on hppa64-hpux and score-elf, and xfails
frv-linux and lm32-linux.

	PR ld/23591
	* testsuite/ld-elf/pr23591a.s,
	* testsuite/ld-elf/pr23591b.s,
	* testsuite/ld-elf/pr23591c.s: Don't start directives in first column.
	* testsuite/ld-elf/pr23591.d: xfail frv-linux and lm32-linux.
	Allow __start___sancov_cntrs as a local symbol.
2018-09-03 12:54:35 +09:30
H.J. Lu 4d1c633545 ld: Lookup section in output with the same name
When there are more than one input sections with the same section name,
SECNAME, linker picks the first one to define __start_SECNAME and
__stop_SECNAME symbols.  When the first input section is removed by
comdat group, we need to check if there is still an output section
with section name SECNAME.

	PR ld/23591
	* ldlang.c (undef_start_stop): Lookup section in output with
	the same name.
	* testsuite/ld-elf/pr23591.d: New file.
	* testsuite/ld-elf/pr23591a.s: Likewise.
	* testsuite/ld-elf/pr23591b.s: Likewise.
	* testsuite/ld-elf/pr23591c.s: Likewise.
2018-08-31 09:26:09 -07:00
H.J. Lu 4bb3c591b2 ld: Pass -z separate-code to ld for property-x86-4a tests
Pass -z separate-code to ld for property-x86-4a tests to generate
the expected .note.gnu.property section.  Also run i386 tests for
x86_64-*-elf* targets.

	* testsuite/ld-i386/i386.exp: Also run for x86_64-*-elf* targets.
	* testsuite/ld-i386/property-x86-4a.d: Pass -z separate-code to
	ld.
	* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
2018-08-31 05:11:03 -07:00
H.J. Lu e9d644e8fb ld: Append -mx86-used-note=no to ASFLAGS
Since x86 assembler may generate .note.gnu.property section, append
-mx86-used-note=no to tests which don't expect .note.gnu.property
section on ELF/x86 targets.

	* testsuite/ld-elf/elf.exp (ASFLAGS): Save, append
	-mx86-used-note=no and restore.
	* testsuite/ld-ifunc/ifunc.exp (ASFLAGS): Likewise.
	* testsuite/ld-scripts/defined.exp (ASFLAGS): Likewise.
	* testsuite/ld-scripts/overlay-size.exp (ASFLAGS): Likewise
2018-08-31 04:48:05 -07:00
H.J. Lu 9a8d6a757d ld: Append -Wa,-mx86-used-note=no for S-records tests
Since x86 assembler may generate .note.gnu.property section and S-records
can't handle .note.gnu.property sections, add -mx86-used-note=no to
S-records tests on ELF/x86 targets to avoid .note.gnu.property section.

	* testsuite/ld-srec/srec.exp: Append -Wa,-mx86-used-note=no to
	CC and CXX on ELF/x86 targets.
2018-08-31 04:44:59 -07:00
H.J. Lu 6c0d3bdec7 x86: Add explicit -mx86-used-note=[yes|no] to tests
Pass explicit -mx86-used-note=[yes|no] to x86 assembler and update
expected outputs from "readelf -n" if needed.

binutils/

	* testsuite/binutils-all/i386/compressed-1b.d: Pass
	-mx86-used-note=no to assembler.
	* testsuite/binutils-all/i386/compressed-1c.d: Likewise.
	* testsuite/binutils-all/x86-64/compressed-1b.d: Likewise.
	* testsuite/binutils-all/x86-64/compressed-1c.d: Likewise.
	* testsuite/binutils-all/i386/empty.d: Pass -mx86-used-note=yes
	to assembler and update expected output from "readelf -n".
	* testsuite/binutils-all/i386/ibt.d: Likewise.
	* testsuite/binutils-all/i386/pr21231a.d: Likewise.
	* testsuite/binutils-all/i386/pr21231b.d: Likewise.
	* testsuite/binutils-all/i386/shstk.d: Likewise.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk.d: Likewise.

gas/

	* testsuite/gas/i386/bss.d: Pass -mx86-used-note=no to assembler.
	* testsuite/gas/i386/ilp32/quad.d: Likewise.
	* testsuite/gas/i386/ilp32/reloc64.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-size-1.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-size-3.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-size-5.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-unwind.d: Likewise.
	* testsuite/gas/i386/property-1.d: Likewise.
	* testsuite/gas/i386/relax.d: Likewise.
	* testsuite/gas/i386/reloc64.d: Likewise.
	* testsuite/gas/i386/size-1.d: Likewise.
	* testsuite/gas/i386/size-3.d: Likewise.
	* testsuite/gas/i386/x86-64-property-1.d: Likewise.
	* testsuite/gas/i386/x86-64-size-1.d: Likewise.
	* testsuite/gas/i386/x86-64-size-3.d: Likewise.
	* testsuite/gas/i386/x86-64-size-5.d: Likewise.
	* testsuite/gas/i386/x86-64-unwind.d: Likewise.
	* testsuite/gas/i386/divide.d: Append "#pass".

ld/

	* testsuite/ld-i386/i386.exp: (ASFLAGS): Save, append
	-mx86-used-note=no and restore.  Pass -mx86-used-note=yes and
	-mx86-used-note=no to assembler.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/no-plt.exp: Pass -mx86-used-note=yes to
	assembler.
	* testsuite/ld-i386/tls.exp: Likewise.
	* testsuite/ld-x86-64/no-plt.exp: Likewise.
	* testsuite/ld-x86-64/tls.exp: Likewise.
	* testsuite/ld-i386/pr23486a.d: Pass -mx86-used-note=no to
	assembler.
	* testsuite/ld-i386/pr23486b.d: Likewise.
	* testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
	* testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486a.d: Likewise.
	* testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486b.d: Likewise.
	* testsuite/ld-i386/property-x86-3.d: Pass -mx86-used-note=yes
	to assembler and update expected output from "readelf -n".
	* testsuite/ld-i386/property-x86-4a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
	* testsuite/ld-i386/property-1a.r: New file.
	* testsuite/ld-i386/property-2a.r: Likewise.
	* testsuite/ld-i386/property-3a.r: Likewise.
	* testsuite/ld-i386/property-4a.r: Likewise.
	* testsuite/ld-i386/property-5a.r: Likewise.
	* testsuite/ld-i386/property-7a.r: Likewise.
	* testsuite/ld-x86-64/property-1a.r: Likewise.
	* testsuite/ld-x86-64/property-2a.r: Likewise.
	* testsuite/ld-x86-64/property-3a.r: Likewise.
	* testsuite/ld-x86-64/property-4a.r: Likewise.
	* testsuite/ld-x86-64/property-5a.r: Likewise.
	* testsuite/ld-x86-64/property-7a.r: Likewise.
	* testsuite/ld-x86-64/mpx.exp: Pass -mx86-used-note=no to
	assembler.
2018-08-31 04:35:57 -07:00
Chenghua Xu 9108bc33b1 [MIPS] Add Loongson 2K1000 proccessor support.
bfd/
	* archures.c (bfd_architecture): New machine
	bfd_mach_mips_gs264e.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Handle
	E_MIPS_MACH_GS264E.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Map bfd_mach_mips_gs264e to
	bfd_mach_mips_gs464e extension.

binutils/
	* NEWS: Mention Loongson 2K1000 proccessor support.
	* readelf.c (get_machine_flags): Handle gs264e.

elfcpp/
	* mips.c (EF_MIPS_MACH): New E_MIPS_MACH_GS264E.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Exclude CPU_GS264E.
	(mips_cpu_info_table): Add gs264e descriptors.
	* doc/as.texi (march table): Add gs264e.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): New E_MIPS_MACH_GS264E.
	* opcode/mips.h (CPU_XXX): New CPU_GS264E.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Run good_combination
	gs264e and gs464e.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs264e descriptors.
2018-08-29 20:55:25 +08:00
Chenghua Xu bd782c07b9 [MIPS] Add Loongson 3A2000/3A3000 proccessor support.
bfd/
	* archures.c (bfd_architecture): New machine
	bfd_mach_mips_gs464e.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Handle
	E_MIPS_MACH_GS464E.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Map bfd_mach_mips_gs464e to
	bfd_mach_mips_gs464 extension.

binutils/
	* NEWS: Mention Loongson 3A2000/3A3000 proccessor support.
	* readelf.c (get_machine_flags): Handle gs464e.

elfcpp/
	* mips.c (EF_MIPS_MACH): New E_MIPS_MACH_GS464E.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Exclude CPU_GS464E.
	(mips_cpu_info_table): Add gs464e descriptors.
	* doc/as.texi (march table): Add gs464e.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): New E_MIPS_MACH_GS464E.
	* opcode/mips.h (CPU_XXX): New CPU_GS464E.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Run good_combination
	gs464e and gs464.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs464e descriptors.
2018-08-29 20:43:19 +08:00
Chenghua Xu ac8cb70f36 [MIPS] Add Loongson 3A1000 proccessor support.
bfd/
	* archures.c (bfd_architecture): Rename
	bfd_mach_mips_loongson_3a to bfd_mach_mips_gs464.
	* bfd-in2.h (bfd_architecture): Likewise.
	* cpu-mips.c (enum I_xxx): Likewise.
	(arch_info_struct): Likewise.
	* elfxx-mips.c (_bfd_elf_mips_mach): Likewise.
	(mips_set_isa_flags): Likewise.
	(mips_mach_extensions): Likewise.
	(bfd_mips_isa_ext_mach): Likewise.
	(bfd_mips_isa_ext): Likewise.
	(print_mips_isa_ext): Delete AFL_EXT_LOONGSON_3A.

binutils/
	* NEWS: Mention Loongson 3A1000 proccessor support.
	* readelf.c (get_machine_flags): Rename loongson-3a to gs464.
	(print_mips_isa_ext): Delete AFL_EXT_LOONGSON_3A.

elfcpp/
	* mips.c (EF_MIPS_MACH): Rename E_MIPS_MACH_LS3A to
	E_MIPS_MACH_GS464.

gas/
	* config/tc-mips.c (ISA_HAS_ODD_SINGLE_FPR): Rename
	CPU_LOONGSON_3A to CPU_GS464.
	(mips_cpu_info_table): Add gs464 descriptors, Keep
	loongson3a as an alias of gs464 for compatibility.
	* doc/as.texi (march table): Rename loongson3a to gs464.
	* testsuite/gas/mips/loongson-3a-mmi.d: Set "ISA Extension"
	flag to None.

gold/
	* mips.cc (Mips_mach, add_machine_extensions, elf_mips_mach):
	Rename loongson3a to gs464.
	(mips_isa_ext_mach, mips_isa_ext): Delete loongson3a.
	(infer_abiflags): Use ases instead of isa_ext for infer ABI
flags.
	(elf_mips_mach_name): Rename loongson3a to gs464.

include/
	* elf/mips.h (E_MIPS_MACH_XXX): Rename E_MIPS_MACH_LS3A to
	E_MIPS_MACH_GS464.
	(AFL_EXT_XXX): Delete AFL_EXT_LOONGSON_3A.
	* opcode/mips.h (INSN_XXX): Delete INSN_LOONGSON_3A.
	(CPU_XXX): Rename CPU_LOONGSON_3A to CPU_GS464.
	* opcode/mips.h (mips_isa_table): Delete CPU_LOONGSON_3A case.

ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Rename loongson3a
	to gs464.

opcodes/
	* mips-dis.c (mips_arch_choices): Add gs464 descriptors, Keep
	loongson3a as an alias of gs464 for compatibility.
	* mips-opc.c (mips_opcodes): Change Comments.
2018-08-29 20:32:30 +08:00
Chenghua Xu bc672693cc [MIPS/LD/testsuite] Skip o32 flags check on mips*-*-irix*
ld/ChangeLog:

	* testsuite/ld-mips-elf/mips-elf-flags.exp (good_combination):
	Skip o32 flags checking if target is mips*-*-irix*.
2018-08-29 17:12:44 +08:00
H.J. Lu 90c745dc54 x86: Don't mask out the GNU_PROPERTY_X86_UINT32_VALID bit
Since only the GNU_PROPERTY_X86_UINT32_VALID bit may be set in data-only
relocatable objects which don't contain any instructions, linker
shouldn't mask out the GNU_PROPERTY_X86_UINT32_VALID bit when merging
GNU_PROPERTY_X86_XXX bits.  Otherwise, linker output doesn't contain
GNU_PROPERTY_X86_XXX property with any data-only relocatable inputs.
This patch keeps the GNU_PROPERTY_X86_UINT32_VALID bit and updates
readelf to print "<None>" if GNU_PROPERTY_X86_XXX property only has
the GNU_PROPERTY_X86_UINT32_VALID bit.

bfd/

	* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Don't mask
	out the GNU_PROPERTY_X86_UINT32_VALID bit.

binutils/

	* readelf.c (decode_x86_isa): Print <None> if bitmask only
	contains the GNU_PROPERTY_X86_UINT32_VALID bit.
	(decode_x86_feature_1): Likewise.
	(decode_x86_feature_2): Likewise.
	(print_gnu_property_note): Don't mask out the
	GNU_PROPERTY_X86_UINT32_VALID bit.
	* testsuite/binutils-all/i386/pr21231b.d: Updated.
	* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.

gas/

	* testsuite/gas/i386/i386.exp: Run property-1 and
	x86-64-property-1.
	* testsuite/gas/i386/property-1.d: New file.
	* testsuite/gas/i386/property-1.s: Likewise.
	* testsuite/gas/i386/x86-64-property-1.d: Likewise.

ld/

	* testsuite/ld-i386/i386.exp: Run property-x86-5.
	* testsuite/ld-i386/property-x86-5.d: New file.
	* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5a.s: Likewise.
	* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run property-x86-5 and
	property-x86-5-x32.
2018-08-27 15:42:14 -07:00
Alan Modra 3d9c8f6b3f Delay evaluation of alignment expressions in output sections
git commit 702d16713 broke expressions using CONSTANT(COMMONPAGESIZE)
in ALIGN or SUBALIGN of output section statements, because these
optional fields were evaluated at script parse time and the patch in
question delayed setting of config.commonpagesize.  The right thing to
do is keep the tree representation of those fields for later
evaluation.

	PR 23571
	* ldlang.h (section_alignment): Make it an expression tree.
	(subsection_alignment): Likewise.
	* ldlang.c (topower): Delete.
	(output_section_statement_newfunc): Adjust initialization.
	(init_os): Evaluate section_alignment.
	(lang_size_sections_1): Likewise.
	(size_input_section): Evaluate subsection_alignment.
	(lang_enter_output_section_statement): Don't evaluate here.
	(lang_new_phdr): Use exp_get_vma rather than exp_get_value_int.
	* ldexp.h (exp_get_value_int): Delete.
	(exp_get_power): Declare.
	* ldexp.c (exp_get_value_int): Delete.
	(exp_get_power): New function.
	* emultempl/pe.em (place_orphan): Build expression for section
	alignment.
	* emultempl/pep.em (place_orphan): Likewise.
	* testsuite/ld-scripts/pr23571.d,
	* testsuite/ld-scripts/pr23571.t: New test.
	* testsuite/ld-scripts/align.exp: Run it.
2018-08-26 22:45:59 +09:30
Chenghua Xu 3da65cd27e [PATCH] [MIPS] LD/testsuite: Skip 32bit test if ld not support.
ld/ChangeLog:

    * testsuite/ld-mips-elf/mips-elf-flags.exp
    (check_ld_support_32bit, check_is_32bit_args): New procedures.
    (good_combination, bad_combination): Skip 32bit test if ld
    not support 32bit emulations.
2018-08-24 21:25:15 +08:00
H.J. Lu a9eafb08b3 x86: Update GNU_PROPERTY_X86_XXX macros
This patch updates GNU_PROPERTY_X86_XXX macros:

1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_AND_LO      0xc0000002
 #define GNU_PROPERTY_X86_UINT32_AND_HI      0xc0007fff

2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_LO    0xc0008000
 #define GNU_PROPERTY_X86_UINT32_OR_HI    0xc000ffff

3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs and the property is
present in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_AND_LO   0xc0010000
 #define GNU_PROPERTY_X86_UINT32_OR_AND_HI   0xc0017fff

4. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED
and GNU_PROPERTY_X86_FEATURE_2_XXX bits.

GNU_PROPERTY_X86_FEATURE_1_AND is unchanged.  GNU_PROPERTY_X86_ISA_1_USED
and GNU_PROPERTY_X86_ISA_1_NEEDED are updated to better support targeted
processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very useful.
A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined.  The previous
GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed to
GNU_PROPERTY_X86_COMPAT_ISA_1_XXX.

bfd/

	* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Handle
	X86_COMPAT_ISA_1_USED, X86_COMPAT_ISA_1_NEEDED,
	X86_UINT32_AND_LO, X86_UINT32_AND_HI, X86_UINT32_OR_LO,
	X86_UINT32_OR_HI, X86_UINT32_OR_AND_LO and X86_UINT32_OR_AND_HI
	instead of X86_ISA_1_USED, X86_ISA_1_NEEDED and X86_FEATURE_1_AND.
	(_bfd_x86_elf_merge_gnu_properties): Likewise.
	(_bfd_x86_elf_link_setup_gnu_properties): Add X86_FEATURE_2_NEEDED
	instead of X86_ISA_1_NEEDED.
	(_bfd_x86_elf_link_fixup_gnu_properties): Handle
	X86_COMPAT_ISA_1_USED, X86_COMPAT_ISA_1_NEEDED, X86_UINT32_AND_LO,
	X86_UINT32_AND_HI, X86_UINT32_OR_LO, X86_UINT32_OR_HI,
	X86_UINT32_OR_AND_LO and X86_UINT32_OR_AND_HI instead of
	X86_ISA_1_USED, X86_ISA_1_NEEDED and X86_FEATURE_1_AND.

binutils/

	* readelf.c (decode_x86_compat_isa): New function.
	(decode_x86_feature_2): Likewise.
	(decode_x86_isa): Updated for new X86_ISA_1_XXX bits.
	(decode_x86_feature): Renamed to ...
	(decode_x86_feature_1): This.  Remove the type argument.
	(print_gnu_property_note): Handle X86_COMPAT_ISA_1_USED,
	X86_COMPAT_ISA_1_NEEDED, X86_UINT32_AND_LO, X86_UINT32_AND_HI,
	X86_UINT32_OR_LO, X86_UINT32_OR_HI, X86_UINT32_OR_AND_LO and
	X86_UINT32_OR_AND_HI instead of X86_ISA_1_USED, X86_ISA_1_NEEDED
	and X86_FEATURE_1_AND.
	* testsuite/binutils-all/i386/pr21231b.s: Updated to the current
	GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
	values.
	* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.s: Likewise.
	* testsuite/binutils-all/i386/pr21231b.d: Updated.
	* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.

include/

	* elf/common.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This.
	(GNU_PROPERTY_X86_ISA_1_XXX): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_ISA_1_XXX): This.
	(GNU_PROPERTY_X86_UINT32_AND_LO): New.
	(GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
	(GNU_PROPERTY_X86_ISA_1_CMOV): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE3): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSSE3): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE4_1): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE4_2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_FMA): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512F): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512CD): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512ER): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512PF): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512VL): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512BW): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_BITALG): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_IFMA): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_VBMI): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_VNNI): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_X86): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_X87): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_MMX): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XMM): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_YMM): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_ZMM): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_FXSR): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XSAVE): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XSAVEC): Likewise.
	(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
	(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Defined to
	(GNU_PROPERTY_X86_UINT32_OR_LO + 0).
	(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New.  Defined to
	(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
	(GNU_PROPERTY_X86_ISA_1_USED): Defined to
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0).
	(GNU_PROPERTY_X86_FEATURE_2_USED): New.  Defined to
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).

ld/

	* testsuite/ld-i386/i386.exp: Run pr23372c, pr23372d, pr23486c
	and pr23486d.
	* testsuite/ld-i386/pr23372a.s: Update comments.
	* testsuite/ld-i386/pr23372b.s: Likewise.
	* testsuite/ld-i386/pr23372c.s: Likewise.
	* testsuite/ld-x86-64/pr23372a.s: Likewise.
	* testsuite/ld-x86-64/pr23372b.s: Likewise.
	* testsuite/ld-x86-64/pr23372c.s: Likewise.
	* testsuite/ld-x86-64/pr23486a.s: Likewise.
	* testsuite/ld-x86-64/pr23486b.s: Likewise.
	* testsuite/ld-i386/pr23372c.d: New file.
	* testsuite/ld-i386/pr23372d.d: Likewise.
	* testsuite/ld-i386/pr23486c.d: Likewise.
	* testsuite/ld-i386/pr23486d.d: Likewise.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23372d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372d.d: Likewise.
	* testsuite/ld-x86-64/pr23372d.s: Likewise.
	* testsuite/ld-x86-64/pr23372e.s: Likewise.
	* testsuite/ld-x86-64/pr23372f.s: Likewise.
	* testsuite/ld-x86-64/pr23486c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486c.d: Likewise.
	* testsuite/ld-x86-64/pr23486c.s: Likewise.
	* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486d.d: Likewise.
	* testsuite/ld-x86-64/pr23486d.s: Likewise.
	* testsuite/ld-i386/property-3.r: Updated.
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-x86-3.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-3.r: Likewise.
	* testsuite/ld-x86-64/property-4.r: Likewise.
	* testsuite/ld-x86-64/property-5.r: Likewise.
	* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-i386/property-x86-1.S: Updated to the current
	GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
	values.
	* testsuite/ld-i386/property-x86-2.S: Likewise.
	* testsuite/ld-i386/property-x86-3.s: Likewise.
	* testsuite/ld-x86-64/property-x86-1.S: Likewise.
	* testsuite/ld-x86-64/property-x86-2.S: Likewise.
	* testsuite/ld-x86-64/property-x86-3.s: Likewise.
	* ld/testsuite/ld-x86-64/x86-64.exp: Run pr23372c, pr23372c-x32,
	pr23372d, pr23372d-x32, pr23486c, pr23486c-x32, pr23486d and
	pr23486d-x32.
2018-08-24 04:42:15 -07:00
Alan Modra 772758ac42 ehdr_start twiddles
We force __ehdr_start to defined in before_allocation, then restore
the type and a union after dynamic symbols have been allocated.
The union contains a number of structs, all starting with a "next"
pointer, and various fields depending on the symbol type.  The old
code restored the entire union, but it isn't necessary to restore the
"next" pointer, and in fact it could be wrong if __ehdr_start happened
to be last on the list and some symbols were added before restoring.

	* emultempl/elf32.em (before_allocation): Don't restore
	__ehdr_start u.*.next pointer.
2018-08-24 18:25:22 +09:30
Alan Modra 2cd65cb935 PR23566, false uninitialized warning
PR 23566
	* emultempl/elf32.em (before_allocation): Warning fix.
2018-08-24 00:26:40 +09:30
H.J. Lu 7dd36a6f1c Prune BFD warnings for unknown GNU properties
When glibc is enabled with the new GNU_PROPERTY_X86_XXX bits:

https://groups.google.com/forum/#!topic/x86-64-abi/-D05GQ3kWrA

BFD will issue an unknown GNU property warning like

warning: tmpdir/ld1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001

and ignore such GNU properties.  This patch adds prune_warnings_extra to
prune such warnings on release branches and updates prune_warnings to
call prune_warnings_extra.

binutils/

	PR ld/23536
	* Makefile.am (development.exp): New target.
	(EXTRA_DEJAGNU_SITE_CONFIG): New.
	(DISTCLEANFILES): Add development.exp.
	* Makefile.in: Regenerated.
	* testsuite/binutils-all/objcopy.exp (strip_test): Call
	prune_warnings to prune BFD output.
	(strip_test_with_saving_a_symbol): Likewise.
	(objcopy_test_without_global_symbol): Likewise.
	* testsuite/lib/binutils-common.exp (prune_warnings_extra):
	New proc.
	(prune_warnings): Likewise.

gas/

	PR ld/23536
	* Makefile.am (development.exp): New target.
	(EXTRA_DEJAGNU_SITE_CONFIG): New.
	(DISTCLEANFILES): Add development.exp.
	* Makefile.in: Regenerated.

ld/

	PR ld/23536
	* Makefile.am (development.exp): New target.
	(EXTRA_DEJAGNU_SITE_CONFIG): New.
	(DISTCLEANFILES): Add development.exp.
	* Makefile.in: Regenerated.
	* testsuite/ld-bootstrap/bootstrap.exp: Call prune_warnings to
	prune BFD output.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/lib/ld-lib.exp (prune_warnings): Removed.
	* testsuite/ld-elf/shared.exp: Allow "\n" in linker warnings.
2018-08-23 06:12:50 -07:00
Nick Clifton c8455dc986 Update the documentation of the linker's --hash-style option.
PR 23426
	* ld.texi (--hash-style): Note that the default is configurable
	and that for most Linux based systems it will be "both".
2018-08-21 16:16:09 +01:00
Alan Modra 2e72a56e45 Remove duplicate ld testsuite function
It's in binutils/testsuite/lib/binutils-common.exp

	* testsuite/ld-elf/elf.exp (is_elf64): Delete.
2018-08-18 13:47:03 +09:30
H.J. Lu bfb1e8c15a x86: Remove empty X86_FEATURE_1_AND property
There is no need to generate .note.gnu.property section with empty
X86_FEATURE_1_AND property.  This patch adds fixup_gnu_properties
to ELF linker backend so that x86 backend can remove it.

bfd/

	PR ld/23515
	* elf-bfd.h (elf_backend_data): Add fixup_gnu_properties.
	* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Call
	backend fixup_gnu_properties if it isn't NULL.  Discard
	.note.gnu.property section if all properties have been removed.
	* elfxx-target.h (elf_backend_fixup_gnu_properties): New.
	(elfNN_bed): Initialize fixup_gnu_properties.
	* elfxx-x86.c (_bfd_x86_elf_link_fixup_gnu_properties): New
	function.
	* elfxx-x86.h (_bfd_x86_elf_link_fixup_gnu_properties): New
	prototype.
	(elf_backend_fixup_gnu_properties): New.

ld/

	PR ld/23515
	* testsuite/ld-i386/ibt-plt-2a.d: Updated.
	* testsuite/ld-i386/ibt-plt-2b.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2b.d: Likewise.
2018-08-17 03:54:16 -07:00
H.J. Lu 988daa317c ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s
Swap pr23486a.s and pr23486a.s so that pr23486b.d differs from pr23486a.d.

	* testsuite/ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s.
2018-08-12 05:39:00 -07:00