Commit Graph

4549 Commits

Author SHA1 Message Date
H.J. Lu fd7f5a211a x86: Update PR gas/26263 linker tests
Update and run PR gas/26263 linker tests for all x86 ELF targets to
accept any program header layout.

	PR gas/26263
	* testsuite/ld-i386/pr26263.d: Updated.
	* testsuite/ld-x86-64/pr26263.d: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run gas/26263 test for all ELF
	targets.

(cherry picked from commit 98b3697bcdedb92739d8feb9b881efdd70fd40d3)
2020-07-20 05:02:51 -07:00
H.J. Lu 52da8d36c6 x86: Change PLT32 reloc against section to PC32
Commit 292676c1 resolved PLT32 reloc aganst local symbol to section.
Since PLT32 relocation must be against symbols, turn such PLT32
relocation into PC32 relocation.

gas/

	PR gas/26263
	* config/tc-i386.c (i386_validate_fix): Change PLT32 reloc
	against section to PC32 reloc.
	* testsuite/gas/i386/relax-5.d: Updated.
	* testsuite/gas/i386/x86-64-relax-4.d: Likewise.

ld/

	PR gas/26263
	* testsuite/ld-i386/i386.exp: Run PR gas/26263 test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr26263.d: New file.
	* testsuite/ld-x86-64/pr26263.d: Likewise.
	* testsuite/ld-x86-64/pr26263.s: Likewise.

(cherry picked from commit 2585b7a5ce5830e60a089aa2316a329558902f0c)
2020-07-19 11:30:20 -07:00
Alan Modra d349c8e245 Power10 stub selection
This patch better supports mixing of power10 and non-power10 code,
as might be seen in a cpu-optimized library using ifuncs to select
functions optimized for a given cpu.  Using -Wl,--no-power10-stubs
isn't that good in this situation since non-power10 notoc stubs are
slower and larger than the power10 variants, which you'd like to use
on power10 code paths.

With this change, power10 pc-relative code that makes calls marked
@notoc uses power10 stubs if stubs are necessary, and other calls use
non-power10 instructions in stubs.  This will mean that if gcc is
generating code for -mcpu=power10 but with pc-rel disabled then you'll
get the older stubs even on power10 (unless you force with
-Wl,--power10-stubs).  That shouldn't be too big a problem: stubs that
use r2 are reasonable.  It's just the ones that set up addressing
using "mflr 12; bcl 20,31,.+4; mflr 11; mtlr 12" that should be
avoided if possible.

bfd/
	* elf64-ppc.c (struct ppc_link_hash_table): Add has_power10_relocs.
	(select_alt_stub): New function.
	(ppc_get_stub_entry): Use it here.
	(ppc64_elf_check_relocs): Set had_power10_relocs rather than
	power10_stubs.
	(ppc64_elf_size_stubs): Clear power10_stubs here instead.  Don't
	merge notoc stubs with other varieties when power10_stubs is "auto".
	Instead dup the stub hash table entry.
	(plt_stub_size, ppc_build_one_stub, ppc_size_one_stub): Adjust
	tests of power10_stubs.
ld/
	* emultempl/ppc64elf.em (power10-stubs): Accept optional "auto" arg.
	* ld.texi (power10-stubs): Update.
	* testsuite/ld-powerpc/callstub-1.d: Force --power10-stubs.
	* testsuite/ld-powerpc/callstub-2.d: Relax branch offset comparison.
	* testsuite/ld-powerpc/callstub-4.d: New test.
	* testsuite/ld-powerpc/notoc.d: Force --no-power10-stubs.
	* testsuite/ld-powerpc/notoc3.d,
	* testsuite/ld-powerpc/notoc3.s,
	* testsuite/ld-powerpc/notoc3.wf: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run new tests.  Pass
	--no-power10-stubs for notoc link.

(cherry picked from commit e10a07b32dc1faed25b5bbcbbc47d68e2ff537b9)
2020-07-19 12:31:15 +09:30
Hans-Peter Nilsson 131af83de3 mmix bfd: fix bfd_assert for R_MMIX_PUSHJ_STUBBABLE against undef'd symbol
Spotted when inspecting gcc testsuite logs, but this already is
covered by the ld-mmix testsuite, it's just that the assert is ignored
since the regexp match is for a substring and not anchored.

With the anchors added but not the bugfix, the ld.log shows that the
asserts cause a non-match as intended:

Executing on host: sh -c {./ld-new   -LX/src/ld/testsuite/ld-mmix  -m elf64mmix -o tmpdir/dump tmpdir/undef-2.o tmpdir/start.o  2>&1}  /dev/null dump.tmp (timeout = 300)
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: tmpdir/undef-2.o:(.text+0x0): undefined reference to `undefd'
failed with: <./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: tmpdir/undef-2.o:(.text+0x0): undefined reference to `undefd'>, expected: <\A[^\n\r]*undefined reference to `undefd'\Z>
FAIL: ld-mmix/undef-2

Gone with the fix of course, leaving just the intended "undefined
reference" line.

I'm not going to add anchors manually for all the "error:" strings in
the test-suite, not even in the mmix parts.  Sorry, but I'll just do
it for *these* specific undefined-reference tests.

Just a thought: maybe the run_dump_test "error:" string should
*automatically* get anchor marks prepended and appended for a single
line match as in the patch, "\A[^\n\r]*" prepended and \Z appended
unless either anchor mark or \r or \n is present in the regexp?

Committed.

bfd:
	* elf64-mmix.c (mmix_elf_relax_section): Improve accounting for
	R_MMIX_PUSHJ_STUBBABLE relocs against undefined symbols.

ld/testsuite:
	* testsuite/ld-mmix/undef-1.d, testsuite/ld-mmix/undef-1m.d,
	testsuite/ld-mmix/undef-2.d, testsuite/ld-mmix/undef-2m.d: Add
	start- and end-anchors to error-string to match just a
	single-line error-message.

(cherry picked from commit a8a48c756c0da3a49008662e14ae582764ddd0bb)
2020-07-15 20:16:27 +02:00
Alan Modra d6fdc51f9e powerpc garbage collect test
ld's garbage collection test on powerpc64 catered for old compilers
(pre -mcmodel=medium support), setting options that caused the test to
fail.  Which meant the test wasn't really testing anything.  Get rid
of that old compiler support, and avoid -fPIE fails on ppc32.

	* testsuite/ld-gc/gc.exp: Don't set -mminimal-toc for powerpc64,
	and remove powerpc64 xfail.  Use -fno-PIE for ppc32.

(cherry picked from commit c560184eb2074570988c498aaae494d0c4b00328)
2020-07-13 23:41:57 +09:30
Alan Modra 3d186ccca3 pr18841 tests on powerpc64
The PR18841 test does cross-module calls from within an ifunc
resolver, which is nasty, and not supported in general since the
called function may not be relocated.  In this case the called
function (zoo) is just a stub so doesn't need relocating, but on ppc64
the function descriptor for zoo in the executable won't be relocated
at the time the shared library ifunc resolver runs.  That means the
test will fail if your compiler generates PIEs by default.

	PR 18841
	* testsuite/ld-ifunc/ifunc.exp: Run pr18841 tests non-pie.

(cherry picked from commit 470cd0faa7f433b47944683eee4fc3dad6ef7cdf)
2020-07-13 23:41:01 +09:30
Nick Clifton baebeaa3b7 Change fatal errors about linking in executable files to simple warnings.
* ldelf.c (ldelf_after_open): Change fatal errors about linking in
	executable files to simple warnings.
2020-07-13 14:36:50 +01:00
Alan Modra ae9defaaf2 Document powerpc64 ld options
* ld.texi (PowerPC64 ELF64): Document --no-inline-optimize,
	--power10-stubs and --no-power10-stubs.

(cherry picked from commit d882c9889312591a8bfdbc1740938780cd4032bd)
2020-07-10 17:03:05 +09:30
Alan Modra 8c1ec83fba PowerPC64 ld --no-power10-stubs
Needed for libraries that use ifuncs or other means to support
cpu-optimized versions of functions, some power10, some not, and those
functions make calls using linkage stubs.

bfd/
	* elf64-ppc.h (struct ppc64_elf_params): Add power10_stubs.
	* elf64-ppc.c (struct ppc_link_hash_table): Delete
	power10_stubs.
	(ppc64_elf_check_relocs): Adjust setting of power10_stubs.
	(plt_stub_size, ppc_build_one_stub, ppc_size_one_stub): Adjust
	uses of power10_stubs.
ld/
	* emultempl/ppc64elf.em (params): Init new field.
	(enum ppc64_opt): Add OPTION_POWER10_STUBS and OPTION_NO_POWER10_STUBS.
	(PARSE_AND_LIST_LONGOPTS): Support --power10-stubs and
	--no-power10-stubs.
	(PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Likewise.
	* testsuite/ld-powerpc/callstub-3.d: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.

(cherry picked from commit d3b10ee787216d304a858246656ed2fdaecdfd93)
2020-07-10 12:09:58 +09:30
Nick Clifton b3eaec43b9 Updated translations for various binutils sub-directories 2020-07-06 10:40:44 +01:00
Nick Clifton d63813ff85 Set version to 2.34.90 and regenerate files 2020-07-04 10:41:03 +01:00
Nick Clifton b115b9fd3c Add markers for binutils 2.35 branch 2020-07-04 10:16:22 +01:00
Alan Modra b657622c3e Re: Change readelf's display of symbol names
Fixes some fallout from git commit 0942c7ab94.

	PR 26028
gas/
	* testsuite/gas/ia64/unwind-ilp32.d: Add -T to readelf options.
gold/
	* testsuite/Makefile.am (file_in_many_sections.stdout): Add -W
	to readelf options.
	* testsuite/Makefile.in: Regenerate.
ld/
	* testsuite/ld-arm/arm-elf.exp (vxworks1): Pass --wide to readelf
	when dumping relocs.
	* testsuite/ld-i386/i386.exp (vxworks1): Likewise.
	* testsuite/ld-sh/sh-vxworks.exp (vxworks1): Likewise.
	* testsuite/ld-sparc/sparc.exp (vxworks1): Likewise.
	* testsuite/ld-arm/vxworks1.rd: Adjust to suit.
	* testsuite/ld-i386/vxworks1.rd: Adjust.
	* testsuite/ld-sh/vxworks1.rd: Adjust.
	* testsuite/ld-sparc/vxworks1.rd: Adjust.
2020-07-03 17:15:16 +09:30
Nick Clifton 0942c7ab94 Change readelf's display of symbol names (when not in --wide mode) so that if they are going to be truncated then "[...]" is displayed at the end. Add a comment line option to disable this enhancement and restore the old behaviour.
PR 26028
binutils* readelf.c (print_symbol): Handle truncation of symbol names.
	(options): Add -T/--silent-truncation option.
	(parse_args): Handle the option.
	(print_dynamic_symbol): Correct calculation of width available to
	display symbol name.
	* doc/binutils.texi: Document the -T option to readelf.
	* NEWS: Mention the new feature.

gas	* testsuite/gas/ia64/group-2.d: Add -T option to readelf
	command line.
	* testsuite/gas/ia64/unwind.d: Likewise.
	* testsuite/gas/mmix/bspec-1.d: Likewise.
	* testsuite/gas/mmix/bspec-2.d: Likewise.
	* testsuite/gas/mmix/comment-1.d: Likewise.
	* testsuite/gas/tic6x/scomm-directive-4.d: Likewise.

ld	* testsuite/ld-powerpc/powerpc.exp: Add -T option to readelf
	command line when running some tests.
	* testsuite/ld-arm/arm-elf.exp: Likewise.
	* testsuite/ld-mips-elf/mips-elf.exp: Likewise.
	* testsuite/ld-mmix/local1.d: Likewise.
	* testsuite/ld-mmix/local3.d: Likewise.
	* testsuite/ld-mmix/local5.d: Likewise.
	* testsuite/ld-mmix/local7.d: Likewise.
	* testsuite/ld-powerpc/powerpc.exp: Likewise.
2020-07-02 11:30:52 +01:00
H.J. Lu bbd19b19e4 Remove x86 NaCl target support
NaCl has been deprecated:

https://developer.chrome.com/native-client/migration

and NaCl will completely disappear in 2021:

https://lists.llvm.org/pipermail/llvm-dev/2020-April/141107.html

Remove x86 NaCl target support from bfd, binutils, gas and ld.

bfd/

	* archures.c (bfd_mach_i386_nacl): Removed.
	(bfd_mach_i386_i386_nacl): Likewise.
	(bfd_mach_x86_64_nacl): Likewise.
	(bfd_mach_x64_32_nacl): Likewise.
	* config.bfd: Remove *-*-nacl* targets.
	* configure.ac: Remove x86 NaCl target vectors.
	* cpu-i386.c (bfd_arch_i386_onebyte_nop_fill): Removed.
	(bfd_x64_32_nacl_arch): Likewise.
	(bfd_x86_64_nacl_arch): Likewise.
	(bfd_i386_nacl_arch): Likewise.
	(bfd_x64_32_arch_intel_syntax): Updated.
	* elf32-i386.c: Don't include "elf-nacl.h".
	(elf_i386_nacl_plt): Removed.
	(elf_i386_nacl_plt0_entry): Likewise.
	(elf_i386_nacl_plt_entry): Likewise.
	(elf_i386_nacl_pic_plt0_entry): Likewise.
	(elf_i386_nacl_pic_plt_entry): Likewise.
	(elf_i386_nacl_eh_frame_plt): Likewise.
	(elf_i386_nacl_plt): Likewise.
	(elf32_i386_nacl_elf_object_p): Likewise.
	(elf_i386_get_synthetic_symtab): Updated.
	(elf_i386_link_setup_gnu_properties): Likewise.
	* elf64-x86-64.c: Don't include "elf-nacl.h".
	(elf_x86_64_nacl_plt): Removed.
	(elf64_x86_64_nacl_elf_object_p): Likewise.
	(elf_x86_64_nacl_plt0_entry): Likewise.
	(elf_x86_64_nacl_plt_entry): Likewise.
	(elf_x86_64_nacl_eh_frame_plt): Likewise.
	(elf_x86_64_nacl_plt): Likewise.
	(elf32_x86_64_nacl_elf_object_p): Likewise.
	(elf_x86_64_get_synthetic_symtab): Updated.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Likewise.
	* targets.c: Remove x86 NaCl target vectors.
	* bfd-in2.h: Regenerated.
	* configure: Likewise.

binutils/

	* NEWS: Mention x86 NaCl target support removal.
	* dwarf.c (init_dwarf_regnames_by_bfd_arch_and_mach): Remove
	x86 NaCl target support.
	* testsuite/binutils-all/elfedit-1.d: Likewise.
	* testsuite/binutils-all/i386/i386.exp: Likewise.
	* testsuite/binutils-all/x86-64/objects.exp: 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/x86-64.exp: Likewise.

gas/

	* NEWS: Mention x86 NaCl target support removal.
	* config/tc-i386.c: Remove x86 NaCl target support.
	* config/tc-i386.h: Likewise.
	* configure.tgt: Likewise.
	* testsuite/gas/i386/i386.exp: Likewise.
	* testsuite/gas/i386/iamcu-1.d: Likewise.
	* testsuite/gas/i386/iamcu-2.d: Likewise.
	* testsuite/gas/i386/iamcu-3.d: Likewise.
	* testsuite/gas/i386/iamcu-4.d: Likewise.
	* testsuite/gas/i386/iamcu-5.d: Likewise.
	* testsuite/gas/i386/k1om.d: Likewise.
	* testsuite/gas/i386/l1om.d: Likewise.

ld/

	* Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_nacl.c,
	eelf32_x86_64_nacl.c, eelf_x86_64_nacl.c.
	Remove x86 NaCl dep files.
	* NEWS: Mention x86 NaCl target support removal.
	* configure.tgt: Remove x86 NaCl target support.
	* testsuite/ld-elf/binutils.exp: Likewise.
	* testsuite/ld-elf/elf.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp: Likewise.
	* testsuite/ld-i386/align-branch-1.d: Likewise.
	* testsuite/ld-i386/export-class.exp: Likewise.
	* testsuite/ld-i386/i386.exp: Likewise.
	* testsuite/ld-i386/load1.d: Likewise.
	* testsuite/ld-i386/pie1.d: Likewise.
	* testsuite/ld-i386/pr12570a.d: Likewise.
	* testsuite/ld-i386/pr12570b.d: Likewise.
	* testsuite/ld-i386/pr19636-1d.d: Likewise.
	* testsuite/ld-i386/pr19636-1l.d: Likewise.
	* testsuite/ld-i386/pr19636-2c.d: Likewise.
	* testsuite/ld-i386/pr19636-2d.d: Likewise.
	* testsuite/ld-i386/pr19636-2e.d: Likewise.
	* testsuite/ld-i386/pr20244-1a.d: Likewise.
	* testsuite/ld-i386/pr20244-1b.d: Likewise.
	* testsuite/ld-i386/pr20244-2a.d: Likewise.
	* testsuite/ld-i386/pr20244-2b.d: Likewise.
	* testsuite/ld-i386/pr20244-2c.d: Likewise.
	* testsuite/ld-i386/pr20244-4a.d: Likewise.
	* testsuite/ld-i386/pr20244-4b.d: Likewise.
	* testsuite/ld-i386/pr21884.d: Likewise.
	* testsuite/ld-ifunc/binutils.exp: Likewise.
	* testsuite/ld-ifunc/ifunc-10-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-10-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-11-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-11-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-12-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-12-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-13-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-13-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14c-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14c-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14d-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14d-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14e-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14e-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14f-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14f-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-15-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-15-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-20-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-20-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5r-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-8-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-8-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-9-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-9-x86-64.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-x86-64/align-branch-1.d: Likewise.
	* testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
	* testsuite/ld-x86-64/line.exp: Likewise.
	* testsuite/ld-x86-64/load1a.d: Likewise.
	* testsuite/ld-x86-64/load1b.d: Likewise.
	* testsuite/ld-x86-64/load1c.d: Likewise.
	* testsuite/ld-x86-64/load1d.d: Likewise.
	* testsuite/ld-x86-64/pie3.d: Likewise.
	* testsuite/ld-x86-64/pr18160.d: Likewise.
	* testsuite/ld-x86-64/pr19013-x32.d: Likewise.
	* testsuite/ld-x86-64/pr19013.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1b.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1h.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
	* testsuite/ld-x86-64/pr21884.d: Likewise.
	* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
	* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
	* testsuite/ld-x86-64/tlsgd10.dd: Likewise.
	* testsuite/ld-x86-64/tlsgd5.dd: Likewise.
	* testsuite/ld-x86-64/tlsgd8.dd: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* emulparams/elf32_x86_64_nacl.sh: Removed.
	* emulparams/elf_i386_nacl.sh: Likewise.
	* emulparams/elf_x86_64_nacl.sh: Likewise.
	* testsuite/ld-i386/emit-relocs-nacl.rd: Likewise.
	* testsuite/ld-i386/load1-nacl.d: Likewise.
	* testsuite/ld-i386/pie1-nacl.d: Likewise.
	* testsuite/ld-i386/plt-nacl.pd: Likewise.
	* testsuite/ld-i386/plt-pic-nacl.pd: Likewise.
	* testsuite/ld-i386/pr17709-nacl.rd: Likewise.
	* testsuite/ld-i386/pr19636-1d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2c-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2e-nacl.d: Likewise.
	* testsuite/ld-i386/pr19827-nacl.rd: Likewise.
	* testsuite/ld-i386/pr21884-nacl.d: Likewise.
	* testsuite/ld-i386/pr21884-nacl.t: Likewise.
	* testsuite/ld-i386/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbin2-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsnopic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlspic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlspic2-nacl.rd: Likewise.
	* testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1a-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1b-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1c-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1d-nacl.d: Likewise.
	* testsuite/ld-x86-64/pie3-nacl.d: Likewise.
	* testsuite/ld-x86-64/plt-nacl.pd: Likewise.
	* testsuite/ld-x86-64/pr17709-nacl.rd: Likewise.
	* testsuite/ld-x86-64/pr19013-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr19827-nacl.rd: Likewise.
	* testsuite/ld-x86-64/pr21884-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr21884-nacl.t: Likewise.
	* testsuite/ld-x86-64/split-by-file-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin2-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.pd: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic2-nacl.rd: Likewise.
	* Makefile.in: Regenerated.
	* po/BLD-POTFILES.in: Likewise.
2020-06-30 08:56:14 -07:00
Alan Modra fb4a044b5a solaris XPASS ld-elf/group1
* testsuite/ld-elf/group1.d: Don't xfail all solaris targets, just
	ix86 and x86_64.
2020-06-30 14:26:05 +09:30
Alan Modra b9b9b0ef34 Don't xfail nds32 for ld-elf/reloc-discard test
* testsuite/ld-elf/reloc-discard.d: Don't xfail nds32.
2020-06-30 14:26:05 +09:30
Alan Modra 39d050ee50 microblaze-linux XPASS ld-elf/var1
microblaze-linux uses the standard ELF script, microblaze-elf its own
script lacking an input section pattern needed to make this test pass.
Add the missing pattern for .data, in line with most other sections
that do have .* patterns.

	* scripttempl/elfmicroblaze.sc (.data): Add .data.* entry.
	* testsuite/ld-elf/var1.d: Don't xfail microblaze.
2020-06-30 13:32:04 +09:30
H.J. Lu a57f74bb7c tic6x: Call _bfd_elf_add_dynamic_tags
Update tic6x linker tests to expect C6000_DSBT_BASE, C6000_DSBT_SIZE and
C6000_DSBT_INDEX dynamic tags immediately before NULL dynamic tag.

bfd/

	* elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.

ld/

	* testsuite/ld-tic6x/shlib-1.rd: Move C6000_DSBT_BASE,
	C6000_DSBT_SIZE and C6000_DSBT_INDEX dynamic tags to the last.
	* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.
2020-06-29 05:53:01 -07:00
Alan Modra 290a25dc2d x86_64 k1om tests
On x86_64-nacl we currently see
FAIL: Absolute non-overflowing relocs
FAIL: ld-x86-64/protected2-k1om
FAIL: ld-x86-64/protected3-k1om

This limits the tests as per the l1om variants.

	* testsuite/ld-x86-64/abs-k1om.d: Run only on x86_64-*-linux*.
	* testsuite/ld-x86-64/protected2-k1om.d: Likewise.
	* testsuite/ld-x86-64/protected3-k1om.d: Likewise.
2020-06-29 10:04:11 +09:30
Nick Alcock 094e34f221 binutils, ld: work with --disable-libctf
This unfortunately means conditionalizing out all the libctf code, but
the result is not too unbearably ugly, if a bit repetitive.  I have
stubbed out code in the !ENABLE_LIBCTF path to avoid extra redundant
ifdefs where it seems that might be helpful.  (The stubs are not too
disruptive, but I've tried to keep them on one line where possible to
avoid filling up the screen with stubs that nobody would care about.
If this is too much of a coding style violation I can change it.)

Changes since v2: use GCC_ENABLE rather than repeating all the
                  AC_ARG_ENABLE stuff over and over again.

ld/
	* configure.ac [--enable-libctf]: New, default yes.
	Set ENABLE_LIBCTF accordingly.
	* Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* ldlang.c (ctf_output): Conditionalize on ENABLE_LIBCTF.
	(ldlang_open_ctf): Likewise.
	(lang_merge_ctf): Likewise.
	(ldlang_ctf_apply_strsym): Likewise.
	(lang_write_ctf): Likewise.
	(ldlang_write_ctf_late): Likewise.
	(ldlang_open_ctf) [!ENABLE_LIBCTF]: Warn about the presence of CTF
	sections.
	(lang_merge_ctf) [!ENABLE_LIBCTF]: New stub.
	(ldlang_ctf_apply_strsym) [!ENABLE_LIBCTF]: Likewise.
	(lang_write_ctf) [!ENABLE_LIBCTF]: Likewise.
	(ldlang_write_ctf_late) [!ENABLE_LIBCTF]: Likewise.
	* ldelfgen.c (ldelf_emit_ctf_early): Conditionalize on
	ENABLE_LIBCTF.
	(struct ctf_strsym_iter_cb_arg): Likewise.
	(ldelf_ctf_strtab_iter_cb): Likewise.
	(ldelf_ctf_symbols_iter_cb): Likewise.
	(ldelf_examine_strtab_for_ctf): Likewise.
	(ldelf_emit_ctf_early) [!ENABLE_LIBCTF]: New stub.
	(ldelf_examine_strtab_for_ctf) [!ENABLE_LIBCTF]: New stub.

binutils/
	* configure.ac [--enable-libctf]: New, default yes.
	Set ENABLE_LIBCTF accordingly.
	* Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF and LIBCTF_NOBFD.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* objdump.c (usage): Conditionalize portions on ENABLE_LIBCTF.
	(option_values): Likewise.
	(long_options): Likewise.
	(main): Likewise.
	(dump_ctf_indent_lines): Conditionalize out when !ENABLE_LIBCTF.
	(make_ctfsect): Likewise.
	(dump_ctf_archive_member): Likewise.
	(dump_ctf) [ENABLE_LIBCTF]: Likewise.
	(dump_ctf) [!ENABLE_LIBCTF]: New empty stub.
	* readelf.c (options): Conditionalize portions on ENABLE_LIBCTF.
	(usage): Likewise.
	(process_section_contents): Likewise.
	(shdr_to_ctf_sect): Conditionalize out when !ENABLE_LIBCTF.
	(dump_ctf_indent_lines): Likewise.
	(dump_section_as_ctf) [ENABLE_LIBCTF]: Likewise.
2020-06-26 15:56:39 +01:00
Jan Beulich 198e1db737 ld/x86: actually invoke k1om tests
Unlike claimed by the ChangeLog entries added by 7a9068fe16 ("Add
initial Intel K1OM support") these tests did never get enabled.
2020-06-26 16:43:38 +02:00
Pat Bernardi 85f7484a3a m68k: tag floating-point ABI used
This patch adds GNU attribute support to m68k and utilises it to tag the
floating-point calling convention used (hard-float or soft-float). It enables
the linker to ensure linked objects use a consistent floating-point ABI and
allows tools like GDB to infer the ABI used from the ELF file. It is based on
similar work done for PowerPC.

bfd/
	* elf32-m68k.c (m68k_elf_merge_obj_attributes): New function.
	(elf32_m68k_merge_private_bfd_data): Merge GNU attributes.
binutils/
	* readelf.c (display_m68k_gnu_attribute): New function.
	(process_arch_specific): Call display_m68k_gnu_attribute for EM_68K.
gas/
	* config/tc-m68k.c (m68k_elf_gnu_attribute): New function.
	(md_pseudo_table): Handle "gnu_attribute".
	* doc/as.texi: Document GNU attribute for M68K.
include/
	* elf/m68k.h: Add enum for GNU object attribute with floating point
	tag name and values.
ld/
	* testsuite/ld-m68k/attr-gnu-4-0.s: New file.
	* testsuite/ld-m68k/attr-gnu-4-1.s: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-2.s: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-00.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-01.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-02.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-10.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-11.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-12.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-20.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-21.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-22.d: Likewise.
	* testsuite/ld-m68k/m68k.exp: Run the new tests.
2020-06-26 14:42:19 +09:30
H.J. Lu 4bf05d4a90 ld: Correct --dependency-file order
Change ld --help output to

  -d, -dc, -dp                Force common symbols to be defined
  --dependency-file FILE      Write dependency file

instead of

  -d, -dc                     Force common symbols to be defined
  --dependency-file FILE, -dp Write dependency file

	PR ld/26165
	* lexsup.c (ld_options): Correct --dependency-file order.
2020-06-24 06:39:03 -07:00
H.J. Lu 2c8e370829 csky: Don't generate unnecessary dynamic tags
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT.  Don't generate them if there are no
relocation entries for PLT.

bfd/

	PR ld/26083
	* elf32-csky.c (csky_elf_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.

ld/

	PR ld/26083
	* testsuite/ld-csky/tls-ie-v1.d: Updated.
	* testsuite/ld-csky/tls-ie.d: Likewise.
2020-06-24 06:14:28 -07:00
H.J. Lu c679ec98a1 cris: Don't generate unnecessary dynamic tags
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT.  Don't generate them if there are no
relocation entries for PLT.

bfd/

	PR ld/26083
	* elf32-cris.c (elf_cris_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.

ld/

	PR ld/26083
	* testsuite/ld-cris/libdso-15b.d: Updated.
	* testsuite/ld-cris/libdso-1c.d: Likewise.
	* testsuite/ld-cris/libdso-1d.d: Likewise.
	* testsuite/ld-cris/libdso-15c.d: New file.
2020-06-24 04:00:31 -07:00
H.J. Lu 5376d47f66 ld: Set non_ir_ref_regular on source for assignment
We need to set non_ir_ref_regular on the source for assignment to get
the correct LTO resolution:

190 a27be7f4ad90c5ce PREVAILING_DEF real_g

instead of

190 30c3b2d8f967f5ea PREVAILING_DEF_IRONLY real_g

	PR ld/26163
	* ldexp.c (exp_fold_tree_1): Set non_ir_ref_regular on the source
	for assignment.
	* testsuite/ld-plugin/lto.exp: Run ld/26163 test.
	* testsuite/ld-plugin/pr26163a.c: New file.
	* testsuite/ld-plugin/pr26163b.c: Likewise.
2020-06-24 03:56:16 -07:00
Alan Modra a5aae5087c ld --help output
It's best if help message output does not contain tabs, since we don't
know tab stop settings or even if tabs are handled by the output
device.  This reverts some 2020-06-23 changes and fixes the csky help
message.

	* lexsup.c (elf_shlib_list_options): Properly format help message.
	(elf_plt_unwind_list_options): Likewise.
	* emultempl/cskyelf.em (PARSE_AND_LIST_OPTIONS): Likewise.
2020-06-24 20:00:08 +09:30
Roland McGrath f37b21b481 PR 22843: ld, gold: Add --dependency-file option.
gold/
	* options.h (class General_options): Add --dependency-file option.
	* fileread.cc (File_read::files_read): New static variable.
	(File_read::open): Add the file to the files_read list.
	(File_read::record_file_read): New static member function.
	(File_read::write_dependency_file): New static member function.
	* fileread.h (class File_read): Declare them.
	* layout.cc (Layout::read_layout_from_file): Call record_file_read.
	(Close_task_runner::run): Call write_dependency_file if
	--dependency-file was passed.

ld/
	* NEWS: Note --dependency-file.
	* ld.texi (Options): Document --dependency-file.
	* ldlex.h (enum option_values): Add OPTION_DEPENDENCY_FILE.
	* ld.h (ld_config_type): New member dependency_file.
	* lexsup.c (ld_options, parse_args): Parse --dependency-file.
	* ldmain.c (struct dependency_file): New type.
	(dependency_files, dependency_files_tail): New static variables.
	(track_dependency_files): New function.
	(write_dependency_file): New function.
	(main): Call it when --dependency-file was passed.
	* ldfile.c (ldfile_try_open_bfd): Call track_dependency_files.
	(ldfile_open_command_file_1): Likewise.
	* ldelf.c (ldelf_try_needed): Likewise.
	* pe-dll.c (pe_implied_import_dll): Likewise.
2020-06-23 12:01:24 -07:00
Alan Modra 9221725d1f PR26150, Assertion when asm() defines global symbols, -flto and --start-group
If an archive map contains symbols that aren't actually defined by the
indexed element for any reason, then loading that element will leave
the symbol undefined (or common).  This leads to the possibility of
the element being loaded again should the archive be searched again
due to the action of --start-group/--end-group.  The testcase
triggering this problem was an archive containing fat lto objects,
with the archive map incorrectly created by ar rather than gcc-ar.

	PR 26150
	* ldlang.c (ldlang_add_file): Assert that we aren't adding the
	current end of link.next list again too.
	* ldmain.c (add_archive_element): Don't load archive elements
	again that have already been loaded.
2020-06-24 00:50:48 +09:30
Alan Modra c7c970e4c6 Correct bfin XPASSes
bfin-elf and bfin-linux differ.  This patch fixes these:
bfin-linux-uclibc  -XPASS: PR ld/14170
bfin-linux-uclibc  -XPASS: pr17068 link --as-needed lib in group
bfin-linux-uclibc  -XPASS: -Bsymbolic-functions
bfin-linux-uclibc  -XPASS: pr22374 function pointer initialization

	* testsuite/ld-elf/shared.exp (pr14170): Clear xfail for
	bfin-*-linux*.
	(pr17068, symbolic-func.so, pr22374): Likewise.
2020-06-23 11:03:34 +09:30
Nelson Chu 39ff0b8123 RISC-V: Report warning when linking the objects with different priv specs.
We do know some conflicts among different privileged specs.  For linker,
the safest approach is that don't allow the object linked with others which
may cause conflicts.  But this may cause inconvenience since not all objects
with conflicting priv specs are linked will cause problems.  But it is hard
to know the detailed conflict cases for linker, so we probably need a option
to tell linker that we do know there are no conflicts, or we are willing to
take risks to link the objects with conflicted priv specs.  But the option
is still under discussion.

Therefore, we can report warnings rather than errors when linking the objects
with conflicted priv specs.  This not only makes the linker more flexible,
but also warns people that the conflicts may happen.  We also need to update
the output priv spec version once the input priv spec is newer.

	bfd/
	* elfxx-riscv.c (struct priv_spec_t priv_specs[]): Move them from
	opcodes/riscv-opc.c to bfd/elfxx-riscv.c, since we need it in linker.
	(riscv_get_priv_spec_class): Likewise.
	(riscv_get_priv_spec_name): Likewise.
	(riscv_get_priv_spec_class_from_numbers): New function, convert
	the version numbers into string, then call riscv_get_priv_spec_class
	to get the priv spec class.
	* elfxx-riscv.h (riscv_get_priv_spec_class): Move forward declaration
	from include/opcode/riscv.h to bfd/elfxx-riscv.h.
	(riscv_get_priv_spec_name): Likewise.
	(riscv_get_priv_spec_class_from_numbers): New forward declaration.
	(opcode/riscv.h): Include it in the header rather than elfxx-riscv.c.
	* elfnn-riscv.c (riscv_merge_attributes):  Get the priv spec classes
	of input and output objects form their priv spec attributes by
	riscv_get_priv_spec_class_from_numbers.  Report warning rather than
	errors when linking objects with differnet priv spec versions.  We do
	know v1.9.1 may have conflicts to other versions, so report the
	warning, too.  After that, update the output priv spec version to the
	newest one so far.

	gas/
	* config/tc-riscv.c (buf_size, buf): Remove the unused variables.
	(riscv_set_default_priv_spec): Get the priv spec version from the
	priv spec attributes by riscv_get_priv_spec_class_from_numbers.

	include/
	* opcode/riscv.h (riscv_get_priv_spec_class): Move the function
	forward declarations to bfd/elfxx-riscv.h.
	(riscv_get_priv_spec_name): Likewise.

	opcodes/
	* riscv-opc.c: Move the structures and functions to bfd/elfxx-riscv.c.
	* riscv-dis.c: Include elfxx-riscv.h.

	ld/
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Updated.
2020-06-22 10:01:14 +08:00
Alan Modra 0381901e62 Do without ld ENABLE_PLUGINS
Instead, use BFD_SUPPORTS_PLUGINS.

	* ldfile.c: Replace uses of ENABLE_PLUGINS with BFD_SUPPORTS_PLUGINS.
	* ldlang.c: Likewise.
	* ldlang.h: Likewise.
	* ldlex.h: Likewise.
	* ldmain.c: Likewise.
	* lexsup.c: Likewise.
	* plugin.c: Wrap body of file in #if BFD_SUPPORTS_PLUGINS.
	* testplug.c: Likewise.
	* testplug2.c: Likewise.
	* testplug3.c: Likewise.
	* testplug4.c: Likewise.
	* configure.ac (ENABLE_PLUGINS): Don't define AM_CONTITIONAL.
	* Makefile.am: Remove ENABLE_PLUGINS conditionals.
	(PLUGIN_CFLAGS): Don't define.
	(PLUGIN_C, PLUGIN_H, PLUGIN_OBJECT): Likewise.  Substitute all
	uses with plugin file name.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
2020-06-21 22:16:10 +09:30
Alan Modra 348fe36b1d Remove perror from ld_assemble, ld_compile and ld_nm
ERROR should really be reserved for errors in the testsuite framework,
not just normal errors from the tools under test.  Removing use of
perror has been suggested before but without action, over concerns
that some test failures might be missed.  This patch removes uses of
perror in ld_assemble, ld_compile and ld_nm, and updates numerous
places that ignored the result of these functions by inappropriately
returning an "unresolved" test status.  Net result over my large set
of targets look good, in some cases improving the diagnostics, eg:

i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  +FAIL: script
i386-msdos  +FAIL: MRI script
i386-msdos  +FAIL: MEMORY
i386-msdos  +FAIL: MEMORY with symbols

	* testsuite/lib/ld-lib.exp (default_ld_compile): Don't perror on
	a compiler error.
	(default_ld_assemble): Similarly for an assembler error.
	(default_ld_nm): Similarly for an nm error.
	(run_ld_link_tests): Report ld_assemble errors as a fail.
	(check_as_cfi): Remove now unnecessary perror substitution.
	* testsuite/ld-elf/exclude.exp: Report ld_nm error return as test
	fails rather then unresolved.
	* testsuite/ld-gc/gc.exp: Likewise.
	* testsuite/ld-scripts/alignof.exp: Likewise.
	* testsuite/ld-scripts/defined.exp: Likewise.
	* testsuite/ld-scripts/script.exp: Likewise.
	* testsuite/ld-scripts/sizeof.exp: Likewise.
	* testsuite/ld-selective/selective.exp: Likewise.
	* testsuite/ld-scripts/extern.exp: Likewise.  Return on ld_link
	failure.
	* testsuite/ld-elfweak/elfweak.exp: Report compiler errors as
	test unresolved.
	* testsuite/ld-fastcall/fastcall.exp: Report assember errors as
	test fails.
	* testsuite/ld-i386/i386.exp (iamcu_tests): Likewise.
	* testsuite/ld-ia64/line.exp: Likewise.
	* testsuite/ld-mep/mep.exp: Likewise.
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
	* testsuite/ld-nios2/nios2.exp: Likewise.
	* testsuite/ld-scripts/alignof.exp: Likewise.
	* testsuite/ld-x86-64/line.exp: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-scripts/log2.exp: Formatting.
	* testsuite/ld-tic6x/tic6x.exp: Report ld_link errors as a test fail.
2020-06-20 15:53:37 +09:30
Alan Modra b0ee49d21b ecoff testsuite fixes
The aim of this change is to remove a whole lot of "assembly failed"
errors for ecoff targets.

	* testsuite/ld-alpha/alpha.exp: Exclude *ecoff targets.
	* testsuite/ld-elf/binutils.exp: Likewise.
	* testsuite/ld-elf/tls.exp: Likewise.
	* testsuite/ld-elf/tls_common.exp: Likewise.
	* testsuite/ld-scripts/phdrs2.exp: Likewise.
2020-06-20 10:59:11 +09:30
Alan Modra e2201c2a57 SH gas configure and ld tests
All current SH gas targets use BFD.  sh-coff was incorrectly reported
as unsupported.

gas/
	* configure.tgt: Set bfd_gas for all SH targets.
ld/
	* testsuite/ld-sh/sh.exp: Don't run relax tests for non-ELF.
	Fail when ld_assemble fails.  Use elseif to reduce indentation.
2020-06-20 10:56:39 +09:30
Alan Modra e443398846 Re: ld testsuite fixes for alpha
I missed some.

	* testsuite/ld-plugin/pr22983.1.d: Accept st_other notations.
	* testsuite/ld-plugin/pr22983.2.d: Likewise.
	* testsuite/ld-plugin/pr22983.4.d: Likewise.
2020-06-19 12:59:30 +09:30
Alan Modra 2d0a923cc6 ld testsuite fixes for alpha
Some tests failed just due to st_other info, eg. [NOPV], being
emitted by readelf or objdump.  Fix that.  Also since alpha doesn't
support ifunc, don't run the ifunc tests for alpha.

	* testsuite/ld-elf/dynamic-1.rd: Accept st_other notations.
	* testsuite/ld-elf/rdynamic-1.rd: Likewise.
	* testsuite/ld-elf/pr9676.rd: Likewise.
	* testsuite/ld-elf/pr9679.rd: Likewise.
	* testsuite/ld-elfvers/vers30.dsym: Likewise.
	* testsuite/ld-elfvers/vers31.dsym: Likewise.
	* testsuite/ld-plugin/pr22983.3.d: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Exclude alpha.
2020-06-19 10:01:09 +09:30
Alan Modra 5fd104addf Emit a warning when -z relro is unsupported
ld silently accepts -z relro and -z norelro for targets that lack the
necessary GNU_RELRO support.  This patch makes those targets emit a
warning instead, and adds testsuite infrastructure to detect when
relro is unsupported.

binutils/
	* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
	* testsuite/lib/binutils-common.exp (check_relro_support): New proc.
	(run_dump_test): Use check_relro_support to decide whether to pass
	extra ld option "-z norelro".
ld/
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Omit
	-z relro and -z norelro when target support for GNU_RELRO is lacking.
	(gld${EMULATION_NAME}_before_parse): Ignore RELRO default too.
	* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Ignore
	RELRO default when target support for GNU_RELRO is lacking.
	* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
	* testsuite/ld-elf/pr16322.d: xfail when no relro support.
	* testsuite/ld-elf/pr22393-1a.d: Likewise.
	* testsuite/ld-elf/pr22393-1b.d: Likewise.
	* testsuite/ld-elf/shared.exp (pr20995-2.so, pr20995-2): Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_tests): Use check_relro_support
	to decide whether to pass extra ld option "-z norelro".
2020-06-19 09:50:20 +09:30
H.J. Lu 00401e65be ld: Suppress warning for unsupported attribute from older GCC
Suppress warning for unsupported attribute from older GCC:

.../ld/testsuite/ld-elf/pr25754-1a.c:9: warning: 'noclone' attribute directive ignored
.../ld/testsuite/ld-elf/pr25754-1a.c:9: warning: 'noclone' attribute directive ignored
ERROR: .../ld/testsuite/ld-elf/pr25754-1a.c: compilation failed
UNRESOLVED: Build pr25754-1a ( )

	* testsuite/ld-elf/linux-x86.exp (check_pr25749a): Append "-w"
	to cflags.
2020-06-17 07:53:19 -07:00
H.J. Lu 22aa1d5119 ld: Require GCC 5 for Build pr25749-1b (-pie -fPIE)
Before GCC 5, Build pr25749-1b (-pie -fPIE) won't trigger the expected
linker error.

	* testsuite/ld-elf/linux-x86.exp: Require GCC 5 for Build
	pr25749-1b (-pie -fPIE).
2020-06-17 07:39:28 -07:00
Alan Modra 5f89899448 Re: Use __asm__ rather than asm in ld testsuite
* testsuite/ld-elf/pr19553c.c: Replace asm with __asm__.
	* testsuite/ld-elfvers/vers27b.c: Likewise.
2020-06-16 22:44:13 +09:30
Alan Modra 07e7fdfd42 Use __asm__ rather than asm in ld testsuite
* testsuite/ld-elf/pr23428.c: Define _DEFAULT_SOURCE.
	* testsuite/ld-elf/indirect1b.c: Replace asm with __asm__.
	* testsuite/ld-elf/indirect2.c: Likewise.
	* testsuite/ld-elf/indirect3b.c: Likewise.
	* testsuite/ld-elf/indirect4b.c: Likewise.
	* testsuite/ld-elf/pr14323-2.c: Likewise.
	* testsuite/ld-elf/pr18720b.c: Likewise.
	* testsuite/ld-elf/pr23428.c: Likewise.
	* testsuite/ld-elfvsb/common.c: Likewise.
	* testsuite/ld-elfvsb/main.c: Likewise.
	* testsuite/ld-elfvsb/sh1.c: Likewise.
	* testsuite/ld-elfvsb/test.c: Likewise.
	* testsuite/ld-pe/aligncomm-1.c: Likewise.
	* testsuite/ld-pe/aligncomm-2.c: Likewise.
	* testsuite/ld-pe/aligncomm-3.c: Likewise.
	* testsuite/ld-pe/aligncomm-4.c: Likewise.
	* testsuite/ld-plugin/pr23958.c: Likewise.
	* testsuite/ld-size/size-1b.c: Likewise.
	* testsuite/ld-size/size-2b.c: Likewise.
	* testsuite/ld-size/size-3a.c: Likewise.
	* testsuite/ld-size/size-3b.c: Likewise.
	* testsuite/ld-size/size-3c.c: Likewise.
	* testsuite/ld-size/size-4b.c: Likewise.
	* testsuite/ld-size/size-5b.c: Likewise.
	* testsuite/ld-size/size-6a.c: Likewise.
	* testsuite/ld-size/size-7a.c: Likewise.
	* testsuite/ld-size/size-8a.c: Likewise.
	* testsuite/ld-size/size-9b.c: Likewise.
	* testsuite/ld-size/size-10b.c: Likewise.
2020-06-16 22:13:20 +09:30
Alan Modra a435742a7f Really remove tic30-aout support
bfd/
	* aout-tic30.c: Delete file.
	* Makefile.am (BFD32_BACKENDS): Remove aout-tic30.lo.
	(BFD32_BACKENDS_CFILES): Remove aout-tic30.c.
	* config.bfd (c30-*-*aout*, tic30-*-*aout*): Remove entry.
	(xc16x-*-elf): Sort properly.
	* configure.ac: Remove tic30_aout_vec.
	* targets.c: Likewise.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
gas/
	* config/tc-tic30.h: Remove OBJ_AOUT support.
	* configure.tgt: Delete tic30-*-*aout* entry.
ld/
	* emulparams/tic30aout.sh: Delete file.
	* scripttempl/tic30aout.sc: Delete file.
	* Makefile.am: Remove etic30aout.c from ALL_EMULATION_SOURCES and
	delete dependency.
	* configure.tgt: Delete tic30-*-*aout* entry.
	* testsuite/ld-scripts/sane1.d: Delete tic30-*-aout mention.
	* testsuite/ld-scripts/segment-start.d: Likewise.
	* Makefile.in: Regenerate.
	* po/BLD-POTFILES.in: Regenerate.
2020-06-16 15:57:59 +09:30
Max Filippov 7a77f1ac2c xtensa: allow runtime ABI selection
2020-06-15  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (XSHAL_ABI, XTHAL_ABI_UNDEFINED)
	(XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New macros.
	(elf32xtensa_abi): New global variable.
	(xtensa_abi_choice): New function.
	(elf_xtensa_create_plt_entry): Use xtensa_abi_choice instead of
	XSHAL_ABI to select PLT code.

gas/
	* config/tc-xtensa.c (XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New
	macros.
	(elf32xtensa_abi): New declaration.
	(option_abi_windowed, option_abi_call0): New enum constants.
	(md_longopts): Add entries for --abi-windowed and --abi-call0.
	(md_parse_option): Add handlers for --abi-windowed and
	--abi-call0.
	(xtensa_add_config_info): Use xtensa_abi_choice instead of
	XSHAL_ABI to format ABI tag.
	* doc/as.texi (Target Xtensa options): Add --abi-windowed and
	--abi-call0 to the list of options.
	* doc/c-xtensa.texi: Add description for options --abi-windowed
	and --abi-call0.
	* testsuite/gas/xtensa/abi-call0.d: New test definition.
	* testsuite/gas/xtensa/abi-windowed.d: New test definition.
	* testsuite/gas/xtensa/abi.s: New test source.

include/
	* elf/xtensa.h (xtensa_abi_choice): New declaration.

ld/
	* emultempl/xtensaelf.em (XSHAL_ABI): Remove macro definition.
	(XTHAL_ABI_UNDEFINED, XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New
	macros.
	(elf32xtensa_abi): New declaration.
	(xt_config_info_unpack_and_check): Set elf32xtensa_abi if it is
	undefined.  Use xtensa_abi_choice instead of XSHAL_ABI to test
	ABI tag consistency.
	(xtensa_add_config_info): Use xtensa_abi_choice instead of
	XSHAL_ABI to format ABI tag.
	(PARSE_AND_LIST_PROLOGUE): Define OPTION_ABI_WINDOWED,
	OPTION_ABI_CALL0 and declare elf32xtensa_abi.
	(PARSE_AND_LIST_LONGOPTS): Add entries for --abi-windowed and
	--abi-call0.
	(PARSE_AND_LIST_OPTIONS): Add help text for --abi-windowed and
	--abi-call0.
	(PARSE_AND_LIST_ARGS_CASES): Add handlers for --abi-windowed and
	--abi-call0.
	* ld.texi: Add description for options --abi-windowed and
	--abi-call0.
2020-06-15 13:01:30 -07:00
Roland McGrath cae64165f4 gold, ld: Implement -z start-stop-visibility=... option.
gold/
	Implement -z start-stop-visibility=... option.
	* options.h (class General_options): Handle -z start-stop-visibility=.
	(General_options::start_stop_visibility_enum): New public method.
	(General_options::set_start_stop_visibility_enum): New private method.
	(General_options::start_stop_visibility_enum_): New private member.
	* options.cc (General_options::General_options): Add initializer.
	(General_options::finalize): Set this->start_stop_visibility_enum_
	from string value.
	* layout.cc (Layout::define_section_symbols): Use option setting.

bfd/
	* elflink.c (bfd_elf_define_start_stop): Use start_stop_visibility
	field of bfd_link_info.

include/
	* bfdlink.h (struct bfd_link_info): New field start_stop_visibility.

ld/
	* NEWS: Mention -z start-stop-visibility=... option for ELF.
	* ld.texi (Options): Document -z start-stop-visibility=... option.
	* ldmain.c (main): Initialize link_info.start_stop_visibility.
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
	Parse -z start-stop-visibility=... option.
2020-06-15 11:45:02 -07:00
Alan Modra 1298463902 Unnecessary load_lib in ld testsuite
ld-lib.exp is loaded in config/defaults.exp

	* testsuite/ld-scripts/include.exp: Don't load ld-lib.exp.
	* testsuite/ld-scripts/phdrs3.exp: Likewise.
	* testsuite/ld-scripts/rgn-at.exp: Likewise.
	* testsuite/ld-scripts/rgn-over.exp: Likewise.
	* testsuite/ld-scripts/sort.exp: Likewise.
	* testsuite/ld-discard/discard.exp: Likewise.  Use is_elf_format.
2020-06-15 15:07:13 +09:30
Alan Modra ea4b3731ec PR26103 testcase
PR 26103
	* testsuite/ld-linkonce/ref1.s,
	* testsuite/ld-linkonce/ref2.s,
	* testsuite/ld-linkonce/sym1.s,
	* testsuite/ld-linkonce/sym2.s,
	* testsuite/ld-linkonce/sym3.s: New test files.
	* testsuite/ld-linkonce/linkonce.exp: Run tests for PE too.
	Add pr26103 test.  Remove unnecessary load_lib.
2020-06-15 12:11:27 +09:30
Alan Modra cda58d5f97 ld-linkonce test
* testsuite/ld-linkonce/zeroeh_x.s: Rename from x.s.
	* testsuite/ld-linkonce/zeroeh_y.s: Rename from y.s.
	* testsuite/ld-linkonce/zeroehl32.d: Adjust for renaming.  Support
	big-endian output.  Run for powerpc.
2020-06-15 12:08:33 +09:30
Alan Modra 382264181d Run certain ld-plugun lto tests only for ELF
lto-6.c refers to _etext, pr12760b.c has a .gnu.warning section,
the pr23818 test uses readelf, and pr23958.c has a .symver directive.

	* testsuite/ld-plugin/lto.exp (lto_link_tests): Move lto-6,
	pr12760, pr23818 and pr23958 tests to..
	(lto_link_elf_tests): ..here.
2020-06-11 18:22:42 +09:30