Commit Graph

102763 Commits

Author SHA1 Message Date
Nobody ae2c13e275 Binutils 2.35 with MCST patches 2022-08-11 20:17:07 +03:00
Alibek Omarov 97ccaa1a4c Merge db49701327 (not working) 2022-08-10 13:50:15 +03:00
Nobody e0892d32d3 Binutils with MCST patches 2020-10-14 00:22:48 +03:00
GDB Administrator db49701327 Automatic date update in version.in 2020-08-13 00:00:24 +00:00
Jose E. Marchesi 7ab18c12d5 bpf: add missing tests from previous commits
2020-08-07  David Faust  <david.faust@oracle.com>

	* testsuite/ld-bpf/call-3.s: New file.
	* testsuite/ld-bpf/call-3.d: Likewise.
2020-08-12 15:42:40 +02:00
Jose E. Marchesi 9fdc8d9659 bpf: fix false overflow in eBPF ELF backend linker
When performing DISP{16,32} relocations, the eBPF ELF backend linker
needs to convert the relocation from an address into a signed number
of 64-bit words (minus one) to jump.

Because of this unsigned-to-signed conversion, special care needs to
be taken when dividing to ensure the sign bits remain correct.
Otherwise, a false relocation overflow error can be triggered.

bfd/ChangeLog

2020-08-07  David Faust  <david.faust@oracle.com>

	* elf64-bpf.c (bpf_elf_relocate_section): Ensure signed division for
	DISP16 and DISP32 relocations.

ld/ChangeLog

2020-08-07  David Faust  <david.faust@oracle.com>

	* testsuite/ld-bpf/call-3.s: New file.
	* testsuite/ld-bpf/call-3.d: Likewise.
2020-08-12 15:42:24 +02:00
Jose E. Marchesi 9478b1cc94 bpf: relocation fixes for eBPF ELF backend
The eBPF ELF backend was not properly recording relocation addends
during installation, nor reading and applying them when performing
the final relocation. This lead to various issues with incorrect
relocations.

These issues are fixed with a new howto special function to install
the relocations, and updates to bpf_elf_relocate_section to read and
use the addends as recorded in the input_bfd.

bfd/ChangeLog

2020-08-05  David Faust  <david.faust@oracle.com>

	* elf64-bpf.c (bpf_elf_generic_reloc): New function.
	(bpf_elf_howto_table): Use it here.
	(bpf_elf_relocate_section): Use addends recorded in input_bfd for
	instruction and data relocations.

ld/ChangeLog

2020-08-05  David Faust  <david.faust@oracle.com>

	* testsuite/ld-bpf/call-2.s: New file.
	* testsuite/ld-bpf/call-2.d: Likewise.
	* testsuite/ld-bpf/reloc-data-be.d: Likewise.
	* testsuite/ld-bpf/reloc-data-le.d: Likewise.
	* testsuite/ld-bpf/reloc-data.s: Likewise.
	* testsuite/ld-bpf/reloc-insn-external-be.d: Likewise.
	* testsuite/ld-bpf/reloc-insn-external-le.d: Likewise.
	* testsuite/ld-bpf/reloc-insn-external.s: Likewise.
	* testsuite/ld-bpf/reloc-insn32-be.d: Likewise.
	* testsuite/ld-bpf/reloc-insn32-le.d: Likewise.
	* testsuite/ld-bpf/reloc-insn32.s: Likewise.
	* testsuite/ld-bpf/reloc-insn64-be.d: Likewise.
	* testsuite/ld-bpf/reloc-insn64-le.d: Likewise.
	* testsuite/ld-bpf/reloc-insn64.s: Likewise.
2020-08-12 15:41:34 +02:00
Nick Clifton 6ef598a264 Remove spurious text in changelog entry 2020-08-12 11:28:52 +01:00
GDB Administrator 69fbc94600 Automatic date update in version.in 2020-08-12 00:00:27 +00:00
GDB Administrator 5f3db80323 Automatic date update in version.in 2020-08-11 00:00:31 +00:00
GDB Administrator 5376cb0565 Automatic date update in version.in 2020-08-10 00:00:31 +00:00
GDB Administrator 3d28c67888 Automatic date update in version.in 2020-08-09 00:00:25 +00:00
GDB Administrator 8bac9a7749 Automatic date update in version.in 2020-08-08 00:00:24 +00:00
GDB Administrator f088ae8969 Automatic date update in version.in 2020-08-07 00:00:27 +00:00
GDB Administrator c91bff415f Automatic date update in version.in 2020-08-06 00:00:21 +00:00
GDB Administrator 34266d22bb Automatic date update in version.in 2020-08-05 00:00:29 +00:00
H.J. Lu e2b81f7fcf gas/NEWS: Mention {disp16} pseudo prefix
* NEWS: Mention {disp16} pseudo prefix.

(cherry picked from commit 789198ca955f924c7928c016d922c68e3e2e6dae)
2020-08-04 06:00:37 -07:00
H.J. Lu c74f463281 x86: Add {disp16} pseudo prefix
Use Prefix_XXX for pseudo prefixes.  Add {disp16} pseudo prefix and
replace {disp32} pseudo prefix with {disp16} in 16-bit mode test.
Check invalid {disp16}/{disp32} pseudo prefixes.

gas/

	PR gas/26305
	* config/tc-i386.c (_i386_insn::disp_encoding): Add
	disp_encoding_16bit.
	(parse_insn): Check Prefix_XXX for pseudo prefixes.  Handle
	{disp16}.
	(build_modrm_byte): Handle {disp16}.
	(i386_index_check): Check invalid {disp16} and {disp32} pseudo
	prefixes.
	* doc/c-i386.texi: Update {disp32} documentation and document
	{disp16}.
	* testsuite/gas/i386/i386.exp: Run x86-64-inval-pseudo.
	* testsuite/gas/i386/inval-pseudo.s: Add {disp32}/{disp16}
	tests.
	* testsuite/gas/i386/pseudos.s: Add {disp8}/{disp32} vmovaps
	tests with 128-byte displacement.  Add {disp16} tests.
	* testsuite/gas/i386/x86-64-pseudos.s: Add {disp8}/{disp32}
	vmovaps test.  Add (%r13)/(%r13d) tests.
	* testsuite/gas/i386/x86-64-inval-pseudo.l: New file.
	* testsuite/gas/i386/x86-64-inval-pseudo.s: Likewise.
	* testsuite/gas/i386/inval-pseudo.l: Updated.
	* testsuite/gas/i386/pseudos.d: Likewise.
	* testsuite/gas/i386/x86-64-pseudos.d: Likewise.

opcodes/

	PR gas/26305
	* i386-opc.h (Prefix_Disp8): New.
	(Prefix_Disp16): Likewise.
	(Prefix_Disp32): Likewise.
	(Prefix_Load): Likewise.
	(Prefix_Store): Likewise.
	(Prefix_VEX): Likewise.
	(Prefix_VEX3): Likewise.
	(Prefix_EVEX): Likewise.
	(Prefix_REX): Likewise.
	(Prefix_NoOptimize): Likewise.
	* i386-opc.tbl: Use Prefix_XXX on pseudo prefixes.  Add {disp16}.
	* i386-tbl.h: Regenerated.

(cherry picked from commit 41eb8e88859b297f59f4d093aab9306d4b7057d9)
2020-08-04 05:44:17 -07:00
GDB Administrator d4c09da802 Automatic date update in version.in 2020-08-04 00:00:28 +00:00
Alan Modra 06e5c19999 Use xmalloc rather than malloc
As far as I can tell, the following comment is false nowadays.
/* Calls to m-alloc get turned by sed into xm-alloc.  */

Remove it, and call xmalloc.

	* ldlex.l (yy_create_string_buffer): Use xmalloc rather than malloc.
	* lexsup.c (parse_args): Likewise.

(cherry picked from commit ee44c2ac7b3efdfd28c41cd32d7fb935b0582a97)
2020-08-03 17:16:37 +09:30
Alan Modra c772202862 PR26328, Compilation warning when building ld v2.35 with MinGW
PR 26328
	* configure.ac: AC_CHECK_DECLS asprintf.
	* configure: Regenerate.
	* config.in: Regenerate.

(cherry picked from commit bfd133d0d8432d80ea1cbfc1fc38adee0d502ba3)
2020-08-03 17:15:19 +09:30
GDB Administrator 92f0ea10d6 Automatic date update in version.in 2020-08-03 00:00:23 +00:00
GDB Administrator 4d9145534f Automatic date update in version.in 2020-08-02 00:00:22 +00:00
GDB Administrator 41a4b8c852 Automatic date update in version.in 2020-08-01 00:00:24 +00:00
GDB Administrator b54c2337de Automatic date update in version.in 2020-07-31 00:00:30 +00:00
Szabolcs Nagy 4d4f8ee981 aarch64: set sh_entsize of .plt to 0
On aarch64 the first PLT entry is 32 bytes, subsequent entries
are 16 bytes by default but can be 24 bytes with BTI or with
PAC-PLT.

sh_entsize of .plt was set to the PLT entry size, so in some
cases sh_size % sh_entsize != 0, which breaks some tools.

Note that PLT0 (and the TLSDESC stub code which is also in the
PLT) were historically not padded up to meet the sh_size
requirement, but to ensure that PLT stub code is aligned on
cache lines. Similar layout is present on other targets too
which just happens to make sh_size a multiple of sh_entsize and
it is not expected that sh_entsize of .plt is used for anything.

This patch sets sh_entsize of .plt to 0: the section does not
hold a table of fixed-size entries so other values are not
conforming in principle to the ELF spec.

bfd/ChangeLog:

	PR ld/26312
	* elfnn-aarch64.c (elfNN_aarch64_init_small_plt0_entry): Set sh_entsize
	to 0.
	(elfNN_aarch64_finish_dynamic_sections): Remove sh_entsize setting.

(cherry picked from commit 4d3bb35620e70d543d438bf21be1307f7ea0f5d0)
2020-07-30 17:41:29 +01:00
Nick Clifton d085d01b69 Default to DWARF level 3 in the assembler.
* as.c (dwatf_level): Default to level 3 in case version is not
	set on the command line.
2020-07-30 15:00:38 +01:00
Nick Clifton 6347a63b19 Default to DWARF level 4 in the assembler.
* as.c (dwatf_level): Default to level 4 in case version is not
   set on the command line.
2020-07-30 08:45:04 +01:00
GDB Administrator 89a9065674 Automatic date update in version.in 2020-07-30 00:00:29 +00:00
GDB Administrator 5fca9e53fd Automatic date update in version.in 2020-07-29 00:00:27 +00:00
H.J. Lu 2cd5bade18 x86: Handle {disp32} for (%bp)/(%ebp)/(%rbp)
Since (%bp)/(%ebp)/(%rbp) are encoded as 0(%bp)/0(%ebp)/0(%rbp), use
disp32/disp16 on 0(%bp)/0(%ebp)/0(%rbp) for {disp32}.

Note: Since there is no disp32 on 0(%bp), use disp16 instead.

	PR gas/26305
	* config/tc-i386.c (build_modrm_byte): Use disp32/disp16 on
	(%bp)/(%ebp)/(%rbp) for {disp32}.
	* doc/c-i386.texi: Update {disp32} documentation.
	* testsuite/gas/i386/pseudos.s: Add (%bp)/(%ebp) tests.
	* testsuite/gas/i386/x86-64-pseudos.s: Add (%ebp)/(%rbp) tests.
	* testsuite/gas/i386/pseudos.d: Updated.
	* testsuite/gas/i386/x86-64-pseudos.d: Likewise.

(cherry picked from commit 1a02d6b0ff80048df106cbb776a550278f8c9d9c)
2020-07-28 04:04:34 -07:00
GDB Administrator c4747a6a57 Automatic date update in version.in 2020-07-28 00:00:26 +00:00
GDB Administrator e5980062a6 Automatic date update in version.in 2020-07-27 00:00:23 +00:00
GDB Administrator 770a87f8e3 Automatic date update in version.in 2020-07-26 00:00:30 +00:00
GDB Administrator 577a01f8f2 Automatic date update in version.in 2020-07-25 00:00:22 +00:00
Nick Clifton 279745e566 Set version to 2.35.0 and enable development 2020-07-24 12:05:01 +01:00
Nick Clifton 2cb5c79dad 2.35 Release 2020-07-24 10:36:01 +01:00
Nick Clifton 371d97512a Updated German translation for the opcodes sub-directory 2020-07-24 10:13:45 +01:00
GDB Administrator 629c67644c Automatic date update in version.in 2020-07-24 00:00:23 +00:00
Maciej W. Rozycki fa3b131151 PR ld/26288: Allow the use of `--just-symbols' with ET_EXEC input
Fix a regression from commit a87e1817a4 ("Have the linker fail if any
attempt to link in an executable is made.") and do not reject ET_EXEC
input supplied with the `--just-symbols' option.  Such use is legitimate
as the file requested is not actually linked and only the symbols are
extracted. Furthermore it is often the most useful application, as
already observed in our documentation for the option, where it allows
"to refer symbolically to absolute locations of memory defined in other
programs."

Provide a set of tests for the use of ET_EXEC with `--just-symbols'.
These are excluded however for SH/PE targets because they complain if a
section's VMA is 0:

ld: zero vma section reloc detected: `.text' #0 f=32795
ld: zero vma section reloc detected: `.data' #1 f=291

and for x86_64/PE targets because they seem to hardwire the VMA:

 100000000 12000000 01000000 00000000 00000000  ................

	ld/
	PR ld/26288
	* ldelf.c (ldelf_after_open): Do not reject ET_EXEC input
	supplied with `--just-symbols'.
	* testsuite/ld-misc/just-symbols.exp: New test script.
	* testsuite/ld-misc/just-symbols-1.dd: New test dump.
	* testsuite/ld-misc/just-symbols.ld: New test linker script.
	* testsuite/ld-misc/just-symbols-0.s: New test source.
	* testsuite/ld-misc/just-symbols-1.s: New test source.

(cherry picked from commit 97c79e2174fbb0dda16850fa5366592e93d31cb9)
2020-07-23 20:24:58 +01:00
Maciej W. Rozycki 9b6165529d PR ld/26288: Revert obsolete part of PR ld/26047 fix
Revert commit a3fc941881 ("Stop the linker from accepting executable
ELF files as inputs to other links."), which has been made obsolete by
commit a87e1817a4 ("Have the linker fail if any attempt to link in an
executable is made.").  An earlier check triggers added with the latter
commit making the piece of code removed dead.

	ld/
	PR ld/26288

	Revert:
	PR 26047
	* ldelf.c (ldelf_after_open): Fail if attempting to link one
	executable into another.

(cherry picked from commit b5dd7120f6bcbd1fe650b8839a53b2bd423fbf60)
2020-07-23 20:24:58 +01:00
GDB Administrator 60955197a1 Automatic date update in version.in 2020-07-23 00:00:28 +00:00
H.J. Lu 041d1c2d4f ld: Properly override the IR definition
We change the previous definition in the IR object to undefweak only
after all LTO symbols have been read.

include/

	PR ld/26262
	PR ld/26267
	* bfdlink.h (bfd_link_info): Add lto_all_symbols_read.

ld/

	PR ld/26262
	PR ld/26267
	* ldlang.c (lang_process): Set lto_all_symbols_read after all
	LTO IR symbols have been read.
	* plugin.c (plugin_notice): Override the IR definition only if
	all LTO IR symbols have been read or the new definition is
	non-weak and the the IR definition is weak
	* testsuite/ld-plugin/lto.exp: Run PR ld/26262 and ld/26267
	tests.
	* testsuite/ld-plugin/pr26262a.c: New file.
	* testsuite/ld-plugin/pr26262b.c: Likewise.
	* testsuite/ld-plugin/pr26262c.c: Likewise.
	* testsuite/ld-plugin/pr26267.err: Likewise.
	* testsuite/ld-plugin/pr26267a.c: Likewise.
	* testsuite/ld-plugin/pr26267b.c: Likewise.
	* testsuite/ld-plugin/pr26267c.c: Likewise.

(cherry picked from commit 0e6a3f07f50723d1831291492b96fdf74bcbdc11)
2020-07-22 05:47:43 -07:00
GDB Administrator 544fb88902 Automatic date update in version.in 2020-07-22 00:00:23 +00:00
GDB Administrator 351b4f43aa Automatic date update in version.in 2020-07-21 00:00:27 +00:00
Nick Clifton 866fe07d8d Fix a problem with a few PowerPC linker tests when the .data section is retained.
* testsuite/ld-powerpc/powerpc.exp (ppcelftests): Use section name
	.PPC.EMB.apuinfo instead of section number 2 in apuinfo tests.
2020-07-20 14:59:39 +01:00
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
GDB Administrator 6c5963c20e Automatic date update in version.in 2020-07-20 00:00:25 +00: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