Commit Graph

6021 Commits

Author SHA1 Message Date
Alan Modra a67ae9b01a Re: PowerPC64 __tls_get_addr_opt stub .eh_frame fix
The modified test failed on some powerpc targets due to differences in
default hash style.  If the default hash style is both, then more
sections are created, bumping section ids.  Section id is used in stub
symbols and although the test is careful to not depend on id in
labels, the stub hash traversal order changes when stub names change.
That lead to the stubs being emitted in a different order and thus not
matching expected output.

	* testsuite/ld-powerpc/powerpc.exp: Run tlsopt5 with hash-style
	specified.
2018-08-01 19:06:37 +09:30
Alan Modra 1aa4214141 PowerPC64 __tls_get_addr_opt stub .eh_frame fix
This patch sets stub_offset in ppc_size_one_stub rather than in
ppc_build_one_stub.  That allows the plt stub alignment to be done in
just ppc_size_one_stub rather than both functions.  The patch also
corrects the place where the alignment was done, fixing a possible
error in .eh_frame data, and tidies some offset calculations.

bfd/
	* elf64-ppc.c (plt_stub_pad): Delay plt_stub_size call until needed.
	(ppc_build_one_stub): Don't set stub_offset, instead assert that
	it is sane.  Don't adjust stub_offset for alignment.  Adjust size
	calculation.  Use "targ" temp when calculating offsets.
	(ppc_size_one_stub): Set stub_offset here.  Use "targ" temp when
	calculating offsets.  Adjust for alignment before setting
	tls_get_addr_opt_bctrl.
ld/
	* testsuite/ld-powerpc/powerpc.exp: Run tlsopt5 with plt alignment.
	* testsuite/ld-powerpc/tlsopt5.s: Add extra call.
	* testsuite/ld-powerpc/tlsopt5.wf: Adjust expected output.
	* testsuite/ld-powerpc/tlsopt5.d: Likewise.
2018-08-01 12:14:22 +09:30
Alan Modra cb86a42aba csky regen
bfd/
	* po/SRC-POTFILES.in: Regenerate.
gas/
	* po/POTFILES.in: Regenerate.
ld/
	* po/BLD-POTFILES.in: Regenerate.
opcodes/
	* po/POTFILES.in: Regenerate.
2018-08-01 10:32:56 +09:30
Nick Clifton 4570c3d98c Fix thinko in the placement of the .gnu.build.attributes section.
* scripttempl/elf.sc: Move the .gnu.build.attributes section to
	after the .comment section.
2018-07-30 12:35:37 +01:00
Andrew Jenner b8891f8d62 Add support for the C_SKY series of processors.
This patch series is a new binutils port for C-SKY processors, including support for both the V1 and V2 processor variants.  V1 is derived from the MCore architecture while V2 is substantially different, with mixed 16- and 32-bit instructions, a larger register set, a different (but overlapping) ABI, etc.  There is support for bare-metal ELF targets and Linux with both glibc and uClibc.

This code is being contributed jointly by C-SKY Microsystems and Mentor Graphics.  C-SKY is responsible for the technical content and has proposed Lifang Xia and Yunhai Shang as port maintainers.  (Note that C-SKY does have a corporate copyright assignment on file with the FSF.) Mentor Graphics' role has been cleaning up the code, adding documentation and additional test cases, etc, to address issues we anticipated reviewers would complain about.

bfd     * Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES): Add C-SKY.
        (BFD32_BACKENDS, BFD_BACKENDS_CFILES): Likewise.
        * Makefile.in: Regenerated.
        * archures.c (enum bfd_architecture): Add bfd_arch_csky and
        related bfd_mach defines.
        (bfd_csky_arch): Declare.
        (bfd_archures_list): Add C-SKY.
        * bfd-in.h (elf32_csky_build_stubs): Declare.
        (elf32_csky_size_stubs): Declare.
        (elf32_csky_next_input_section: Declare.
        (elf32_csky_setup_section_lists): Declare.
        * bfd-in2.h: Regenerated.
        * config.bfd: Add C-SKY.
        * configure.ac: Likewise.
        * configure: Regenerated.
        * cpu-csky.c: New file.
        * elf-bfd.h (enum elf_target_id): Add C-SKY.
        * elf32-csky.c: New file.
        * libbfd.h: Regenerated.
        * reloc.c: Add C-SKY relocations.
        * targets.c (csky_elf32_be_vec, csky_elf32_le_vec): Declare.
        (_bfd_target_vector): Add C-SKY target vector entries.

binutils* readelf.c: Include elf/csky.h.
        (guess_is_rela): Handle EM_CSKY.
        (dump_relocations): Likewise.
        (get_machine_name): Likewise.
        (is_32bit_abs_reloc): Likewise.

include  * dis-asm.h (csky_symbol_is_valid): Declare.
         * opcode/csky.h: New file.

opcodes  * Makefile.am (TARGET_LIBOPCODES_CFILES): Add csky-dis.c.
         * Makefile.in: Regenerated.
         * configure.ac: Add C-SKY.
         * configure: Regenerated.
         * csky-dis.c: New file.
         * csky-opc.h: New file.
         * disassemble.c (ARCH_csky): Define.
         (disassembler, disassemble_init_for_target): Add case for ARCH_csky.
         * disassemble.h (print_insn_csky, csky_get_disassembler): Declare.

gas      * Makefile.am (TARGET_CPU_CFILES): Add entry for C-SKY.
         (TARGET_CPU_HFILES, TARGET_ENV_HFILES): Likewise.
         * Makefile.in: Regenerated.
         * config/tc-csky.c: New file.
         * config/tc-csky.h: New file.
         * config/te-csky_abiv1.h: New file.
         * config/te-csky_abiv1_linux.h: New file.
         * config/te-csky_abiv2.h: New file.
         * config/te-csky_abiv2_linux.h: New file.
         * configure.tgt: Add C-SKY.
         * doc/Makefile.am (CPU_DOCS): Add entry for C-SKY.
         * doc/Makefile.in: Regenerated.
         * doc/all.texi: Set CSKY feature.
         * doc/as.texi (Overview): Add C-SKY options.
         (Machine Dependencies): Likewise.
         * doc/c-csky.texi: New file.
         * testsuite/gas/csky/*: New test cases.

ld      * Makefile.am (ALL_EMULATION_SOURCES): Add C-SKY emulations.
        (ecskyelf.c, ecskyelf_linux.c): New rules.
        * Makefile.in: Regenerated.
        * configure.tgt: Add C-SKY.
        * emulparams/cskyelf.sh: New file.
        * emulparams/cskyelf_linux.sh: New file.
        * emultempl/cskyelf.em: New file.
        * gen-doc.texi: Add C-SKY.
        * ld.texi: Likewise.
        (Options specific to C-SKY targets): New section.
        * testsuite/ld-csky/*: New tests.
2018-07-30 12:24:14 +01:00
Nick Clifton 7d8a316657 Combine ,gnu.build.attributes.* sections into one .gnu.build.attributes section during linking.
gold	* layout.cc (section_name_mapping): Add an entry for
	.gnu.build.attributes.

ld	* scripttempl/elf.sc: Place .gnu.build.attributes sections with
	other read-only sections.
2018-07-30 09:34:40 +01:00
John Darrington fe57a8c9f5 S12Z: Emit uninitialized data in the .bss segment
* scripttempl/elfm9s12z.sc: Put input sections called .common
	into the .bss segment.
2018-07-27 11:28:59 +09:30
John Darrington 5b73b52bcc S12Z: Emit initialized data segment image.
* scripttempl/elfm9s12z.sc: Emit the data_section at the end of text.
2018-07-27 11:28:59 +09:30
Alan Modra b358827438 Re: Enhance powerpc ld -r --relax
git commit 491993044b broke the powerpc vxworks testsuite.

	* testsuite/ld-powerpc/vxworks-relax-2.rd: Update for 2018-07-25
	ppc_elf_relax_section changes.
2018-07-26 17:38:56 +09:30
Alan Modra 33cb30a1f9 Implement PowerPC64 .localentry for value 1
This adds support for ".localentry 1", a new st_other
STO_PPC64_LOCAL_MASK encoding that signifies a function with a single
entry point like ".localentry 0", but unlike a ".localentry 0"
function does not preserve r2.

include/
	* elf/ppc64.h: Specify byte offset to local entry for values
	of two to six in STO_PPC64_LOCAL_MASK.  Clarify r2 return
	value for such functions when entering via global entry point.
	Specify meaning of a value of one in STO_PPC64_LOCAL_MASK.
bfd/
	* elf64-ppc.c (ppc64_elf_size_stubs): Use a ppc_stub_long_branch_r2off
	for calls to symbols with STO_PPC64_LOCAL_MASK bits set to 1.
gas/
	* config/tc-ppc.c (ppc_elf_localentry): Allow .localentry values
	of 1 and 7 to directly set value into STO_PPC64_LOCAL_MASK bits.
ld/testsuite/
	* ld-powerpc/elfv2.s: Add .localentry f5,1 testcase.
	* ld-powerpc/elfv2exe.d: Update.
	* ld-powerpc/elfv2so.d: Update.
2018-07-26 12:53:50 +09:30
Alan Modra 491993044b Enhance powerpc ld -r --relax
One of the ill effects of ld -r is to mash together sections.  That
can result in reduced icache performance at runtime due to unexpected
movement of code.  Another problem is that sections can become too
large to link on targets that have limited relative addressing.  ld -r
--relax attempts to overcome the large section problem for branches by
inserting trampolines, but the powerpc support added lots of
unnecessary trampolines.  This patch trims them somewhat.

bfd/
	* elf32-ppc.c (ppc_elf_relax_section): Ignore common or undef locals.
	Avoid trashing toff with added when used as a symbol index.
	Ignore R_PPC_PLTREL24 addends in unused example code.  Avoid
	creating unnecessary fixups when relocatable.
ld/
	* testsuite/ld-powerpc/big.s: New file.
	* testsuite/ld-powerpc/relaxrl.d: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run new test.
	* testsuite/ld-powerpc/relaxr.d: Adjust.
2018-07-25 16:52:58 +09:30
Nick Clifton 1d97232ae3 Updated French translation for ld/ and Swedish translation for binutils/
bin	* po/sv.po: Updated Swedish translation.

ld	* po/fr.po: Updated French translation.
2018-07-24 14:07:54 +01:00
Max Filippov 2ae0bdddef xtensa: ld: convert tests to run_dump_test
Three tests with individual .exp files can be implemented in less
verbose way with run_dump_test infrastructure. Convert them.

ld/
2018-07-23  Max Filippov  <jcmvbkbc@gmail.com>

	* testsuite/ld-xtensa/coalesce.d: New file.
	* testsuite/ld-xtensa/coalesce.exp: Remove file.
	* testsuite/ld-xtensa/diff_overflow.d: New file.
	* testsuite/ld-xtensa/diff_overflow.exp: Remove file.
	* testsuite/ld-xtensa/lcall.d: New file.
	* testsuite/ld-xtensa/lcall.exp: Remove file.
	* testsuite/ld-xtensa/xtensa.exp (coalesce, diff_overflow)
	(lcall): New tests.
2018-07-23 12:06:40 -07:00
Max Filippov f5e263426f xtensa: ld: add tests for static linkage relaxation
ld/
2018-07-23  Max Filippov  <jcmvbkbc@gmail.com>

	* testsuite/ld-xtensa/relax-static-defs.s: New file.
	* testsuite/ld-xtensa/relax-static-local-pie.d: New file.
	* testsuite/ld-xtensa/relax-static-local-shared.d: New file.
	* testsuite/ld-xtensa/relax-static-local.s: New file.
	* testsuite/ld-xtensa/relax-static-pie.d: New file.
	* testsuite/ld-xtensa/relax-static-shared.d: New file.
	* testsuite/ld-xtensa/relax-static.s: New file.
	* testsuite/ld-xtensa/relax-undef-weak-local-pie.d: New file.
	* testsuite/ld-xtensa/relax-undef-weak-local-shared.d: New file.
	* testsuite/ld-xtensa/relax-undef-weak-local.s: New file.
	* testsuite/ld-xtensa/relax-undef-weak-pie.d: New file.
	* testsuite/ld-xtensa/relax-undef-weak-shared.d: New file.
	* testsuite/ld-xtensa/relax-undef-weak.s: New file.
	* testsuite/ld-xtensa/xtensa.exp: New file.
2018-07-23 12:05:43 -07:00
Max Filippov da90fdf993 xtensa: ld: rename xtensa.exp to xtensa-linux.exp
xtensa.exp in fact only checks xtensa*-*-linux* configurations, rename
it to xtensa-linux.exp to allow xtensa.exp to check xtensa*-*-*.

ld/
2018-07-23  Max Filippov  <jcmvbkbc@gmail.com>

	* testsuite/ld-xtensa/xtensa.exp: Rename to xtensa-linux.exp.
2018-07-23 12:04:45 -07:00
Alan Modra 49ddb0fbda PowerPC64 fails reloc-discard test
PowerPC64 fails here due to emitting a warning about discarded dynamic
relocations.  That's a good thing, since accidentally discarding
dynamic relocations will likely result in a non-working binary.

	* testsuite/ld-elf/reloc-discard-warn.d: New.
	* testsuite/ld-elf/reloc-discard.d: Skip test on PowerPC64.
2018-07-23 13:06:33 +09:30
H.J. Lu d5f4da5e33 ld: Discard .rel.* and .rela.* sections
On many targets, like x86, .rel.dyn/.rela.dyn section is combined from
different .rel/.rela sections by -z combreloc.  To discard dynamic
relocation section, we need to discard .rel.* and .rela.* sections
instead of .rel.dyn and .rela.dyn sections.

Note: This test fails for targets which issue a warning when dynamic
section is discarded.

	* testsuite/ld-elf/reloc-discard.ld: Discard .rel.* and .rela.*
	sections instead of .rel.dyn and .rela.dyn sections.
2018-07-20 09:58:45 -07:00
H.J. Lu 241e64e3b4 x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed
When -z separate-code, which is enabled by default for Linux/x86, is
used to create executable, ld won't place any data in the code-only
PT_LOAD segment.  If there are no data sections placed before the
code-only PT_LOAD segment, the program headers won't be mapped into
any PT_LOAD segment.  When the executable tries to access it (based
on the program header address passed in AT_PHDR), it will lead to
segfault.  This patch inserts a GNU_PROPERTY_X86_ISA_1_USED note if
there may be no data sections before the text section so that the
first PT_LOAD segment won't be code-only and will contain the program
header.

Testcases are adjusted to either pass "-z noseparate-code" to ld or
discard the .note.gnu.property section.  A Linux/x86 run-time test is
added.

bfd/

	PR ld/23428
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the
	separate code program header is needed, make sure that the first
	read-only PT_LOAD segment has no code by adding a
	GNU_PROPERTY_X86_ISA_1_USED note.

ld/

	PR ld/23428
	* testsuite/ld-elf/linux-x86.S: New file.
	* testsuite/ld-elf/linux-x86.exp: Likewise.
	* testsuite/ld-elf/pr23428.c: Likewise.
	* testsuite/ld-elf/sec64k.exp: Pass "-z noseparate-code" to ld
	for Linux/x86 targets.
	* testsuite/ld-i386/abs-iamcu.d: Likewise.
	* testsuite/ld-i386/abs.d: Likewise.
	* testsuite/ld-i386/pr12718.d: Likewise.
	* testsuite/ld-i386/pr12921.d: Likewise.
	* testsuite/ld-x86-64/abs-k1om.d: Likewise.
	* testsuite/ld-x86-64/abs-l1om.d: Likewise.
	* testsuite/ld-x86-64/abs.d: Likewise.
	* testsuite/ld-x86-64/pr12718.d: Likewise.
	* testsuite/ld-x86-64/pr12921.d: Likewise.
	* testsuite/ld-linkonce/zeroeh.ld: Discard .note.gnu.property
	section.
	* testsuite/ld-scripts/print-memory-usage.t: Likewise.
	* testsuite/ld-scripts/size-2.t: Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use ld
	to create executable if language is "asm".
2018-07-20 09:19:00 -07:00
Andre Simoes Dias Vieira 3ba174474d [PATCH, LD, AArch64] Fix ifunc testisms
This patch fixes some ifunc testisms after H.J. Lu's patch to enable the
use of IFUNC pointers in position dependent code for binutils. See PR
LD/23169 in binutils bugzilla.

The aarch64 ifunc error message test was changed to no longer expect
this error message as this is now an accepted combination. This patch
also disables the executable tests added by H.J. Lu for aarch64, just as
Alan Modra did with his patch, as these tests only seem to work on some
architectures.

ld/ChangeLog:
2018-07-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* testsuite/ld-aarch64/ifunc-9.d: Remove no longer expected error.
	* testsuite/ld-ifunc/ifunc.exp: Disable tests for aarch64.
2018-07-20 16:35:37 +01:00
Maciej W. Rozycki db841b6fcd MIPS/LD: Fix crashing with a discarded dynamic relocation section
Fix a crash that occurs in `_bfd_mips_elf_finish_dynamic_sections' if a
dynamic relocation section has been created, but marked to be discarded
by an assignment to the /DISCARD/ output section in a linker script.
In that case the output section is the absolute section, which has no
ELF section data attached, so trying to set its `sh_size' parameter
causes a null pointer dereference.

This is only done as the value for the DT_RELSZ dynamic entry is being
set, so fix the problem by not creating DT_REL, DT_RELSZ or DT_RELENT
dynamic entries in the first place if the dynamic relocation section
will not be output, as with no dynamic relocation data present these
would not serve their purpose anyway.

Add a generic ELF test case to verify that no dynamic relocation data is
reported in the dynamic segment.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Do not
	create DT_REL, DT_RELSZ or DT_RELENT dynamic entries if the
	dynamic relocation section will be discarded from output.
	(_bfd_mips_elf_finish_dynamic_sections) <DT_RELSZ>: Assert that
	the dynamic relocation section will be retained in output.

	ld/
	* testsuite/ld-elf/reloc-discard.d: New test.
	* testsuite/ld-elf/reloc-discard.ld: New test linker script.
	* testsuite/ld-elf/reloc-discard.s: New test source.
2018-07-20 13:21:33 +01:00
Andreas Krebbel afca762f59 S/390: Improve partial relro support for 64 bit
Currently on S/390 the .got.plt always comes first which prevents the
GNU_RELRO segment from being extended across the non-plt GOT entries.

Just swapping both unfortunately is not that simple since our ABI
requires the _GLOBAL_OFFSET_TABLE_ symbol to point to the very
beginning of the entire GOT. Of the 3 magic GOT entries the first is
accessed via got pointer while second and third are being accessed via
DT_PLTGOT.  In order to keep them together we make DT_PLTGOT to point
to the .got instead of .got.plt.  However, this violates an assumption
in the dynamic linker prelink undo code about the GOTPLT entries
starting at DT_PLTGOT + 3.  We got rid of this requirement with a
Glibc patch already in version 2.24:
https://sourceware.org/ml/libc-alpha/2016-06/msg01302.html

So the S/390 relro GOT layout will look like this with this patch:

      +----------------------------------+
      |got[0]: DYNAMIC                   |   <--- _GLOBAL_OFFSET_TABLE_ == DT_PLTGOT .got
      |got[1]: link_map parm             |
      |got[2]: &_dl_runtime_resolve      |
      +----------------------------------+
      |                                  |   non-plt GOT entries
      |                                  |
      |                                  |
      +----------------------------------+
      |                                  |   <--- .gotplt, PLT GOT entries
      |                                  |
      |                                  |
      |                                  |
      +----------------------------------+

The patch detects the current layout in size_dynamic_section in order
to deal also with linker scripts not generated by this ld version.
With partial relro enabled we pick a linker script where .got and
.got.plt are swapped which then triggers the rest of the logic.

ld/ChangeLog:

2018-07-18  Andreas Krebbel  <krebbel@linux.ibm.com>

	* emulparams/elf64_s390.sh: Define GENERATE_RELRO_SCRIPT and
	SEPARATE_GOTPLT.
	* testsuite/ld-s390/gotreloc_64-relro-1.dd: New test.
	* testsuite/ld-s390/gotreloc_64-norelro-1.dd: Renamed from ...
	* testsuite/ld-s390/gotreloc_64-1.dd: ... this.
	* testsuite/ld-s390/s390.exp: Split the GOT testcase into two.

bfd/ChangeLog:

2018-07-18  Andreas Krebbel  <krebbel@linux.ibm.com>

	* elf-s390-common.c (s390_gotplt_after_got_p): New function.
	(s390_got_pointer): New function.
	(s390_got_offset): New function.
	(s390_gotplt_offset): New function.
	* elf64-s390.c (allocate_dynrelocs): Adjust comment.
	(elf_s390_size_dynamic_sections): Move space for magic GOT entries
	from .got.plt to .got if necessary and pick the right location for
	_GLOBAL_OFFSET_TABLE_.
	(elf_s390_relocate_section): Use the wrapper functions from
	elf-s390-common.c to deal with both possible layouts (either .got
	or .got.plt first).
	(elf_s390_finish_dynamic_sections): Likewise.
	(elf_s390_finish_dynamic_symbol): Make the location of the GOT
	magic entries conditional.
2018-07-18 13:20:06 +02:00
Andreas Krebbel a38137289e ld: Enable using separate linker script for -z relro
With this patch dedicated linker scripts can be generated for partial
relro triggered by defining GENERATE_RELRO_SCRIPT in the target
specific scripts.

This is necessary for e.g. S/390 where usually the .got.plt comes
first and prevents the relro segment from being extended across the
non-plt GOT entries.

The patch started with the work from Marcin taken from the mwk user
branches.  However, the patch needed substantial changes due to the
'separate code' feature which got committed in the meantime.

ld/ChangeLog:

2018-07-18  Andreas Krebbel  <krebbel@linux.ibm.com>
	    Marcin Kościelnicki <koriakin@0x04.net>

	* emultempl/elf32.em: Add code to pick dedicated linker scripts
	for partial relro.
	* genscripts.sh: Generate dedicated linker scripts for partial relro.
2018-07-18 13:20:06 +02:00
Nick Clifton 0984c34e76 Updated French translation for gold and Spanish translation for ld.
ld	* po/es.po: Updated Spanish translation.
gold	* po/fr.po: Updated French translation.
2018-07-18 08:37:38 +01:00
Maciej W. Rozycki d5c928c053 LD: Export relative-from-absolute symbol marking to BFD
It is usually possible to tell absolute and ordinary symbols apart in
BFD throughout the link, by checking whether the section that owns the
symbol is absolute or not.

That however does not work for ordinary symbols defined in a linker
script outside an output section statement.  Initially such symbols are
entered into to the link hash as absolute symbols, owned by the absolute
section.  A flag is set in the internal linker expression defining such
symbols to tell the linker to convert them to section-relative ones in
the final phase of the link.  That flag is however not accessible to BFD
linker code, including BFD target code in particular.

Add a flag to the link hash then to copy the information held in the
linker expression.  Define a macro, `bfd_is_abs_symbol', for BFD code to
use where determining whether a symbol is absolute or ordinary is
required before the final link phase.

This macro will correctly identify the special `__ehdr_start' symbol as
ordinary throughout link, for example, even though early on it will be
assigned to the absolute section.  Of course this does not let BFD code
identify what the symbol's ultimate section will be before the final
link phase has converted this symbol (in `update_definedness').

	include/
	* bfdlink.h (bfd_link_hash_entry): Add `rel_from_abs' member.

	bfd/
	* linker.c (bfd_is_abs_symbol): New macro.
	* bfd-in2.h: Regenerate.

	ld/
	* ldexp.c (exp_fold_tree_1) <etree_assign, etree_provide>
	<etree_provided>: Copy expression's `rel_from_abs' flag to the
	link hash.
2018-07-17 20:04:53 +01:00
Maciej W. Rozycki 78da84f994 MIPS/LD/testsuite: Correct mips-elf.exp test ABI/emul/endian arrangement
Similarly to commit 86b24e15c4 ("MIPS/LD/testsuite: Correct
comm-data.exp test ABI/emul/endian arrangement") update the mips-elf.exp
test script to:

- correctly select emulations for targets using non-traditional MIPS
  emulations,

- correctly select ABIs for targets that do not support all of them,

- use the default endianness selection where possible to benefit targets
  that support only one,

- simplify test invocation by providing ABI-specific `run_dump_test'
  wrappers, specifically `run_dump_test_o32', `run_dump_test_n32',
  `run_dump_test_n64' and `run_dump_test_eabi', which remove the need to
  use conditionals across the Expect script or to repeat ABI-specific
  GAS and LD flags with each invocation,

removing numerous test failures for `mips-sgi-irix6', `mips64-openbsd',
`mips64el-openbsd' and `mips64el-ps2-elf' targets and broadening
coverage for several MIPS targets.

There are some new failures for the `mips64el-ps2-elf' target with tests
that were not previously run for that target:

FAIL: MIPS16 link branch to absolute expression (n32)
FAIL: MIPS16 link branch to absolute expression 1 (n32)
FAIL: MIPS16 link branch to absolute expression 2 (n32)
FAIL: microMIPS link branch to absolute expression (n32)
FAIL: MIPS ELF got reloc n32
FAIL: MIPS ELF xgot reloc n32
FAIL: undefined weak symbol overflow (n32)
FAIL: R_MIPS16_HI16 and R_MIPS16_LO16 relocs n32
FAIL: ld-mips-elf/attr-gnu-4-0-n32-ph
FAIL: ld-mips-elf/attr-gnu-4-1-n32-ph
FAIL: ld-mips-elf/attr-gnu-4-2-n32-ph
FAIL: ld-mips-elf/attr-gnu-4-3-n32-ph
FAIL: MIPSr6 JALR reloc unaligned/cross-mode link test (n32)

which are mostly due to dump discrepancies caused by mapping differences
coming from the default linker scripts used by these test cases, or
sometimes because of the specific MIPS processor architecture recorded
in the ELF file taking precedence over the general MIPS ISA level also
recorded.  Finally, the R_MIPS16_HI16/R_MIPS16_LO16 relocation test
failure is a preexisting issue with the IRIX style emulation.

These failures will have to be addressed separately.

	ld/
	* testsuite/ld-mips-elf/mips-elf.exp (run_dump_test_abi)
	(run_dump_test_o32, run_dump_test_n32, run_dump_test_n64)
	(run_dump_test_eabi): New procedures.
	(has_newabi, has_elf32): Remove variables.
	(has_abi): New associative array variable.
	(abi_asflags, abi_ldflags): Update settings across targets.
	(irixemul): New variable.
	Replace `run_dump_test' calls where applicable throughout with
	`run_dump_test_o32', `run_dump_test_n32', `run_dump_test_n64'
	and `run_dump_test_eabi' as appropriate.  Remove explicit
	passing of `abi_asflags' and `abi_ldflags'.  Use `noarch' for
	tests that require their own architecture setting.  Force the
	big endianness for tests that require it.  Select the endianness
	required for `objdump invocation with the `reloc-2' test.
	Conditionalize tests run via `run_ld_link_tests' on the ABI
	required and use the ABI list from the `has_abi' array where
	appropriate.
	* testsuite/ld-mips-elf/attr-gnu-4-0-n32-ph.d: Remove ABI and
	endianness selection options from `ld' and `source' tags.  Relax
	output format matching.
	* testsuite/ld-mips-elf/attr-gnu-4-0-n64-ph.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-1-n32-ph.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-1-n64-ph.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-2-n32-ph.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-2-n64-ph.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-3-n32-ph.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-3-n64-ph.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d: Remove
	ABI and endianness selection options from `as', `ld', `source'
	tags, and also the `-march=from-abi' option.  Remove the `as'
	tag where it would become empty.
	* testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d:
	Likewise.
	* testsuite/ld-mips-elf/bal-jalx-addend-micromips.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-addend-n32.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-addend-n64.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-addend.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d:
	Likewise.
	* testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d:
	Likewise.
	* testsuite/ld-mips-elf/bal-jalx-local-micromips.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-local-n32.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-local-n64.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-local.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d:
	Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d:
	Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d:
	Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n32.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n64.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-micromips.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-n32.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic-n64.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-pic.d: Likewise.
	* testsuite/ld-mips-elf/branch-absolute-addend-n32.d: Likewise.
	* testsuite/ld-mips-elf/branch-absolute-addend-n64.d: Likewise.
	* testsuite/ld-mips-elf/branch-absolute-addend.d: Likewise.
	* testsuite/ld-mips-elf/branch-absolute-n32.d: Likewise.
	* testsuite/ld-mips-elf/branch-absolute-n64.d: Likewise.
	* testsuite/ld-mips-elf/branch-absolute.d: Likewise.
	* testsuite/ld-mips-elf/dyn-sec64.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame1-n32.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame2-n32.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-got-n32-embed.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-got-n32.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-got-n64-embed.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-got-n64-irix.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-got-n64.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-xgot-n32-embed.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-xgot-n32.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-xgot-n64-embed.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-xgot-n64-irix.d: Likewise.
	* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: Likewise.
	* testsuite/ld-mips-elf/emit-relocs-1.d: Likewise.
	* testsuite/ld-mips-elf/got-dump-2.d: Likewise.
	* testsuite/ld-mips-elf/got-page-2.d: Likewise.
	* testsuite/ld-mips-elf/jal-global-overflow-0.d: Likewise.
	* testsuite/ld-mips-elf/jal-global-overflow-1.d: Likewise.
	* testsuite/ld-mips-elf/jal-local-overflow-0.d: Likewise.
	* testsuite/ld-mips-elf/jal-local-overflow-1.d: Likewise.
	* testsuite/ld-mips-elf/jalbal.d: Likewise.
	* testsuite/ld-mips-elf/jalx-addend-n32.d: Likewise.
	* testsuite/ld-mips-elf/jalx-addend-n64.d: Likewise.
	* testsuite/ld-mips-elf/jalx-addend.d: Likewise.
	* testsuite/ld-mips-elf/jalx-local-n32.d: Likewise.
	* testsuite/ld-mips-elf/jalx-local-n64.d: Likewise.
	* testsuite/ld-mips-elf/jalx-local.d: Likewise.
	* testsuite/ld-mips-elf/jr-to-b-1.d: Likewise.
	* testsuite/ld-mips-elf/jr-to-b-2.d: Likewise.
	* testsuite/ld-mips-elf/lsi-4010-isa.d: Likewise.
	* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d:
	Likewise.
	* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d:
	Likewise.
	* testsuite/ld-mips-elf/micromips-branch-absolute-addend.d:
	Likewise.
	* testsuite/ld-mips-elf/micromips-branch-absolute-n32.d:
	Likewise.
	* testsuite/ld-mips-elf/micromips-branch-absolute-n64.d:
	Likewise.
	* testsuite/ld-mips-elf/micromips-branch-absolute.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-2.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-3.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-1.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-2.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-1.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32-1.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64-1.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-addend.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n32-1.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n32-2.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n32.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n64-1.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n64-2.d:
	Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute-n64.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-absolute.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-addend-2.d: Likewise.
	* testsuite/ld-mips-elf/mips16-branch-addend-3.d: Likewise.
	* testsuite/ld-mips-elf/mips16-hilo-n32.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-0.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-1.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-addend-2.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-addend-6.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-n32-0.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-n32-1.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d: Likewise.
	* testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-0.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-1.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-addend-2.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-addend-6.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-n32-0.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-n32-1.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-n64-sym32-0.d: Likewise.
	* testsuite/ld-mips-elf/mips16e2-pcrel-n64-sym32-1.d: Likewise.
	* testsuite/ld-mips-elf/multi-got-1.d: Likewise.
	* testsuite/ld-mips-elf/multi-got-hidden-1.d: Likewise.
	* testsuite/ld-mips-elf/multi-got-hidden-2.d: Likewise.
	* testsuite/ld-mips-elf/multi-got-no-shared.d: Likewise.
	* testsuite/ld-mips-elf/no-shared-1-n32.d: Likewise.
	* testsuite/ld-mips-elf/no-shared-1-n64.d: Likewise.
	* testsuite/ld-mips-elf/no-shared-1-o32.d: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-2.d: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-3-error.d: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-4-error.d: Likewise.
	* testsuite/ld-mips-elf/pie-n32.d: Likewise.
	* testsuite/ld-mips-elf/pie-n64.d: Likewise.
	* testsuite/ld-mips-elf/pie-o32.d: Likewise.
	* testsuite/ld-mips-elf/rel32-n32.d: Likewise.
	* testsuite/ld-mips-elf/rel32-o32.d: Likewise.
	* testsuite/ld-mips-elf/rel64.d: Likewise.
	* testsuite/ld-mips-elf/relax-jalr-n32.d: Likewise.
	* testsuite/ld-mips-elf/reloc-1-n32.d: Likewise.
	* testsuite/ld-mips-elf/reloc-1-n64.d: Likewise.
	* testsuite/ld-mips-elf/reloc-2.d: Likewise.
	* testsuite/ld-mips-elf/reloc-3-n32.d: Likewise.
	* testsuite/ld-mips-elf/reloc-local-overflow.d: Likewise.
	* testsuite/ld-mips-elf/textrel-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-2.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-micromips.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-mips16.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-r6-2.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-0.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-2.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-0.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-0.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jump-micromips.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jump-mips16.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jump.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-ldpc-0.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-ldpc-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-lwpc-0.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-lwpc-1.d: Likewise.
2018-07-12 20:01:44 +01:00
Maciej W. Rozycki f880fcab1a MIPS/LD/testsuite: Limit reloc 6 tests to DSO targets
Complement commit 500c05ddbe ("MIPS/ld/testsuite: Limit export class
call reloc tests to DSO targets") and also check for target's shared
library support in determining whether to run reloc 6 tests, which
require it.  No changes in results as all targets currently enabled for
NewABI testing support shared libraries.

	ld/
	* testsuite/ld-mips-elf/mips-elf.exp: Limit reloc 6 tests to
	shared library targets.
2018-07-12 20:01:44 +01:00
Maciej W. Rozycki 1cb83cac9a MIPS/BFD: Fix TLS relocation resolution for regular executables
Correct an issue with commit 0f20cc3522 ("TLS support for MIPS"),
<https://sourceware.org/ml/binutils/2005-02/msg00607.html>, where a
condition used to determine whether to use a dynamic symbol for GD, LD
and IE TLS dynamic relocations against a symbol that has been defined
locally has been incorrectly reversed.

It's executables rather than dynamic shared objects where no symbol is
required, because such symbols cannot be preempted and therefore their
values (thread pointer offsets) are fixed at the static link time as is
the associated module ID of the main executable, so the original
condition should have been `shared' instead of `!shared'.  This wrong
condition was then later converted from `!shared' to `!bfd_link_pic',
with commit 0e1862bb40 ("Add output_type to bfd_link_info").

Use the correct `bfd_link_dll' condition then, and adjust code for the
dynamic symbol index possibly being -1 as with symbols that have been
forced local, removing unnecessary dynamic relocations from dynamic
regular executables.  PIE executables are unaffected as the existing
condition excluded them by chance due to the conversion mentioned above.

Adjust test cases accordingly.

	bfd/
	* elfxx-mips.c (mips_tls_got_relocs): Use `bfd_link_dll' rather
	than `!bfd_link_pic' in determining the dynamic symbol index.
	Avoid the index of -1.
	(mips_elf_initialize_tls_slots): Likewise.  Flatten code by
	moving `dyn' to the beginning of the function block.

	ld/
	* testsuite/ld-mips-elf/tlsdyn-o32.d: Update test for dynamic
	relocation removal.
	* testsuite/ld-mips-elf/tlsdyn-o32.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.
2018-07-11 17:44:45 +01:00
Maciej W. Rozycki 9143e72c6d PR ld/22570: MIPS/BFD: Fix TLS relocation resolution for PIE executables
Correct a commit 0e1862bb40 ("Add output_type to bfd_link_info") issue
and use `bfd_link_dll' rather than `bfd_link_pic' in determining whether
to fully resolve GD, LD and IE TLS relocations referring to symbols
locally defined rather than deferring them to the load time by means of
dynamic relocations.

Such symbols cannot be preempted in PIE executables, which are
necessarily PIC, and therefore their values (thread pointer offsets) are
fixed at the static link time as is the associated module ID of the main
executable.

Given the `tlsbin-o32.s' and `tlsdyn-o32.s' sources from our test suite
this removes the absolute TLS relocations from the static:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
1000002c R_MIPS_TLS_TPREL32  *ABS*
10000030 R_MIPS_TLS_DTPMOD32  *ABS*
10000038 R_MIPS_TLS_DTPMOD32  *ABS*

and the dynamic:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
1000002c R_MIPS_TLS_TPREL32  *ABS*
10000038 R_MIPS_TLS_DTPMOD32  *ABS*
10000044 R_MIPS_TLS_DTPMOD32  *ABS*
10000030 R_MIPS_TLS_DTPMOD32  tlsvar_gd
10000034 R_MIPS_TLS_DTPREL32  tlsvar_gd
10000040 R_MIPS_TLS_TPREL32  tlsvar_ie

PIE executable respectively, as reported by `objdump -R', and fills the
corresponding GOT slots with the values expected, as recorded with the
test cases added.  The new output from `objdump -R' is:

DYNAMIC RELOCATION RECORDS (none)

and:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
10000030 R_MIPS_TLS_DTPMOD32  tlsvar_gd
10000034 R_MIPS_TLS_DTPREL32  tlsvar_gd
10000040 R_MIPS_TLS_TPREL32  tlsvar_ie

for the static and the dynamic executable respectively.

2018-07-11  Maciej W. Rozycki  <macro@mips.com>
            Rich Felker  <bugdal@aerifal.cx>

	bfd/
	PR ld/22570
	* elfxx-mips.c (mips_tls_got_relocs): Use `bfd_link_dll' rather
	than `bfd_link_pic' to determine whether dynamic relocations are
	to be produced.
	(mips_elf_initialize_tls_slots): Likewise.

	ld/
	PR ld/22570
	* testsuite/ld-mips-elf/tlsbin-pie-o32.d: New test.
	* testsuite/ld-mips-elf/tlsbin-pie-o32.got: New test.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.d: New test.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.got: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-07-11 17:44:45 +01:00
Alan Modra c7df3df443 Revise "ld testsuite use of notarget"
git commit 624940689a wrongly changed fill.d and fill16.d notarget
entries to xfail, so revert that change and instead replace notarget
with skip.  The two tests are complementary.

This patch also modifies the pr20022 test to use .data, avoiding
xfails on targets that complain about dynamic relocations in .text.
This shows a bug in metag which discards section _foo in pr2022.so.

	* testsuite/ld-elf/hash.d: Comment on mips xfail.
	* testsuite/ld-gc/pr20022b.s: Use .data not .text.
	* testsuite/ld-gc/pr20022.d: Remove xfails.
	* testsuite/ld-scripts/fill.d: Revert most of last patch, but use
	skip rather than notarget.
	* testsuite/ld-scripts/fill16.d: Likewise.
2018-07-11 16:39:04 +09:30
Maciej W. Rozycki 500c05ddbe MIPS/ld/testsuite: Limit export class call reloc tests to DSO targets
Only run MIPS/LD export class call relocation tests with shared library
targets, avoiding:

.../ld/ld-new: -shared not supported

linker errors and removing:

FAIL: MIPS export class call relocation test (o32)

regressions with `mipsel-ps2-elf' and `mips64el-ps2-elf' targets.

	ld/
	* testsuite/ld-mips-elf/mips-elf.exp: Limit export class call
	relocation tests to shared library targets.
2018-07-11 00:57:36 +01:00
Alan Modra be570f0684 xgate testsuite fixes
binutils/
	* testsuite/lib/binutils-common.exp (supports_gnu_unique): Return
	zero for xgate.
ld/
	* testsuite/lib/ld-lib.exp (check_gc_sections_available): Return 0
	for xgate.
	* testsuite/ld-elf/elf.exp: Add xgate to pr21703 xfails.
	* testsuite/ld-elf/shared.exp: Add xgate to pr21703 xfails.
	* testsuite/ld-discard/extern.d: xfail xgate.
	* testsuite/ld-discard/start.d: Likewise.
	* testsuite/ld-discard/static.d: Likewise.
	* testsuite/ld-elf/attributes.d: Likewise.
	* testsuite/ld-elf/compressed1d.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/merge.d: Likewise.
	* testsuite/ld-elf/merge2.d: Likewise.
	* testsuite/ld-elf/merge3.d: Likewise.
	* 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/pr12851.d: Likewise.
	* testsuite/ld-elf/pr12975.d: Likewise.
	* testsuite/ld-elf/pr13177.d: Likewise.
	* testsuite/ld-elf/pr13195.d: Likewise.
	* testsuite/ld-elf/pr14156b.d: Likewise.
	* testsuite/ld-elf/pr17550c.d: Likewise.
	* testsuite/ld-elf/pr17550d.d: Likewise.
	* testsuite/ld-elf/pr17615.d: Likewise.
	* testsuite/ld-elf/pr20528a.d: Likewise.
	* testsuite/ld-elf/pr20528b.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/pr349.d: Likewise.
	* testsuite/ld-elf/warn1.d: Likewise.
	* testsuite/ld-elf/warn2.d: Likewise.
	* testsuite/ld-elf/warn3.d: Likewise.
2018-07-10 23:59:59 +09:30
Alan Modra 1594e052d4 xgate cleanup
elf32-xgate.c contains many functions that are only stubs and
elf32-xgate.h contains unused declarations.  While this might be
reasonable for the initial commit of a port with subsequent work
fleshing out the stubs, xgate has only had two minor target specific
patches since the initial commit over six years ago.  The rest of the
changes have been general maintenance work applied to all ELF targets,
and some of this work could have been avoided if the stubs hadn't been
there.  So this patch removes all the stubs.

I've kept the functionality of the old elf32_xgate_add_symbol_hook,
implemented in elf32_xgate_backend_symbol_processing.  Presumably,
that's to set the symbol st_target_internal flag for use in
elf32-m68hc1x.c:elf32_m68hc11_relocate_section.

The empty elf32_xgate_relocate_section meant that xgate had no linker.
Or at least, no linker relocation processing.  Deleting the
elf_backend_relocate_section define means the target will now use the
generic linker reloc processing.  How good that is will depend on the
accuracy of the reloc howtos..

I haven't updated the ld testsuite to xfail tests expected to fail
for generic elf targets.

bfd/
	* elf32-xgate.h: Delete.
	* elf32-xgate.c: Delete unnecessary forward declarations, add two
	that are now needed.
	(xgate_elf_bfd_link_hash_table_create)
	(xgate_elf_bfd_link_hash_table_free)
	(xgate_elf_set_mach_from_flags, struct xgate_scan_param)
	(stub_hash_newfunc, elf32_xgate_add_symbol_hook)
	(elf32_xgate_setup_section_lists, elf32_xgate_size_stubs)
	(elf32_xgate_build_stubs, elf32_xgate_check_relocs)
	(elf32_xgate_relocate_section, _bfd_xgate_elf_set_private_flags)
	(elf32_xgate_post_process_headers): Delete.
	(elf32_xgate_backend_symbol_processing): New function.
	(xgate_elf_ignore_reloc, xgate_elf_special_reloc)
	(_bfd_xgate_elf_print_private_bfd_data): Make static.
	(ELF_TARGET_ID, elf_info_to_howto, elf_backend_check_relocs)
	(elf_backend_relocate_section, elf_backend_object_p)
	(elf_backend_final_write_processing, elf_backend_can_gc_sections)
	(elf_backend_post_process_headers, elf_backend_add_symbol_hook)
	(bfd_elf32_bfd_link_hash_table_create)
	(bfd_elf32_bfd_set_private_flags)
	(xgate_stub_hash_lookup): Don't define.
	(elf_backend_symbol_processing): Define.
	* elf-bfd.h (elf_target_id): Delete XGATE_ELF_DATA.
ld/
	* emulparams/xgateelf.sh (TEMPLATE_NAME) Set to generic.
	(EXTRA_EM_FILE): Set to genelf.
2018-07-10 23:59:07 +09:30
Alan Modra 624940689a ld testsuite use of notarget
Much of the time it is better to use xfail rather than notarget to
hide a testsuite failure no one is planning on fixing.

1) When a target is fixed, an inappropriate xfail results in XPASS
   whereas notarget is silent.  Leaving in an inappropriate notarget
   entry risks the bug reappearing later, silently.
2) Tests might be used as a template for a new test, carrying over
   notarget and/or xfail.  Inappropriate notarget entries are silent.
3) An xfailed test that mysteriously XPASSes might actually indicate a
   bug.

	* testsuite/ld-elf/attributes.d: Use xfail rather than notarget.
	* testsuite/ld-elf/hash.d: Likewise.
	* testsuite/ld-elf/orphan-10.d: Likewise.
	* testsuite/ld-elf/overlay.d: Likewise.
	* testsuite/ld-elf/pr14926.d: Likewise.
	* testsuite/ld-elf/pr17550d.d: Likewise.
	* testsuite/ld-elf/pr19539.d: Likewise.
	* testsuite/ld-elf/pr22319.d: Likewise.
	* testsuite/ld-misc/defsym1.d: Likewise.
	* testsuite/ld-pe/pr19803.d: Likewise.
	* testsuite/ld-scripts/assign-loc.d: Likewise.
	* testsuite/ld-scripts/defined4.d: Likewise.
	* testsuite/ld-scripts/empty-address-1.d: Likewise.
	* testsuite/ld-scripts/empty-address-2a.d: Likewise.
	* testsuite/ld-scripts/empty-address-2b.d: Likewise.
	* testsuite/ld-scripts/fill.d: Likewise.
	* testsuite/ld-scripts/fill16.d: Likewise.
	* testsuite/ld-scripts/pr14962.d: Likewise.
	* testsuite/ld-scripts/pr14962-2.d: Likewise.
	* testsuite/ld-unique/pr21529.d: Likewise.
	* testsuite/ld-elf/compress1a.d: Likewise, and adjust targets.
	* testsuite/ld-elf/compressed1a.d: Likewise.
	* testsuite/ld-elf/compressed1d.d: Likewise.
	* testsuite/ld-elf/compressed1e.d: Likewise.
	* testsuite/ld-elf/eh5.d: Likewise.
	* testsuite/ld-elf/group8a.d: Likewise.
	* testsuite/ld-elf/linkonce2.d: Likewise.
	* testsuite/ld-elf/orphan-9.d: Likewise.
	* testsuite/ld-elf/pr17550a.d: Likewise.
	* testsuite/ld-elf/pr17550b.d: Likewise.
	* testsuite/ld-elf/pr17550c.d: Likewise.
	* testsuite/ld-elf/pr19162.d: Likewise.
	* testsuite/ld-elf/pr21884.d: Likewise.
	* testsuite/ld-gc/pr19167.d: Likewise.
	* testsuite/ld-gc/pr20022.d: Likewise.
	* testsuite/ld-gc/start.d: Likewise.
	* testsuite/ld-elf/orphan-11.d: Delete notarget.
	* testsuite/ld-elf/orphan-12.d: Likewise.
	* testsuite/ld-gc/stop.d: Likewise.
	* testsuite/ld-scripts/empty-address-3a.d: Likewise.
	* testsuite/ld-scripts/empty-address-3b.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64-now.d: Delete duplicate notarget.
	* testsuite/ld-scripts/section-match-1.d: Comment fix.
2018-07-10 23:58:29 +09:30
Maciej W. Rozycki 7153abac62 MIPS/LD/testsuite: Make Linux dumps for n64 GOT relocation tests the default
The current default dumps for n64 GOT relocation tests only work for
IRIX targets really, while the Linux dumps are suitable for non-Linux
targets as well.  Make the Linux dumps the default then and handle the
IRIX ones as a special case.

Define an `irix' variable as a shorthand for `[istarget *-*-irix*]' and
use it for these n64 GOT relocation tests as well as export class call
relocation tests.

	ld/
	* testsuite/ld-mips-elf/elf-rel-got-n64.d: Rename to...
	* testsuite/ld-mips-elf/elf-rel-got-n64-irix.d: ... this.
	* testsuite/ld-mips-elf/elf-rel-got-n64-linux.d: Rename to...
	* testsuite/ld-mips-elf/elf-rel-got-n64.d: ... this.
	* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: Rename to...
	* testsuite/ld-mips-elf/elf-rel-xgot-n64-irix.d: ... this.
	* testsuite/ld-mips-elf/elf-rel-xgot-n64-linux.dd: Rename to...
	* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: ... this.
	* testsuite/ld-mips-elf/mips-elf.exp: Update accordingly.
	Define `irix' as a shorthand for `[istarget *-*-irix*]' and use
	it throughout.
2018-07-10 01:28:46 +01:00
Maciej W. Rozycki 8d4c0995eb MIPS/LD/testsuite: Fix IRIX dumps for n64 GOT relocation tests
Factor in the presence of a `.gnu.attributes' section at the end of the
respective dumps:

Disassembly of section .gnu.attributes:

0000000000000000 <.gnu.attributes>:
   0:	41000000 	bc0f	4 <__dso_displacement+0x4>
   4:	0f676e75 	jal	d9db9d4 <__dso_displacement+0xd9db9d4>
   8:	00010000 	sll	zero,at,0x0
   c:	00070401 	0x70401

and also ignore any trailing output with the IRIX variant of n64 GOT
relocation tests, like already done with the Linux and the embedded
ones, removing:

FAIL: MIPS ELF got reloc n64
FAIL: MIPS ELF xgot reloc n64

LD testsuite regressions with the `mips-sgi-irix6' target.

	ld/
	* testsuite/ld-mips-elf/elf-rel-got-n64.d: Add `#pass' at the
	end.
	* testsuite/ld-mips-elf/elf-rel-xgot-n64.d: Likewise.
2018-07-09 23:43:27 +01:00
Maciej W. Rozycki 4b8377e7db MIPS/BFD: Do not redirect to discarded lazy binding stubs
Correct a MIPS/BFD linker issue with dynamic symbol and corresponding
GOT entry values being redirected to lazy binding stubs where the stubs
section has been discarded by assigning to the `/DISCARD/' output
section in the linker script used.  The issue manifests itself by the
values entered being relative to the absolute section, which is what any
discarded sections are internally assigned in the linker.

For the `stub-dynsym-2.s' piece of code included as a test case with
this change this issue results in the dynamic symbol table and the GOT
looking like:

Symbol table '.dynsym' contains 3 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000010     0 FUNC    GLOBAL DEFAULT  UND bar
     2: 00000000     0 FUNC    GLOBAL DEFAULT  UND foo

Primary GOT:
 Canonical gp value: 00097ff0

 Reserved entries:
   Address     Access  Initial Purpose
  00090000 -32752(gp) 00000000 Lazy resolver
  00090004 -32748(gp) 80000000 Module pointer (GNU extension)

 Global entries:
   Address     Access  Initial Sym.Val. Type    Ndx Name
  00090008 -32744(gp) 00000010 00000010 FUNC    UND bar
  0009000c -32740(gp) 00000000 00000000 FUNC    UND foo

if assembled to regular MIPS code, or:

Symbol table '.dynsym' contains 3 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000d     0 FUNC    GLOBAL DEFAULT  UND bar
     2: 00000001     0 FUNC    GLOBAL DEFAULT  UND foo

Primary GOT:
 Canonical gp value: 00097ff0

 Reserved entries:
   Address     Access  Initial Purpose
  00090000 -32752(gp) 00000000 Lazy resolver
  00090004 -32748(gp) 80000000 Module pointer (GNU extension)

 Global entries:
   Address     Access  Initial Sym.Val. Type    Ndx Name
  00090008 -32744(gp) 0000000d 0000000d FUNC    UND bar
  0009000c -32740(gp) 00000001 00000001 FUNC    UND foo

if assembled to microMIPS code.  Symbol values and GOT entries record
the offset into the inexistent stubs section and the ISA bit rather than
zero, which would be the case if a lazy binding stub was not used for
other reasons, such as the value of the symbol being taken for a purpose
other than making a function call (e.g. an R_MIPS_GOT16 relocation).

Correct the issue by refraining from redirecting symbols to lazy binding
stubs if the stubs section is going to be discarded.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Don't set
	`->needs_lazy_stub' if the stubs output section is the absolute
	section.

	ld/
	* testsuite/ld-mips-elf/stub-dynsym-2.dd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-2.gd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-2.sd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-discard-2.gd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-discard-2.sd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-2.dd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-2.gd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-2.sd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.dd: New
	test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.gd: New
	test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.sd: New
	test.
	* testsuite/ld-mips-elf/stub-dynsym-2.ld: New test linker
	script.
	* testsuite/ld-mips-elf/stub-dynsym-discard-2.ld: New test
	linker script.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-07-09 21:30:44 +01:00
Maciej W. Rozycki 8a8c916960 LD/testsuite: run_dump_test: Report UNSUPPORTED for excluded targets
Bring the LD implementation of `run_dump_test' in line with its binutils
and GAS counterparts and report the UNSUPPORTED status for tests the run
of which has been prevented by means of one or more of `target',
`alltargets' and `notarget' tags.  Define `skip', `anyskip' and `noskip'
tags, which do not report anything for tests that are not run.

The rationale behind this is that we want to have unsupported tests
reported to ensure that they have actually been attempted and have not
been accidentally suppressed.  Then tests which have target-specific
variants that cannot be expressed with a single .d file can make use of
the newly added tags to silently suppress the uninteresting variants.

	ld/
	* testsuite/lib/ld-lib.exp (run_dump_test): Call `unsupported'
	if the target being tested has been excluded by means of one or
	more of `target', `alltargets' and `notarget' tags.  Add support
	for `skip', `anyskip' and `noskip' tags.
2018-07-09 15:50:57 +01:00
Maciej W. Rozycki 8f7fc65182 LD/testsuite: run_dump_test: Use the intended test name ASAP
Bring the LD implementation of `run_dump_test' in line with its binutils
and GAS counterparts and use the intended test name, from the `name' tag
if set, for test status reporting as soon as it is available.

	ld/
	* testsuite/lib/ld-lib.exp (run_dump_test): Move the setting of
	`testname' earlier on and use it for test status reporting.
2018-07-09 15:50:57 +01:00
Alan Modra 61658d78f0 m68hc1* fixes
With config.sub now properly returning m68hc12-unknown-elf rather than
m68hc12-unknown-none, more ELF tests run.  This patch enables
STB_GNU_UNIQUE processing fixing some testsuite failures that probably
no m68hc12 user cares about, and removes some XPASSes.

bfd/
	* elf32-m68hc1x.c (elf32_m68hc11_post_process_headers): Call
	_bfd_elf_post_process_headers.
ld/
	* testsuite/ld-discard/extern.d: Remove m68hc12 xfail.
	* testsuite/ld-discard/start.d: Likewise.
	* testsuite/ld-discard/static.d: Likewise.
2018-07-09 17:27:35 +09:30
Christophe Lyon f5a1cdde80 [ARM] Fix warning cannot find thumb start symbol
In case params.thumb_entry_symbol has its default NULL value, using it
to print a warning in gld${EMULATION_NAME}_finish results in a crash.

Use h->root.string instead which either points to
params.thumb_entry_symbol name or to entry_symbol name.

2018-07-09  Christophe Lyon  <christophe.lyon@linaro.org>

	* emultempl/armelf.em (gld${EMULATION_NAME}_finish): Use the right
	symbol name in case of warning.

Change-Id: Iec61a833c0ad538b1440bf326ba67834c314dd63
2018-07-09 07:47:24 +00:00
Jim Wilson bb11866d6a RISC-V: Add riscv-*-* configure support, and minor cleanup.
bfd/
	* config.bfd (riscv32*-*-*): Renamed from riscv32-*-*.
	(riscv64*-*-*): Likewise.
	(riscv-*-*): Add as an alias for riscv32*-*-*.

	ld/
	* configure.tgt (riscv-*-*): Add as an alias for riscv32*-*-*.
2018-07-05 17:49:11 -07:00
Maciej W. Rozycki a5628fa844 MIPS/LD/testsuite: Use $linux_gnu consistently across `mips-elf.exp'
Replace two remaining spelled-out calls to `[istarget mips*-*-linux*]'
in `mips-elf.exp' with $linux_gnu, which is equivalent.

	ld/
	* testsuite/ld-mips-elf/mips-elf.exp: Replace remaining calls to
	`[istarget mips*-*-linux*]' with $linux_gnu.
2018-07-05 19:44:02 +01:00
H.J. Lu 56ad703d56 x86: Remove x86 ISA properties with empty bits
There is no need to generate x86 ISA properties with empty bits in
linker output.

bfd/

	PR ld/23372
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove x86
	ISA properties with empty bits.

ld/

	PR ld/23372
	* testsuite/ld-i386/i386.exp: Run pr23372a and pr23372b.
	* testsuite/ld-i386/pr23372a.d: New file.
	* testsuite/ld-i386/pr23372a.s: Likewise.
	* testsuite/ld-i386/pr23372b.d: Likewise.
	* testsuite/ld-i386/pr23372b.s: Likewise.
	* testsuite/ld-i386/pr23372c.s: Likewise.
	* testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372a.d: Likewise.
	* testsuite/ld-x86-64/pr23372a.s: Likewise.
	* testsuite/ld-x86-64/pr23372b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372b.d: Likewise.
	* testsuite/ld-x86-64/pr23372b.s: Likewise.
	* testsuite/ld-x86-64/pr23372c.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr23372a, pr23372a-x32,
	pr23372b and pr23372b-x32.
2018-07-05 09:24:18 -07:00
Nick Clifton d8dab05495 Updated Russian, Bulgarian, and Brazilian Portuguese translations for various components of the binutuls.
ld	* po/bg.po: Updated Bulgarian translation.
	* po/pt_BR.po: Updated Brazilian Portuguese translation.

binutils* po/bg.po: Updated Bulgarian translation.

bfd,gas	* po/ru.po: Updated Russian translation.
2018-07-05 12:16:56 +01:00
Alan Modra 4a91d0ba30 Error for mismatched powerpc ABI tags
And report the two input files that are incompatible rather than
reporting that an input file is incompatible with the output.

bfd/
	* elf-bfd.h (_bfd_elf_ppc_merge_fp_attributes): Update prototype.
	* elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): Return error
	on mismatch.  Remove "warning: " from messages.  Track last bfd
	used to set tags.
	(ppc_elf_merge_obj_attributes): Likewise.  Handle status from
	_bfd_elf_ppc_merge_fp_attributes.
	* elf64-ppc.c (ppc64_elf_merge_private_bfd_data): Handle status
	from _bfd_elf_ppc_merge_fp_attributes.
ld/
	* testsuite/ld-powerpc/attr-gnu-4-12.d: Update expected output.
	* testsuite/ld-powerpc/attr-gnu-4-13.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-21.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-23.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-31.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-32.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-8-23.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-12-21.d: Likewise.
2018-07-05 10:21:37 +09:30
H.J. Lu 94d401b8b8 ld: Set non_ir_ref_regular for --undefined SYMBOL
Set non_ir_ref_regular to TRUE for symbols forced into the output file
so that they won't be removed by garbage collection with LTO.

	PR ld/23309
	* ldlang.c (insert_undefined): Set non_ir_ref_regular to TRUE.
	* plugin.c (is_visible_from_outside): Don't scan entry_symbol.
	* testsuite/ld-plugin/pr23309.c: New file.
	* testsuite/ld-plugin/pr23309.d: Likewise.
2018-07-04 06:29:13 -07:00
H.J. Lu b14b7ff14f ld: Properly display default for -z separate-code
Check DEFAULT_LD_Z_SEPARATE_CODE to display default for -z separate-code.

	PR ld/23358
	* lexsup.c (elf_shlib_list_options): Properly display default
	for -z separate-code.
2018-07-04 06:22:51 -07:00
Maciej W. Rozycki 30e5322741 MIPS/LD/testsuite: Fix a typo in PR ld/21334 test name
ld/
	* testsuite/ld-mips-elf/mips-elf.exp: Fix a typo in PR ld/21334
	test name.
2018-07-02 23:57:21 +01:00
H.J. Lu b638b5d57f x86-64: Clear the R_X86_64_converted_reloc_bit bit
We need to clear the R_X86_64_converted_reloc_bit bit after setting it
to avoid leaking it out by --emit-relocs.

bfd/

	PR ld/23324
	* elf64-x86-64.c (elf_x86_64_relocate_section): Clear the
	R_X86_64_converted_reloc_bit bit.

ld/

	PR ld/23324
	* testsuite/ld-x86-64/pr23324.s: New file.
	* testsuite/ld-x86-64/pr23324a.d: Likewise.
	* testsuite/ld-x86-64/pr23324b.d: Likewise.
2018-07-02 13:08:09 -07:00
Thomas Preud'homme c0c468d562 [ARM] Update bfd's Tag_CPU_arch knowledge
BFD's bfd_get_mach () function returns a bfd specific value representing
the architecture of the target which is populated from the Tag_CPU_arch
build attribute value of that target. Among other users of that
interfacem, objdump which uses it to print the architecture version of
the binary being examinated and to decide what instruction is available
if run with "-m arm" via its own mapping from bfd_mach_arm_X values to
feature bits available.

However, both BFD and objdump's most recent known architecture is
Armv5TE. When encountering a newer architecture bfd_get_mach will return
bfd_mach_arm_unknown. This is unfortunate since objdump uses that value
to allow all instructions on all architectures which is already what it
does by default, making the "-m arm" trick useless.

This patch updates BFD and objdump's knowledge of Arm architecture
versions up to the latest Armv8-M Baseline and Mainline, Armv8-R and
Armv8.4-A architectures. Since several architecture versions (eg. 8.X-A)
share the same Tag_CPU_arch build attribute value and
bfd_mach_arm values, the mapping from bfd machine value to feature bits
need to return the most featureful feature bits that would yield the
given bfd machine value otherwise some instruction would not disassemble
under "-m arm" mode. The patch rework that mapping to make this clearer
and simplify writing the mapping rules. In particular, for simplicity
all FPU instructions are allowed in all cases.

Finally, the patch also rewrite the cpu_arch_ver table in GAS to use the
TAG_CPU_ARCH_X macros rather than hardcode their value.

2018-07-02  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* archures.c (bfd_mach_arm_5TEJ, bfd_mach_arm_6, bfd_mach_arm_6KZ,
	bfd_mach_arm_6T2, bfd_mach_arm_6K, bfd_mach_arm_7, bfd_mach_arm_6M,
	bfd_mach_arm_6SM, bfd_mach_arm_7EM, bfd_mach_arm_8, bfd_mach_arm_8R,
	bfd_mach_arm_8M_BASE, bfd_mach_arm_8M_MAIN): Define.
	* bfd-in2.h: Regenerate.
	* cpu-arm.c (arch_info_struct): Add entries for above new
	bfd_mach_arm values.
	* elf32-arm.c (bfd_arm_get_mach_from_attributes): Add Tag_CPU_arch to
	bfd_mach_arm mapping logic for pre Armv4 and Armv5TEJ and later
	architectures.  Force assert failure for any new Tag_CPU_arch value.

gas/
	* config/tc-arm.c (cpu_arch_ver): Use symbolic TAG_CPU_ARCH macros
	rather than hardcode their values.

ld/
	* arm-dis.c (select_arm_features): Fix typo in heading comment.  Allow
	all FPU features and add mapping from new bfd_mach_arm values to
	allowed CPU feature bits.

opcodes/
	* testsuite/ld-arm/tls-descrelax-be8.d: Add architecture version in
	expected result.
	* testsuite/ld-arm/tls-descrelax-v7.d: Likewise.
	* testsuite/ld-arm/tls-longplt-lib.d: Likewise.
	* testsuite/ld-arm/tls-longplt.d: Likewise.
2018-07-02 11:22:20 +01:00