Commit Graph

6498 Commits

Author SHA1 Message Date
Nick Clifton ba311c5b10 Have the linker's help text include the default setting of the --hash-style option, if relevent.
PR 25979
	* lexsup.c (elf_shlib_list_options): Include the default value for
	the hash style in the output text.
2020-05-13 10:59:02 +01:00
Alan Modra d5b7ebe806 Regen ld/Makefile.in
Missed from c578f16ef1.
2020-05-12 09:19:26 +09:30
Alan Modra 94ba9882d5 Power10 VSX 32-byte storage access
bfd/
	* elf64-ppc.c (xlate_pcrel_opt): Handle lxvp and stxvp.
opcodes/
	* ppc-opc.c (insert_xtp, extract_xtp): New functions.
	(XTP, DQXP, DQXP_MASK): Define.
	(powerpc_opcodes): Add lxvp, stxvp, lxvpx, stxvpx.
	(prefix_opcodes): Add plxvp and pstxvp.
gas/
	* testsuite/gas/ppc/vsx_32byte.d,
	* testsuite/gas/ppc/vsx_32byte.s: New test.
	* testsuite/gas/ppc/ppc.exp: Run it.
ld/
	* testsuite/ld-powerpc/pcrelopt.s: Add lxvp and stxvp.
	* testsuite/ld-powerpc/pcrelopt.d: Update.
2020-05-11 21:08:37 +09:30
Alan Modra 7c1f422735 PowerPC Rename powerxx to power10
Now that ISA3.1 is out we can finish with the powerxx silliness.

bfd/
	* elf64-ppc.c: Rename powerxx to power10 throughout.
gas/
	* config/tc-ppc.c (md_assemble): Update for PPC_OPCODE_POWER10
	renaming.
	* testsuite/gas/ppc/prefix-align.d: Use -mpower10/-Mpower10 in
	place of -mfuture/-Mfuture.
	* testsuite/gas/ppc/prefix-pcrel.d: Likewise.
	* testsuite/gas/ppc/prefix-reloc.d: Likewise.
gold/
	* powerpc.cc: Rename powerxx to power10 throughout.
include/
	* elf/ppc64.h: Update comment.
	* opcode/ppc.h (PPC_OPCODE_POWER10): Rename from PPC_OPCODE_POWERXX.
ld/
	* testsuite/ld-powerpc/callstub-1.d: Use -mpower10/-Mpower10 in
	place of -mfuture/-Mfuture.
	* testsuite/ld-powerpc/notoc2.d: Likewise.
	* testsuite/ld-powerpc/powerpc.exp: Likewise.
	* testsuite/ld-powerpc/tlsgd.d: Likewise.
	* testsuite/ld-powerpc/tlsie.d: Likewise.
	* testsuite/ld-powerpc/tlsld.d: Likewise.
opcodes/
	* ppc-dis.c (ppc_opts): Add "power10" entry.
	(print_insn_powerpc): Update for PPC_OPCODE_POWER10 renaming.
	* ppc-opc.c (POWER10): Rename from POWERXX.  Update all uses.
2020-05-11 21:08:36 +09:30
Nick Clifton 73199c2b7a Updated French translation for the ld sub-directory and an update Spanish translation for the opcodes subdirectory. 2020-05-11 12:02:26 +01:00
Wilco Dijkstra cff69cf4cf [binutils-gdb][ld][AArch64] Fix group_sections algorithm
PR ld/25665
	* bfd/elfnn-aarch64.c (group_sections): Copy implementation
	from elf32-arm.c.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
	* testsuite/ld-aarch64/farcall-group.s: New large group test.
	* testsuite/ld-aarch64/farcall-group.d: Likewise.
2020-05-04 15:51:56 +01:00
Alan Modra a8acd6eeb6 PR25882, .gnu.attributes are not checked for shared libraries
This allows backend merge_private_bfd_data to examine shared library
e_flags and/or .gnu.attributes.  ARM and PowerPC have done so when
using ld.gold for a long time.

(The tic6x change below is dead code due to the earlier FIXME,
but this is probably one of the changes needed there.)

	PR 25882
bfd/
	* elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer
	Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output.
ld/
	* ldlang.c (lang_check): Call bfd_merge_private_bfd_data for
	shared libraries.
2020-05-01 15:32:36 +09:30
Alan Modra 94a8e7b0ef Regen ld BLD-POTFILES.in
* po/BLD-POTFILES.in: Regenerate.
2020-05-01 15:32:36 +09:30
Alex Coplan 09c1e68a16 AArch64: add GAS support for UDF instruction
binutils * testsuite/binutils-all/aarch64/in-order-all.d: Update to use new
          disassembly.
        * testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise.

ld/     * testsuite/ld-aarch64/erratum843419_tls_ie.d: Use udf in disassembly.
        * testsuite/ld-aarch64/farcall-b-section.d: Likewise.
        * testsuite/ld-aarch64/farcall-back.d: Likewise.
        * testsuite/ld-aarch64/farcall-bl-section.d: Likewise.

gas/   * config/tc-aarch64.c (fix_insn): Implement for AARCH64_OPND_UNDEFINED.
          (parse_operands): Implement for AARCH64_OPND_UNDEFINED.
        * testsuite/gas/aarch64/udf.s: New.
        * testsuite/gas/aarch64/udf.d: New.
        * testsuite/gas/aarch64/udf-invalid.s: New.
        * testsuite/gas/aarch64/udf-invalid.l: New.
        * testsuite/gas/aarch64/udf-invalid.d: New.

include * opcode/aarch64.h (enum aarch64_opnd): Add AARCH64_OPND_UNDEFINED.

opcodes * aarch64-opc.h (enum aarch64_field_kind): Add FLD_imm16_2.
        * aarch64-opc.c (fields): Add entry for FLD_imm16_2.
          (operand_general_constraint_met_p): validate AARCH64_OPND_UNDEFINED.
        * aarch64-tbl.h (aarch64_opcode_table): Add udf instruction, entry for
          FLD_imm16_2.
        * aarch64-asm-2.c: Regenerated.
        * aarch64-dis-2.c: Regenerated.
        * aarch64-opc-2.c: Regenerated.
2020-04-30 15:47:30 +01:00
Nick Clifton 8a8a117123 Add generic tests for linker support of the -shared or -pie options to tests which use them.
binutils* testsuite/lib/binutils-common.exp (check_pie_support): New
	proc.

ld	* testsuite/ld-elf/compress1c.d: XFAIL if thet target linker does
	not support the -shared command line option.
	* /ld-elf/compressed1c.d: Likewise.
	* /ld-elf/compressed1e.d: Likewise.
	* /ld-elf/dynamic1.d: Likewise.
	* /ld-elf/dynsym1.d: Likewise.
	* /ld-elf/ehdr_start-shared.d: Likewise.
	* /ld-elf/exclude3b.d: Likewise.
	* /ld-elf/global1.d: Likewise.
	* /ld-elf/hash.d: Likewise.
	* /ld-elf/local1.d: Likewise.
	* /ld-elf/mbind1b.d: Likewise.
	* /ld-elf/now-1.d: Likewise.
	* /ld-elf/now-2.d: Likewise.
	* /ld-elf/now-3.d: Likewise.
	* /ld-elf/now-4.d: Likewise.
	* /ld-elf/pr12975.d: Likewise.
	* /ld-elf/pr13177.d: Likewise.
	* /ld-elf/pr13195.d: Likewise.
	* /ld-elf/pr16322.d: Likewise.
	* /ld-elf/pr16498a.d: Likewise.
	* /ld-elf/pr16498b.d: Likewise.
	* /ld-elf/pr17615.d: Likewise.
	* /ld-elf/pr19162.d: Likewise.
	* /ld-elf/pr19698.d: Likewise.
	* /ld-elf/pr20513c.d: Likewise.
	* /ld-elf/pr20513d.d: Likewise.
	* /ld-elf/pr21389a.d: Likewise.
	* /ld-elf/pr21389b.d: Likewise.
	* /ld-elf/pr21389c.d: Likewise.
	* /ld-elf/pr21562a.d: Likewise.
	* /ld-elf/pr21562b.d: Likewise.
	* /ld-elf/pr21562c.d: Likewise.
	* /ld-elf/pr21562d.d: Likewise.
	* /ld-elf/pr21562e.d: Likewise.
	* /ld-elf/pr21562f.d: Likewise.
	* /ld-elf/pr21562g.d: Likewise.
	* /ld-elf/pr21562h.d: Likewise.
	* /ld-elf/pr21562i.d: Likewise.
	* /ld-elf/pr21562j.d: Likewise.
	* /ld-elf/pr21562k.d: Likewise.
	* /ld-elf/pr21562l.d: Likewise.
	* /ld-elf/pr21562m.d: Likewise.
	* /ld-elf/pr21562n.d: Likewise.
	* /ld-elf/pr21903a.d: Likewise.
	* /ld-elf/pr21903b.d: Likewise.
	* /ld-elf/pr22269b.d: Likewise.
	* /ld-elf/pr22393-1a.d: Likewise.
	* /ld-elf/pr22393-1b.d: Likewise.
	* /ld-elf/pr23658-1c.d: Likewise.
	* /ld-elf/pr25708.d: Likewise.
	* /ld-elf/rpath-1.d: Likewise.
	* /ld-elf/rpath-2.d: Likewise.
	* /ld-elf/runpath-1.d: Likewise.
	* /ld-elf/runpath-2.d: Likewise.
	* /ld-elf/sizeofb.d: Likewise.
	* /ld-elf/startofb.d: Likewise.
	* /ld-elf/strtab.d: Likewise.
	* /ld-elf/textaddr2.d: Likewise.
	* /ld-elf/textaddr5.d: Likewise.
	* /ld-elf/textaddr6.d: Likewise.
	* /ld-elf/unknown2.d: Likewise.
	* /ld-undefined/entry-3.d: Likewise.
	* /ld-undefined/entry-4.d: Likewise.
	* /ld-elf/mbind1c.d: XFAIL if the target linker does not support
	the -pie option.
	* /ld-elf/pie.d: Likewise.
	* /ld-elf/pr19539.d: Likewise.
	* /ld-elf/pr21903d.d: Likewise.
	* /ld-elf/pr22269a.d: Likewise.
	* /ld-elf/pr22393-1c.d: Likewise.
	* /ld-elf/pr22393-1d.d: Likewise.
	* /ld-elf/pr22423.d: Likewise.
	* /ld-elf/loadaddr1.d: Expect to fail on the rx-linux target.
	* /ld-elf/loadaddr2.d: Likewise.
	* /ld-elf/pr22393-1e.d: Likewise.
	* /ld-elf/pr22393-1f.d: Likewise.
	* /ld-elf/textaddr1.d: Likewise.
	* /ld-elf/textaddr4.d: Likewise.
2020-04-30 13:49:30 +01:00
Yoshinori Sato c578f16ef1 ld: Add rx-linux emulation. gas: Change ELF flags initial value in rx-linux
ld	* emulparams/elf32rx_linux.sh: New rx-linux emulation.
	* emultempl/rxlinux.em: New.
	* configure.tgt: Add rx-linux.
	* Makefile.am: Add eelf32rx_linux.c
	* Makefile.in: Regenerate.

gas	* config/tc-rx.c (elf_flags): Reset default value.
	(md_parse_option): For rx-elf Initialize elf_flags with RX_ABI.
2020-04-30 13:35:37 +01:00
Max Filippov d548f47df4 xtensa: fix XTENSA_NDIFF handling for PR ld/25861
Fields marked with XTENSA_NDIFF relocations are not negated, they only
have sign bits removed. Don't negate their values when relaxation is
performed. Don't add sign bits when the value is zero. Report overflow
when the result has negative sign but all significant bits are zero.

2020-04-29  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (relax_section): Don't negate diff_value for
	XTENSA_NDIFF relocations. Don't add sign bits whe diff_value
	equals 0. Report overflow when the result has negative sign but
	all significant bits are zero.

ld/
	* testsuite/ld-xtensa/relax-diff1.d: New test definition.
	* testsuite/ld-xtensa/relax-diff1.s: New test source.
	* testsuite/ld-xtensa/relax-ndiff.d: New test definition.
	* testsuite/ld-xtensa/relax-ndiff.s: New test source.
	* testsuite/ld-xtensa/xtensa.exp: (relax-diff1)
	(relax-ndiff): New tests.
2020-04-29 18:34:23 -07:00
Stephen Casner 4849fabc7c Remove restriction on skipping some linker tests because their default image base is too high.
PR 25829
	* testsuite/ld-scripts/default-script.exp: Add --image-base=0 to
	LDFLAGS for targets *-*-mingw64 x86_64-*-cygwin.
	* testsuite/ld-scripts/default-script1.d: No longer have to skip
	test for those targets.
	* testsuite/ld-scripts/default-script2.d: Likewise.
	* testsuite/ld-scripts/default-script3.d: Likewise.
	* testsuite/ld-scripts/default-script4.d: Likewise.
2020-04-29 12:57:56 +01:00
Tamar Christina 251dae9107 x86: Add i386 PE big-object support
The 64-bit version of binutils got support for the PE COFF BIG OBJ format a
couple of years ago.   The BIG OBJ format is a slightly different COFF format
which extends the size of the number of section field in the header from a
uint16_t to a uint32_t and so greatly increases the number of sections allowed.

However the 32-bit version of bfd never got support for this.  The GHC Haskell
compiler generates a great deal of symbols due to it's use of
-ffunction-sections and -fdata-sections.

This meant that we could not build the 32-bit version of the GHC Compiler for
many releases now as binutils didn't have this support.

This patch adds the support to the 32-bit port of binutils as well and also does
come cleanup in the code.

bfd/ChangeLog:

	* coff-i386.c (COFF_WITH_PE_BIGOBJ): New.
	* coff-x86_64.c (COFF_WITH_PE_BIGOBJ): New.
	* config.bfd (targ_selvecs): Rename x86_64_pe_be_vec
	to x86_64_pe_big_vec as it not a big-endian format.
	(vec i386_pe_big_vec): New.
	* configure.ac: Likewise.
	* targets.c: Likewise.
	* configure: Regenerate.
	* pe-i386.c (TARGET_SYM_BIG, TARGET_NAME_BIG,
	COFF_WITH_PE_BIGOBJ): New.
	* pe-x86_64.c (TARGET_SYM_BIG, TARGET_NAME_BIG):
	New.
	(x86_64_pe_be_vec): Moved.

gas/ChangeLog:

	* NEWS: Add news entry for big-obj.
	* config/tc-i386.c (i386_target_format): Support new format.
	* doc/c-i386.texi: Add i386 support.
	* testsuite/gas/pe/big-obj.d: Rename test to not be x64 specific.
	* testsuite/gas/pe/pe.exp (big-obj): Make test run on i386 as well.

ld/ChangeLog:

	* pe-dll.c (pe_detail_list):  Add pe-bigobj-i386.
2020-04-27 17:41:39 +01:00
Max Filippov 30ce8e47fa xtensa: fix PR ld/25861
Introduce new relaxations XTENSA_PDIFF{8,16,32} for positive differences
(subtracted symbol precedes diminished symbol) and XTENSA_NDIFF{8,16,32}
for negative differences (subtracted symbol follows diminished symbol).
Don't generate XTENSA_DIFF relocations in the assembler, generate
XTENSA_PDIFF or XTENSA_NDIFF based on relative symbol position.

Handle XTENSA_DIFF in BFD for compatibility with old object files.
Handle XTENSA_PDIFF and XTENSA_NDIFF in BFD, treating difference value
as unsigned.

2020-04-22  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* bfd-in2.h: Regenerated.
	* elf32-xtensa.c (elf_howto_table): New entries for
	R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.
	(elf_xtensa_reloc_type_lookup, elf_xtensa_do_reloc)
	(relax_section): Add cases for R_XTENSA_PDIFF{8,16,32} and
	R_XTENSA_NDIFF{8,16,32}.
	* libbfd.h (bfd_reloc_code_real_names): Add names for
	BFD_RELOC_XTENSA_PDIFF{8,16,32} and
	BFD_RELOC_XTENSA_NDIFF{8,16,32}.
	* reloc.c: Add documentation for BFD_RELOC_XTENSA_PDIFF{8,16,32}
	and BFD_RELOC_XTENSA_NDIFF{8,16,32}.

binutils/
	* readelf.c (is_none_reloc): Recognize
	BFD_RELOC_XTENSA_PDIFF{8,16,32} and
	BFD_RELOC_XTENSA_NDIFF{8,16,32}.

gas/
	* config/tc-xtensa.c (md_apply_fix): Replace
	BFD_RELOC_XTENSA_DIFF{8,16,32} generation with
	BFD_RELOC_XTENSA_PDIFF{8,16,32} and
	BFD_RELOC_XTENSA_NDIFF{8,16,32} generation.
	* testsuite/gas/xtensa/loc.d: Replace BFD_RELOC_XTENSA_DIFF16
	with BFD_RELOC_XTENSA_PDIFF16 in the expected output.

include/
	* elf/xtensa.h (elf_xtensa_reloc_type): New entries for
	R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.

ld/
	* testsuite/ld-xtensa/relax-loc.d: New test definition.
	* testsuite/ld-xtensa/relax-loc.s: New test source.
	* testsuite/ld-xtensa/xtensa.exp (relax-loc): New test.
2020-04-22 18:46:45 -07:00
Fangrui Song 161719466a For relative paths in INPUT() and GROUP(), search the directory of the current linker script before searching other paths.
PR ld/25806
	* ldlang.h (struct lang_input_statement_struct): Add extra_search_path.
	* ldlang.c (current_input_file): New.
	(ldirname): New.
	(new_afile): Add from_filename parameter. Set extra_search_path.
	(lang_add_input_file): Pass current_input_file to new_afile.
	(load_symbols): Set current_input_file.
2020-04-22 16:20:02 +01:00
Alan Modra 1d934d7685 Correct mingw target select
x86_64-w64-mingw32  +FAIL: ld-scripts/default-script1
x86_64-w64-mingw32  +FAIL: ld-scripts/default-script2
x86_64-w64-mingw32  +FAIL: ld-scripts/default-script3
x86_64-w64-mingw32  +FAIL: ld-scripts/default-script4

	* testsuite/ld-scripts/default-script1.d: Correct mingw skip.
	* testsuite/ld-scripts/default-script2.d: Likewise.
	* testsuite/ld-scripts/default-script3.d: Likewise.
	* testsuite/ld-scripts/default-script4.d: Likewise.
2020-04-22 21:14:36 +09:30
Stephen Casner 39a7b38fac Fix linker tests to work with 16-bit targets.
PR 25829
	* testsuite/ld-scripts/script.exp (check_script)
	(extract_symbol_test): Make test addresses fit in 16 bits.
	* testsuite/ld-scripts/memory.t: Likewise.
	* testsuite/ld-scripts/memory_sym.t (TXT_LENGTH): Likewise.
	* testsuite/ld-scripts/default-script.t (_START): Likewise.
	* testsuite/ld-scripts/default-script1.d: Likewise.
	* testsuite/ld-scripts/default-script2.d: Likewise.
	* testsuite/ld-scripts/default-script3.d: Likewise.
	* testsuite/ld-scripts/default-script4.d: Likewise.
	* testsuite/ld-scripts/empty-address-1.t: 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-misc/start.s: .long -> .dc.a to allow relocation to
	fit target address size.
 	* testsuite/ld-scripts/empty-address-1.s: Likewise.
	* testsuite/ld-scripts/empty-address-2.s: Likewise.
2020-04-21 15:10:52 +01:00
H.J. Lu 6f6fd151cb elf: Strip zero-sized dynamic sections
ELF size_dynamic_sections is called by the ELF backend linker after all
the linker input files have been seen but before the section sizes have
been set.  After the sections sizes have been set, target-specific,
global optimizations may make some dynamic sections zero-sized if they
are no longer needed.

Add ELF strip_zero_sized_dynamic_sections so that ELF backend linker can
strip zero-sized dynamic sections after the sections sizes have been set.

bfd/

	PR ld/25849
	* elf-bfd.h (elf_backend_data): Add
	elf_backend_strip_zero_sized_dynamic_sections.
	(_bfd_elf_strip_zero_sized_dynamic_sections): New prototype.
	* elf64-alpha.c (elf_backend_strip_zero_sized_dynamic_sections):
	New macro.
	* elflink.c (_bfd_elf_strip_zero_sized_dynamic_sections): New
	function.
	* elfxx-target.h (elf_backend_strip_zero_sized_dynamic_sections):
	New macro.
	(elfNN_bed): Add elf_backend_strip_zero_sized_dynamic_sections.

ld/

	PR ld/25849
	* ldelfgen.c (ldelf_map_segments): Call
	elf_backend_strip_zero_sized_dynamic_sections.
	* testsuite/ld-alpha/tlsbinr.rd: Updated.
2020-04-21 05:24:03 -07:00
Alan Modra 2efec98b28 PowerPC64: remove empty .rela.dyn (.rela.branch_lt)
Stripping .rela.branch_lt is easy enough but messes with the
testsuite due to stub symbols (that use section id) changing.  Tests
that run on more than one target variant can be tricky to fix, this
renaming happened to work.

bfd/
	* elf64-ppc.c (ppc64_elf_size_stubs): Strip relbrlt too.
ld/
	* testsuite/ld-powerpc/tlsopt5.s: Rename foo to aaaaa.
	* testsuite/ld-powerpc/tlsopt5.d: Adjust to suit.
	* testsuite/ld-powerpc/tlsopt6.d: Likewise.
2020-04-20 08:14:42 +09:30
Rainer Orth dbe23755ac ld: Don't xfail ld-elf/warn[12] on 64-bit Solaris/SPARC
Two ld tests currently XPASS on 64-bit Solaris/SPARC:

XPASS: ld-elf/warn1
XPASS: ld-elf/warn2

They were xfail'ed on Solaris/SPARCv9 back in 2005

	https://sourceware.org/pipermail/binutils/2005-February/039268.html

but obviously this no longer appplies.

Fixed by removing the xfail's.

Tested on sparcv9-sun-solaris2.11 and sparc-sun-solaris2.11.

	* testsuite/ld-elf/warn1.d: Don't xfail on 64-bit Solaris/SPARC.
	* testsuite/ld-elf/warn2.d: Likewise.
2020-04-18 22:17:24 +02:00
H.J. Lu 54975ae91f elf: Don't use .set for alpha target
Since the .set directive of ELF/alpha target is different, define NO_SET
to 1 to use "=" for ELF/alpha target.

	* testsuite/ld-elf/elf.exp (ASFLAGS): Add "--defsym NO_SET=1" for
	alpha target.
	* testsuite/ld-elf/pr19789.s: Use "=" if NO_SET is defined.
2020-04-18 11:23:09 -07:00
Stephen Casner 0203cad215 Fix the test for PR 18963 so that it will work on 16-bit targets.
PR 18963
	* testsuite/ld-scripts/pr18963.t: Reduce section sizes to fit in
	16-bit address space.
	* testsuite/ld-scripts/pr18963.d: Likewise.
2020-04-17 14:16:27 +01:00
Nick Clifton ce1feff0e7 Revert "Fix the test for PR 18963 so that it will work on 16-bit targets."
This reverts commit 7a1a12f4d1.
2020-04-17 13:16:56 +01:00
Juan Manuel Guerrero 0fe0f2d621 [PATCH 1/2] coff-go32: update ldscript
* scripttempl/i386go32.sc: Provide symbol _environ.  Link in
	.ctors and .dtors.  Discard LTO sections.
2020-04-17 13:12:31 +01:00
Nick Clifton 49c16254b4 Commit: Running the linker testsuite with clang
* testsuite/config/default.exp: If not already set then create the
	CCC_OVERRIDE_OPTIONS environment variable to help when running the
	testsuite with clang.
	* testsuite/ld-elf/pr22269-1.c: Add a missing return statement.
	* testsuite/ld-elfvers/vers.exp: Add checks to detect if files
	were built before attempting to copy them.
2020-04-17 13:03:53 +01:00
Stephen Casner 7a1a12f4d1 Fix the test for PR 18963 so that it will work on 16-bit targets.
PR ld/18963
	* testsuite/ld-scripts/pr18963.s: New, replaces empty data.s to
	allocate space in text, data, bss here rather than pr18963.t.
	* testsuite/ld-scripts/pr18963.t: Remove assignments to dot.
	* testsuite/ld-scripts/pr18963.d: Change addresses to fit 16 bits.
2020-04-16 16:13:31 +01:00
Fangrui Song 95a5156812 Unify the behaviour of ld.bfd and ld.gold with respect to warning about unresolved symbol references. (PR 24613)
PR binutils/24613
include	* bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and
	RM_GENERATE_ERROR. Add RM_DIAGNOSE.
	(struct bfd_link_info): Add warn_unresolved_syms.

ld	* lexsup.c (parse_args): Change RM_GENERATE_WARNING and
	RM_GENERATE_ERROR to RM_DIAGNOSE.
	* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Change
	RM_GENERATE_ERROR to RM_DIAGNOSE.
	* emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise.

bfd	* coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR
	to RM_DIAGNOSE plus a check of warn_unresolved_syms.
	* coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise.
	* elf-bfd.h (_bfd_elf_large_com_section): Likewise.
	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
	* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
	* elf32-sh.c (sh_elf_relocate_section): Likewise.
	* elf32-spu.c (spu_elf_relocate_section): Likewise.
	* elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
	* elflink.c (elf_link_output_extsym): Likewise.
	* elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
2020-04-15 14:25:08 +01:00
Stephen Casner fa1477dc34 Fixes for the magic number used in PDP11 AOUT binaries.
PR ld/25677
include	* aout/aout64.h (N_DATADDR): Add IMAGIC case.

bfd	* pdp11.c: Add implementation of --imagic option.
	(adjust_o_magic): Fix objcopy --extract-symbol test.
	* libaout.h (enum aout_magic): Add i_magic.

ld	* emulparams/pdp11.sh (SCRIPT_NAME): Change to pdp11.
	(EXTRA_EM_FILE): New, add emulation file pdp11.
	* scripttempl/pdp11.sc: New, derived from aout.sc without
	irrelevant input sections.
	* emultempl/pdp11.em (_add_options, _handle_option)
	(_list_options): New. Add options -z, --imagic for pdp11-aout.
	(_before_parse): Make --omagic be default instead of --nmagic.
	(_get_script): Modify special-case linker script for --imagic.
	* lexsup.c (parse_args): Explictly set config.text_read_only for -n.
	* ld.texi (Options): Add documentation of PDP11-specific options.
	(Options): Fix unrelated typo to --no-compact-branches.
	* gen-doc.texi: @set PDP11.
	* testsuite/ld-pdp11/pdp11.exp: New, start pdp11 testing.
	* testsuite/ld-pdp11/sections.s: New, source for options tests.
	* testsuite/ld-pdp11/imagic.d: New, test --imagic format.
	* testsuite/ld-pdp11/imagicz.d: New, test -z (imagic) format.
	* testsuite/ld-pdp11/nmagic.d: New, test --nmagic format.
	* testsuite/ld-pdp11/omagic.d: New, test --omagic format.
2020-04-14 14:41:27 +01:00
H.J. Lu 10ca4b042d readelf: Consolidate --syms --use-dynamic with --dyn-syms
When reconstructing dynamic symbol table from the PT_DYNAMIC segment,
compute dynamic symbol table size from hash table.  For DT_HASH, the
number of dynamic symbol table entries equals the number of chains.
For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL
indings are in hash table.  Since DT_GNU_HASH/DT_MIPS_XHASH place all
symbols with STB_LOCAL binding before symbols with other bindings and
all undefined symbols defined ones in dynamic symbol table, the highest
symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol
table index.

Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms
and --syms --use-dynamic.

binutils/

	PR binutils/25707
	* readelf.c (nbuckets): New.
	(nchains): Likewise.
	(buckets): Likewise.
	(chains): Likewise.
	(ngnubuckets): Likewise.
	(gnubuckets): Likewise.
	(gnuchains): Likewise.
	(mipsxlat): Likewise.
	(ngnuchains): Likewise.
	(gnusymidx): Likewise.
	(VALID_SYMBOL_NAME): Likewise.
	(VALID_DYNAMIC_NAME): Use it.
	(get_dynamic_data): Moved before process_dynamic_section.
	(get_num_dynamic_syms): New function.
	(process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH,
	DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol
	table.  Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string
	table.
	(get_symbol_index_type): Don't print "bad section index" when
	there is no section header.
	(print_dynamic_symbol): Rewrite.
	(process_symbol_table): Call print_dynamic_symbol to dump dynamic
	symbol table.

ld/

	PR binutils/25707
	* testsuite/ld-arm/armthumb-lib.sym: Updated.
	* testsuite/ld-arm/farcall-mixed-app.sym: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.sym: Likewise.
	* testsuite/ld-arm/fdpic-main-m.sym: Likewise.
	* testsuite/ld-arm/fdpic-main.sym: Likewise.
	* testsuite/ld-arm/fdpic-shared-m.sym: Likewise.
	* testsuite/ld-arm/fdpic-shared.sym: Likewise.
	* testsuite/ld-arm/mixed-app.sym: Likewise.
	* testsuite/ld-arm/mixed-lib.sym: Likewise.
	* testsuite/ld-arm/preempt-app.sym: Likewise.
	* testsuite/ld-elf/hash.d: Likewise.
	* testsuite/ld-elf/pr13195.d: Likewise.
	* testsuite/ld-elfvsb/hidden2.d: Likewise.
	* testsuite/ld-mips-elf/hash2.d: Likewise.
2020-04-14 05:00:34 -07:00
Rainer Orth a5d214978f ld: xfail several shared (non PIC) tests on Solaris
Three ld tests currently FAIL on Solaris/SPARC:

FAIL: shared (non PIC)
FAIL: shared (non PIC, load offset)
FAIL: shared (PIC main, non PIC so)

all of them in the same way:

/var/gcc/binutils/sparcv7/obj/binutils/ld/tmpdir/ld/collect-ld: read-only
segment has dynamic relocations

Given that Solaris defaults to -z text, this is to be expected, thus
this patch xfail's them.

Tested on sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11.

	* testsuite/ld-shared/shared.exp: Remove dangling comments.
	xfail shared non PIC tests on Solaris.
2020-04-10 11:18:10 +02:00
Rainer Orth ae4b1d73f9 ld: Fix pr22269-1 on 32-bit Solaris/SPARC
pr22269-1.s currently FAILs to assemble on 32-bit Solaris/SPARC:

ERROR:  -K PIC tmpdir/pr22269-1.s: assembly failed
UNRESOLVED: pr22269-1 (static pie undefined weak)

tmpdir/pr22269-1.s: Assembler messages:
tmpdir/pr22269-1.s:27: Error: Architecture mismatch on "be,pn %icc,.LL4 ,pn %icc,.LL4".
tmpdir/pr22269-1.s:27: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
tmpdir/pr22269-1.s:32: Error: Architecture mismatch on "return %i7+8".
tmpdir/pr22269-1.s:32: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
tmpdir/pr22269-1.s:36: Error: Architecture mismatch on "return %i7+8".
tmpdir/pr22269-1.s:36: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)

I could trace this to the fact that gcc on sparc-sun-solaris2.* defaults
to --with-cpu=v9.  So the gcc -S step of compiling the testcase is run
with -mcpu=v9, while the manual invocation of as-new lacks the
corresponding -Av9, creating a mismatch.

Solaris seems to be the only affected target, otherwise only
64-bit-default configurations default to --with-cpu=v9 or
--with-cpu=ultrasparc: sparcv9-*-*, sparc64-*-*,
sparc64-*-freebsd*, ultrasparc-*-freebsd*, and sparc64-*-openbsd*.

This patch just adds -Av9 to AFLAGS_PIC in ld-elf/shared.exp.  It has a
precedent in ld-elfvers/vers.exp where -Av9a is added to as_options on
sparc-*-*.  It lets the test pass and causes no other changes in
sparc-sun-solaris2.11 test results.

	* testsuite/ld-elf/shared.exp: Add -Av9 to AFLAGS_PIC on sparc*-*-*.
2020-04-09 13:10:40 +02:00
H.J. Lu aa350065a4 NOCF_PROTECTION_CFLAGS: Replace nopie with available
* testsuite/config/default.exp (NOCF_PROTECTION_CFLAGS): Replace
	nopie with available.
2020-04-02 07:42:40 -07:00
H.J. Lu 8be5def63b ld: Add NOCF_PROTECTION_CFLAGS to turn off -fcf-protection
GCC in Ubuntu 20.04 enables -fcf-protection by default, which leads to

FAIL: S-records
FAIL: S-records with constructors
FAIL: Build plt-main with -z bndplt
FAIL: Build plt-main with PIE and -z bndplt
FAIL: Build plt-main with -z bndplt -z now
FAIL: Build plt-main with PIE and -z bndplt -z now

on x86-64.  Add NOCF_PROTECTION_CFLAGS to pass -fcf-protection=none on
these tests.

	* testsuite/config/default.exp (NOCF_PROTECTION_CFLAGS): New.
	Set to "-fcf-protection=none" if target compiler supports it.
	* testsuite/ld-srec/srec.exp: Add $NOCF_PROTECTION_CFLAGS to
	CC and CXX.
	* testsuite/ld-x86-64/x86-64.exp: Add $NOCF_PROTECTION_CFLAGS
	to PLT BND tests.
2020-04-02 07:12:45 -07:00
H.J. Lu 516231b7c7 linux-x86.exp: Compile with -I../bfd
Compile with -I../bfd to include <bfd_stdint.h> in PR ld/25749 tests.

	* testsuite/ld-elf/linux-x86.exp (check_pr25749a): Compile with
	-I../bfd.
	(check_pr25749b): Likewise.
2020-04-02 04:44:01 -07:00
Rainer Orth bb89747721 ld: Disable ifunc tests on Solaris
A couple of ld ifunc tests currently FAIL on 64-bit Solaris/x86:

FAIL: ld-ifunc/ifunc-10-x86-64
FAIL: ld-ifunc/ifunc-11-x86-64
FAIL: ld-ifunc/ifunc-12-x86-64
FAIL: ld-ifunc/ifunc-13-x86-64
FAIL: ld-ifunc/ifunc-14a-x86-64
FAIL: ld-ifunc/ifunc-14b-x86-64
FAIL: ld-ifunc/ifunc-14c-x86-64
FAIL: ld-ifunc/ifunc-14d-x86-64
FAIL: ld-ifunc/ifunc-14e-x86-64
FAIL: ld-ifunc/ifunc-14f-x86-64
FAIL: ld-ifunc/ifunc-15-x86-64
FAIL: ld-ifunc/ifunc-17a-x86-64
FAIL: ld-ifunc/ifunc-17b-x86-64
FAIL: ld-ifunc/ifunc-2-local-x86-64-now
FAIL: ld-ifunc/ifunc-2-local-x86-64
FAIL: ld-ifunc/ifunc-2-x86-64-now
FAIL: ld-ifunc/ifunc-2-x86-64
FAIL: ld-ifunc/ifunc-20-x86-64
FAIL: ld-ifunc/pr17154-x86-64-now
FAIL: ld-ifunc/pr17154-x86-64

For one, the actual error is weird:

./ld-new: target elf64-x86-64 not found
failed with: <./ld-new: target elf64-x86-64 not found>, no expected output
FAIL: ld-ifunc/ifunc-10-x86-64

although ld -V does report the elf_x86_64 emulation as supported:

$ ./ld/ld-new -V
GNU ld (GNU Binutils) 2.34.50.20200328
  Supported emulations:
   elf_x86_64_sol2
   elf_x86_64
[...]

When using ld -m elf_x86_64_sol2 instead, one of the testcases links
successfully.

However, there's no point in pursuing this: Solaris does not support
ifunc, as can be seen in <sys/elf.h>:

/*
 * GNU/Linux specific symbol type not used by Solaris
 */
#define STT_GNU_IFUNC   10

and never will, given that it has symbol capabilities as solution to
effectively the same problem:

http://www.linker-aliens.org/blogs/rie/entry/symbol_capabilitie/

Therefore this patch disables ifunc testing on Solaris completely by
removing Solaris from binutils/testsuite/lib/binutils-common.exp
(supports_gnu_osabi).  The ifunc part is justified above.  SHF_GNU_MBIND is
in the OS-specific range and conflicts with

#define SHF_SUNW_REALLOC        0x01000000      /* internal: krtld realloc */

While the comment suggests this might be relocatable without too much
problems, the description of mbind (no formal spec AFAICS, just the
comment in the binutils patch submission) strongly suggests that this
isn't relevant to Solaris at all.

Indirectly, clearing supports_gnu_osabi on Solaris disables
supports_gnu_unique.  Again, Solaris <sys/elf.h> has

/*
 * GNU/Linux specific binding not used by Solaris
 */
#define STB_GNU_UNIQUE  10

so this seems the right thing to do.

Afterwards, one can remove the explicit mentions of *-*-solaris2* in
quite a number of (but not all) the ld-ifunc dump file notarget lists.

There's one fallout, though: two gas tests now XPASS because they are
xfail'ed for !supports_gnu_osabi:

XPASS: mbind sections 12
XPASS: mbind section contents 16
XPASS: mbind sections 16
XPASS: mbind section contents 16

To fix that, I've changed

#xfail: ![supports_gnu_osabi]

to notarget.

Tested on x86_64-pc-solaris2.11, i386-pc-solaris2.11,
x86_64-pc-linux-gnu, and i686-pc-linux-gnu.

	ld:
	* testsuite/ld-ifunc/ifunc-10-i386.d: Remove *-*-solaris2* from
	notarget.
	* ifunc-11-i386.d: Likewise.
	* ifunc-12-i386.d: Likewise.
	* ifunc-13-i386.d: Likewise.
	* ifunc-14a-i386.d: Likewise.
	* ifunc-14b-i386.d: Likewise.
	* ifunc-14c-i386.d: Likewise.
	* ifunc-14d-i386.d: Likewise.
	* ifunc-14e-i386.d: Likewise.
	* ifunc-14f-i386.d: Likewise.
	* ifunc-15-i386.d: Likewise.
	* ifunc-16-i386-now.d: Likewise.
	* ifunc-16-i386.d: Likewise.
	* ifunc-17a-i386.d: Likewise.
	* ifunc-17b-i386.d: Likewise.
	* ifunc-18a-i386.d: Likewise.
	* ifunc-18b-i386.d: Likewise.
	* ifunc-19a-i386.d: Likewise.
	* ifunc-19b-i386.d: Likewise.
	* ifunc-2-i386-now.d: Likewise.
	* ifunc-2-i386.d: Likewise.
	* ifunc-2-local-i386-now.d: Likewise.
	* ifunc-2-local-i386.d: Likewise.
	* ifunc-20-i386.d: Likewise.
	* ifunc-21-i386.d: Likewise.
	* ifunc-22-i386.d: Likewise.
	* ifunc-5a-i386.d: Likewise.
	* ifunc-5a-local-i386.d: Likewise.
	* ifunc-5b-i386.d: Likewise.
	* ifunc-5b-local-i386.d: Likewise.
	* ifunc-5r-local-i386.d: Likewise.
	* ifunc-6a-i386.d: Likewise.
	* ifunc-6b-i386.d: Likewise.
	* ifunc-7a-i386.d: Likewise.
	* ifunc-7b-i386.d: Likewise.
	* ifunc-8-i386.d: Likewise.
	* ifunc-9-i386.d: Likewise.
	* pr17154-i386-now.d: Likewise.
	* pr17154-i386.d: Likewise.

	* ifunc-23a-x86.d: Remove notarget.
	* ifunc-24a-x86.d: Likewise.
	* ifunc-25a-x86.d: Likewise.

	gas:
	* testsuite/gas/elf/section12a.d: Use notarget instead of xfail.
	* testsuite/gas/elf/section12b.d: Likewise.
	* testsuite/gas/elf/section16a.d: Likewise.
	* testsuite/gas/elf/section16b.d: Likewise.

	binutils:
	* testsuite/lib/binutils-common.exp (supports_gnu_osabi): Don't
	enable on *-*-solaris*.
2020-04-02 10:52:57 +02:00
Nick Clifton 4f5bd88505 Replace "use use" in a warning message with "use".
PR ld/25747
	* ldfile.c (ldfile_open_file): Fix typo in warning message.
2020-04-02 08:38:48 +01:00
H.J. Lu 382aae0632 x86: Only allow S + A relocations against absolute symbol
Since value of non-preemptible absolute symbol (SHN_ABS) won't change,
only relocations, which can be resolved as absolute value + addend, and
GOTPCREL relocations, where absolute value + addend is stored in the GOT
slot, against non-preemptible absolute symbol are allowed in PIE and
shared library.

Also convert load relocation to R_386_32, R_X86_64_32S or R_X86_64_32 for
relocation against non-preemptible absolute symbol.  Don't convert to
R_X86_64_32S nor R_X86_64_32 for non-preemptible absolute symbol if they
overflow.

bfd/

	PR ld/25749
	PR ld/25754
	* elf32-i386.c (elf_i386_convert_load_reloc): Convert load
	relocation to R_386_32 for relocation against non-preemptible
	absolute symbol.
	(elf_i386_check_relocs): Call _bfd_elf_x86_valid_reloc_p.  Don't
	allocate dynamic relocation for non-preemptible absolute symbol.
	(elf_i386_relocate_section): Pass sec to
	GENERATE_DYNAMIC_RELOCATION_P.
	* elf64-x86-64.c (R_X86_64_converted_reloc_bit): Moved.
	(elf_x86_64_convert_load_reloc): Covert load relocation to
	R_X86_64_32S or R_X86_64_32 for relocation against non-preemptible
	absolute symbol.  Don't convert to R_X86_64_32S nor R_X86_64_32
	for non-preemptible absolute symbol if they overflow.
	(elf_x86_64_check_relocs): Call _bfd_elf_x86_valid_reloc_p.  Set
	tls_type for GOT slot to GOT_ABS for non-preemptible absolute
	symbol.  Don't allocate dynamic relocation for non-preemptible
	absolute symbol.
	(elf_x86_64_relocate_section): Don't generate relative relocation
	for GOTPCREL relocations aganst local absolute symbol.  Pass sec
	to GENERATE_DYNAMIC_RELOCATION_P.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): No dynamic relocation
	against non-preemptible absolute symbol.
	(_bfd_elf_x86_valid_reloc_p): New function.
	(_bfd_x86_elf_size_dynamic_sections): No dynamic relocation for
	GOT_ABS GOT slot.
	* elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): Add an SEC
	argument.  Don't generate dynamic relocation against
	non-preemptible absolute symbol.
	(ABS_SYMBOL_P): New.
	(GENERATE_RELATIVE_RELOC_P): Don't generate relative relocation
	against non-preemptible absolute symbol.
	(GOT_ABS): New.
	(R_X86_64_converted_reloc_bit): New.  Moved from elf64-x86-64.c.
	(_bfd_elf_x86_valid_reloc_p): New.

ld/

	PR ld/25749
	PR ld/25754
	* testsuite/ld-elf/linux-x86.exp: Run ld/25749 tests.
	* testsuite/ld-elf/pr25749-1.c: New file.
	* testsuite/ld-elf/pr25749-1a.c: Likewise.
	* testsuite/ld-elf/pr25749-1b.c: Likewise.
	* testsuite/ld-elf/pr25749-1b.err: Likewise.
	* testsuite/ld-elf/pr25749-1c.c: Likewise.
	* testsuite/ld-elf/pr25749-1d.c: Likewise.
	* testsuite/ld-elf/pr25749-2.c: Likewise.
	* testsuite/ld-elf/pr25749-2a.s: Likewise.
	* testsuite/ld-elf/pr25749-2b.s: Likewise.
	* testsuite/ld-elf/pr25749.rd: Likewise.
	* testsuite/ld-elf/pr25754-1a.c: Likewise.
	* testsuite/ld-elf/pr25754-1b.s: Likewise.
	* testsuite/ld-elf/pr25754-2a.c: Likewise.
	* testsuite/ld-elf/pr25754-2b.err: Likewise.
	* testsuite/ld-elf/pr25754-2b.s: Likewise.
	* testsuite/ld-elf/pr25754-3a.c: Likewise.
	* testsuite/ld-elf/pr25754-3b.s: Likewise.
	* testsuite/ld-elf/pr25754-4a.c: Likewise.
	* testsuite/ld-elf/pr25754-4b.s: Likewise.
	* testsuite/ld-elf/pr25754-4c.s: Likewise.
	* testsuite/ld-elf/pr25754-5a.c: Likewise.
	* testsuite/ld-elf/pr25754-5b.s: Likewise.
	* testsuite/ld-elf/pr25754-5c.s: Likewise.
	* testsuite/ld-elf/pr25754-6a.c: Likewise.
	* testsuite/ld-elf/pr25754-6b.s: Likewise.
	* testsuite/ld-x86-64/pr19609-6a.d: Don't expect linker error.
2020-04-01 14:31:47 -07:00
Tamar Christina 3ce23ca1de Arm: Skip Thumb2 PLT tests on NaCL.
NaCL does not support dynamic linking and so these tests should be
skipped under it.

ld/ChangeLog:

	PR ld/16017
	* testsuite/ld-arm/arm-elf.exp (thumb-plt, thumb-plt-got): Skip for NaCL.
2020-04-01 18:36:23 +01:00
Nick Clifton 77bf7b5317 Extend the linker's error message for missing libraries if there is an almost match.
PR ld/25747
	* ldfile.c (ldfile_open_file): If a search for a library fails,
	but there is a file that would match if it had a "lib" prefix to
	its name, then tell the user.
2020-04-01 17:25:28 +01:00
Tamar Christina a7618269b7 Arm: Fix LSB of GOT for Thumb2 only PLT.
When you have a Thumb only PLT then the address in the GOT for PLT0 needs to
have the Thumb bit set since the instruction used in PLTn to get there is
`ldr.w	pc` which is an inter-working instruction:

the PLT sequence in question is

00000120 <foo@plt>:
 120:	f240 0c98 	movw	ip, #152	; 0x98
 124:	f2c0 0c01 	movt	ip, #1
 128:	44fc      	add	ip, pc
 12a:	f8dc f000 	ldr.w	pc, [ip]
 12e:	e7fc      	b.n	12a <foo@plt+0xa>

Disassembly of section .text:

00000130 <bar>:
 130:	b580      	push	{r7, lr}
 132:	af00      	add	r7, sp, #0
 134:	f7ff fff4 	bl	120 <foo@plt>

and previously the linker would generate

Hex dump of section '.got':
 ...
  0x000101b8 40010100 00000000 00000000 10010000 @...............

Which would make it jump and transition out of thumb mode and crash since you
only have thumb mode on such cores.

Now it correctly generates

Hex dump of section '.got':
 ...
  0x000101b8 40010100 00000000 00000000 11010000 @...............

Thanks to Amol for testing patch and to rgujju for reporting it.

bfd/ChangeLog:

	PR ld/16017
	* elf32-arm.c (elf32_arm_populate_plt_entry): Set LSB of the PLT0
	address in the GOT if in thumb only mode.

ld/ChangeLog:

	PR ld/16017
	* testsuite/ld-arm/arm-elf.exp (thumb-plt-got): New.
	* testsuite/ld-arm/thumb-plt-got.d: New test.
2020-04-01 10:52:33 +01:00
Tamar Christina 15ccbdd717 Arm: Fix thumb2 PLT branch offsets.
When I previously changed these offsets I had incorrectly used an offset of -2
for this Thumb2 PLT.  Unfortunately because we had no tests for this PLT I had
missed that the result was incorrect.

This patch fixes the offset to PC .-4 so that it correctly addresses the
previous instruction and adds a test for this PLT stub.

bfd/ChangeLog:

	* elf32-arm.c (elf32_thumb2_plt_entry): Fix PC-rel offset.

ld/ChangeLog:

	* testsuite/ld-arm/arm-elf.exp (thumb-plt): New.
	* testsuite/ld-arm/thumb-plt.d: New test.
	* testsuite/ld-arm/thumb-plt.s: New test.
2020-04-01 10:52:32 +01:00
Hans-Peter Nilsson 41ff29bf5d ld/testsuite/ld-scripts/defined4.d: Don't xfail mmix-*-*.
A recent fix for the mmo input reader caused symbol-to-type mapping
(which is heuristic for the mmo format) to change (as in "corrected"),
and this test-case now passes.

Before that change, the comment was actually wrong: the symbol type
was mistakenly set to as B for uninitialized data, not T for text
section.
2020-04-01 04:10:18 +02:00
Nick Clifton 00386881a3 Fix objcopy's --preserve-dates command line option so that it will work with PE format files.
PR binutils/pr25662
bfd	* libcoff-in.h (struct pe_tdata): Rename the insert_timestamp
	field to timestamp and make it an integer.
	* libcoff.h: Regenerate.
	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Test the timestamp
	field in the pe_data structure rather than the insert_timestamp
	field.

binutils* objcopy.c (copy_object): When copying PE format files set the
	timestamp field in the pe_data structure if the preserve_dates
	flag is set.
	* testsuite/binutils-all/objcopy.exp (objcopy_test) Use
	--preserve-dates in place of the -p option, in order to make its
	effect more obvious.

ld	* emultempl/pe.em (after_open): Replace initialisation of the
	insert_timestamp field in the pe_data structure with an
	initialisation of the timestamp field.
	* emultemp/pep.em: Likewise.
	* pe-dll.c (fill_edata): Use the timestamp field in the pe_data
	structure instead of the insert_timestamp field.
2020-03-30 16:30:02 +01:00
H.J. Lu 767be9d907 ld: Set COMMONPAGESIZE for i386 Solaris
Since COMMONPAGESIZE is set for other Solaris targets, including x86-64
Solaris, also set COMMONPAGESIZE for i386 Solaris to fix

FAIL: Build pr20995-2.so
FAIL: pr20995-2

	PR 25732
	* emulparams/elf_i386_ldso.sh (COMMONPAGESIZE): New.
	* testsuite/ld-elf/shared.exp:Don't xfail pr20995-2 tests for
	Solaris.
2020-03-28 05:06:58 -07:00
H.J. Lu 258e884429 ld: Xfail pr20995-2 tests for Solaris
Xfail pr20995-2 tests for Solaris since Solaris doesn't support RELRO.

	PR 25732
	* testsuite/ld-elf/shared.exp: Xfail pr20995-2 tests for Solaris.
2020-03-27 07:35:22 -07:00
H.J. Lu cacb9d8713 ld: Skip some x86 IFUNC tests for Solaris
Since Solaris ld.so.1 doesn't support ifunc and never will, skip some
x86 IFUNC tests for Solaris.

	PR 25732
	* testsuite/ld-ifunc/ifunc-23a-x86.d: Add notarget for Solaris.
	* testsuite/ld-ifunc/ifunc-24a-x86.d: Likewise.
	* testsuite/ld-ifunc/ifunc-25a-x86.d: Likewise.
2020-03-27 07:01:54 -07:00
Alan Modra 86fd7e2e10 h8300-linux ld testsuite
This fixes lots of fails caused by h8300-linux not supporting -shared
and related options.  I've also fixed ld-h8300 tests to accept the
valid h8300-linux -m options .

pr22450.d is also fixed for avr, crx, ip2k, m68hc11 and xc16x, and the
new pr25708 test for hppa64.

	* testsuite/ld-elf/compress1c.d: xfail h8300.
	* testsuite/ld-elf/compressed1c.d: Likewise.
	* testsuite/ld-elf/compressed1e.d: Likewise.
	* testsuite/ld-elf/dynamic1.d: Likewise.
	* testsuite/ld-elf/dynsym1.d: Likewise.
	* testsuite/ld-elf/ehdr_start-shared.d: Likewise.
	* testsuite/ld-elf/exclude3b.d: Likewise.
	* testsuite/ld-elf/export-class.exp: Don't run without -shared support.
	* testsuite/ld-elf/global1.d: xfail h8300.
	* testsuite/ld-elf/hash.d: Likewise.
	* testsuite/ld-elf/loadaddr1.d: Likewise.
	* testsuite/ld-elf/loadaddr2.d: Likewise.
	* testsuite/ld-elf/local1.d: Likewise.
	* testsuite/ld-elf/mbind1b.d: Likewise.
	* testsuite/ld-elf/mbind1c.d: Likewise.
	* testsuite/ld-elf/now-1.d: Likewise.
	* testsuite/ld-elf/now-2.d: Likewise.
	* testsuite/ld-elf/now-3.d: Likewise.
	* testsuite/ld-elf/now-4.d: Likewise.
	* testsuite/ld-elf/pie.d: Likewise.
	* testsuite/ld-elf/pr12975.d: Likewise.
	* testsuite/ld-elf/pr13177.d: Likewise.
	* testsuite/ld-elf/pr13195.d: Likewise.
	* testsuite/ld-elf/pr16322.d: Likewise.
	* testsuite/ld-elf/pr16498a.d: Likewise.
	* testsuite/ld-elf/pr16498b.d: Likewise.
	* testsuite/ld-elf/pr17615.d: Likewise.
	* testsuite/ld-elf/pr19162.d: Likewise.
	* testsuite/ld-elf/pr19539.d: Likewise.
	* testsuite/ld-elf/pr19617a.d: Likewise.
	* testsuite/ld-elf/pr19698.d: Likewise.
	* testsuite/ld-elf/pr20513c.d: Likewise.
	* testsuite/ld-elf/pr20513d.d: Likewise.
	* testsuite/ld-elf/pr21389a.d: Likewise.
	* testsuite/ld-elf/pr21389b.d: Likewise.
	* testsuite/ld-elf/pr21389c.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/pr21562e.d: Likewise.
	* testsuite/ld-elf/pr21562f.d: Likewise.
	* testsuite/ld-elf/pr21562g.d: Likewise.
	* testsuite/ld-elf/pr21562h.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/pr21903a.d: Likewise.
	* testsuite/ld-elf/pr21903b.d: Likewise.
	* testsuite/ld-elf/pr21903d.d: Likewise.
	* testsuite/ld-elf/pr22269a.d: Likewise.
	* testsuite/ld-elf/pr22269b.d: Likewise.
	* testsuite/ld-elf/pr22393-1a.d: Likewise.
	* testsuite/ld-elf/pr22393-1b.d: Likewise.
	* testsuite/ld-elf/pr22393-1c.d: Likewise.
	* testsuite/ld-elf/pr22393-1d.d: Likewise.
	* testsuite/ld-elf/pr22393-1e.d: Likewise.
	* testsuite/ld-elf/pr22393-1f.d: Likewise.
	* testsuite/ld-elf/pr22423.d: Likewise.
	* testsuite/ld-elf/pr22450.d: xfail avr, crx, h8300, ip2k, m68hc11,
	and xc16x.
	* testsuite/ld-elf/pr23658-1c.d: xfail h8300.
	* testsuite/ld-elf/pr25708.d: xfail h8300 and hppa64.
	* testsuite/ld-elf/rpath-1.d: xfail h8300.
	* testsuite/ld-elf/rpath-2.d: Likewise.
	* testsuite/ld-elf/runpath-1.d: Likewise.
	* testsuite/ld-elf/runpath-2.d: Likewise.
	* testsuite/ld-elf/sizeofb.d: Likewise.
	* testsuite/ld-elf/startofb.d: Likewise.
	* testsuite/ld-elf/strtab.d: Likewise.
	* testsuite/ld-elf/textaddr1.d: Likewise.
	* testsuite/ld-elf/textaddr2.d: Likewise.
	* testsuite/ld-elf/textaddr4.d: Likewise.
	* testsuite/ld-elf/textaddr5.d: Likewise.
	* testsuite/ld-elf/textaddr6.d: Likewise.
	* testsuite/ld-elf/unknown2.d: Likewise.
	* testsuite/ld-undefined/entry-3.d: Likewise.
	* testsuite/ld-undefined/entry-4.d: Likewise.
	* testsuite/ld-h8300/h8300.exp: Pass appropriate ld -m option.
	* testsuite/ld-h8300/gcsection.d: Remove ld -m option and relax
	file format match.
	* testsuite/ld-h8300/relax-2.d: Likewise.
	* testsuite/ld-h8300/relax-3.d: Likewise.
	* testsuite/ld-h8300/relax-4.d: Likewise.
	* testsuite/ld-h8300/relax-5.d: Likewise.
	* testsuite/ld-h8300/relax-6.d: Likewise.
	* testsuite/ld-h8300/relax-7.d: Likewise.
	* testsuite/ld-h8300/relax.d: Relax file format match.
2020-03-25 14:51:41 +10:30
H.J. Lu 7e6e972f74 bfd: Display symbol version for nm -D
Extend _bfd_elf_get_symbol_version_string for nm -D to display symbol
version.  _bfd_elf_get_symbol_version_name is added to avoid updating
all XXX_get_symbol_version_string functions.

bfd/

	PR binutils/25708
	* elf-bfd.h (_bfd_elf_get_symbol_version_name): New.
	* elf.c (_bfd_elf_get_symbol_version_name): New function.  Based
	on the previous _bfd_elf_get_symbol_version_string.
	(_bfd_elf_get_symbol_version_string): Use it.

binutils/

	PR binutils/25708
	* nm.c (SYM_NAME): Removed.
	(print_symname): Add a pointer to struct extended_symbol_info
	argument.  Call _bfd_elf_get_symbol_version_name to get symbol
	version.
	(print_symdef_entry): Pass NULL to print_symname.
	(print_symbol_info_bsd): Update call to print_symname.
	(print_symbol_info_sysv): Likewise.
	(print_symbol_info_posix): Likewise.

ld/

	PR binutils/25708
	* testsuite/ld-elf/pr25708.d: New file.
2020-03-24 04:23:11 -07:00
Alan Modra 5e737279c6 i386msdos uninitialised read
Also reinstate ld i386aout for i386-msdos target, which doesn't build
otherwise.

bfd/
	* i386msdos.c (msdos_object_p): Don't access e_lfanew when that
	field hasn't been read.  Remove unnecessary casts.
ld/
	* Makefile.am (ALL_EMULATION_SOURCES): Reinstate ei386aout.c.
	Include ei386aout dep file.
	* Makefile.in: Regenerate.
	* po/BLD-POTFILES.in: Regenerate.
2020-03-23 23:26:12 +10:30