Commit graph

7315 commits

Author SHA1 Message Date
Indu Bhagat
1bd123bdf3 ld/doc: use "stack trace" instead of "unwind" for SFrame
SFrame format is meant for generating stack traces only.

ld/
	* ld.texi: Replace the use of "unwind" with "stack trace".
2023-02-02 00:49:44 -08:00
Alan Modra
0709900ede ld-elf/merge test update
The merge test fais on numerous targets because they don't support the
necessary pc-relative relocs.  This patch removes that part of the
merge test, and makes references to the merged strings from .data
rather than .text to better support targets that relax text by
default.
2023-02-02 13:40:14 +10:30
Alan Modra
081609f5ff Re: Another fix for EFI generation with LTO enabled
Revert 1c66b8a039 and instead fix the broken list pointer.

	PR 29998
	* pe-dll.c (build_filler_bfd): Revert last change.
	* ldlang.c (lang_process): When rescanning archives for lto,
	fix file_chain.tail pointer if the insert point happens to be
	at the end of the list.
2023-01-31 21:51:09 +10:30
Alan Modra
9884676d9d testsuite XPASSes
This adjusts the testsuite to get rid of a number of XPASSes that have
appeared.  Someone might like to look into a better patch for the s390
change.

aarch64-pe  XPASS: weak symbols
arm-nacl  XPASS: rgn-over8
mcore-pe  XPASS: ld-scripts/provide-8
mips64-linux-gnuabi64  XPASS: vers4
mips64-linux-gnuabi64  XPASS: vers4b
mips-linux-gnu  XPASS: vers4
mips-linux-gnu  XPASS: vers4b
s390-linux-gnu  XPASS: undefined line
sh4-linux-gnu  XPASS: --gc-sections with __start_SECTIONNAME
sh-coff  XPASS: objcopy object (simple copy)
sh-coff  XPASS: objcopy executable (pr25662)

binutils/
	* testsuite/binutils-all/objcopy.exp: Don't xfail "simple
	copy" and "pr25662" on sh-*-coff.  Remove all non-ELF xfails
	on "ELF unknown section type" test.
ld/
	* testsuite/ld-elfvers/vers.exp (vers4, vers4b): Don't xfail
	all mips, just xfail mips irix.
	* testsuite/ld-gc/pr19161.d: Don't xfail sh.
	* testsuite/ld-scripts/rgn-over8-ok.d: Don't xfail nacl.
	* testsuite/ld-scripts/weak.exp: Don't xfail aarch64-pe.
	* testsuite/ld-undefined/undefined.exp: Conditionally xfail
	"undefined line" depending on gcc version for s390.
2023-01-31 15:18:04 +10:30
Nick Clifton
1c66b8a039 Another fix for EFI generation with LTO enabled.
PR 29998 * pe-dll.c (build_filler_bfd): Initialise the next field of the filler input statement, so that it does not break the file chain.
2023-01-27 12:00:35 +00:00
Alan Modra
1f5e6267aa Call bfd_close_all_done in ld_cleanup
This is similar to "Call bfd_close_all_done in output_file_close",
but with some code tidying in the pe/pep write_build_id functions.
write_build_id is passed the output bfd as its parameter, so there is
no need to go looking for the output bfd via link_info (and doing so
will no longer work since I clear link_info.output_bfd before calling
bfd_close).

	* emultempl/pe.em (write_build_id): Rename t to td.  Formatting.
	Don't access pe_data(link_info.output_bfd), use td instead.
	(setup_build_id): Rename t to td.  Formatting.
	* emultempl/pep.em: As for pe.em.
	* ldmain.c (ld_cleanup): Call bfd_close_all_done on linker bfds.
	(main): Clear link_info.output_bfd when closing.
2023-01-27 15:47:09 +10:30
Mark Harmstone
0f97abf074 ld/testsuite: Add missing targets to PDB tests 2023-01-25 22:26:37 +00:00
Mark Harmstone
9a02fbd198 ld: Add pdb support to aarch64-w64-mingw32
This extends PDB support to the aarch64 PE targets.

The changes to the test files are just to make it so they can be assembled as
either x86, x86_64, or aarch64, mainly by changing the comment style.
The only actual code change here is in adding the architecture constants
to pdb.c.
2023-01-25 22:26:18 +00:00
H.J. Lu
0e46a09d12 i386: Pass -Wl,--no-as-needed to compiler as needed
Pass -Wl,--no-as-needed to linker tests to fix

FAIL: Run pr19031
FAIL: Run got1
FAIL: Undefined weak symbol (-fPIE -no-pie)
FAIL: Undefined weak symbol (-fPIE -pie)

when --as-needed is passed to linker by compiler.

	PR ld/30050
	* testsuite/ld-i386/i386.exp: Pass -Wl,--no-as-needed to compiler
	as needed.
2023-01-25 08:57:57 -08:00
Nick Clifton
f3d8ae90b2 Fix seg-fault when generating an empty DLL with LTO enabled.
ld   PR 29998
     * pe-dll.c (generate_reloc): Handle sections
     with no assigned output section.
     Terminate early of there are no relocs to put
     in the .reloc section.
     (pe_exe_fill_sections): Do not emit an empty
     .reloc section.

bfd  * cofflink.c (_bfd_coff_generic_relocate_section):
     Add an assertion that the output section is set
     for defined, global symbols.
2023-01-24 09:47:43 +00:00
Mark Harmstone
7ebf464bbd ld: Avoid magic numbers for subsystems in pe.em and pep.em 2023-01-24 00:54:45 +00:00
Mark Harmstone
cec13966ba ld: Set default subsystem for arm-pe to IMAGE_SUBSYSTEM_WINDOWS_GUI
This fixes the test failures introduced by 87a5cf5c, by changing the
default subsystem for arm-pe from 9 (IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) to
2 (IMAGE_SUBSYSTEM_WINDOWS_GUI), which matches what happens with other
PE targets.

As far as I can tell there's no working modern Windows CE toolchain
knocking about anyway, so this change shouldn't inconvenience anyone.
2023-01-23 20:29:51 +00:00
Mark Harmstone
6f4a117fe1 Add support for secidx relocations to aarch64-w64-mingw32
This patch adds support for the .secidx directive and its corresponding
relocation to aarch64-w64-mingw32. As with x86, this is a two-byte LE
integer which gets filled in with the 1-based index of the output
section that a symbol ends up in.

This is needed for PDBs, which represent addresses as a .secrel32,
.secidx pair.

The test is substantially the same as for amd64, but with changes made
for padding and alignment.
2023-01-23 20:07:30 +00:00
Michael Matz
ec15b12d06 Add testcase ld-elf/merge4
to check a situation that once failed with the new section merging
when it mishandled offsets pointing into alignment padding in mergable
string sections (i.e. pointing to zeros).  It made bootstrap.exp fail
but that depends on many factors to actually go wrong so this is a more
explicit variant of it.
2023-01-20 14:58:04 +01:00
Michael Matz
26ec71f512 arm32: Fix rodata-merge-map
the test expects a second, but useless, $d mapping symbol for
the partially merged section, and specifically disallows one
for the completely merged section.  The new merging algorithm
makes it so that also the partially merged sections are conceptually
SEC_EXCLUDED, except the first merge section (e.g. as if the very
first object file already contains all strings).  So that second mapping
symbol is now missing.  It never was needed anyway.

So, adjust the test.
2023-01-20 14:58:04 +01:00
Alan Modra
5293666148 Correct ld-pe/aarch64.d test output
"foo" is at 0x2010.  This corrects the expected output for .long and
.word referencing foo, showing a problem with relocation handling.

	* testsuite/ld-pe/aarch64.d: Correct expected output.
2023-01-16 23:25:32 +10:30
Hans-Peter Nilsson
b305015577 ld/testsuite: Adjust for ELF_MAXPAGESIZE 0x1000
Many tests reflect a setting of ELF_MAXPAGESIZE to 64 KiB.
With ELF_MAXPAGESIZE changed to 4 KiB, layout is sometimes
different and symbols end up in other places.  Avoid churn
and regexpification of old test patterns by passing the
max-page-size setting active at the time.

ld/testsuite:

	* testsuite/ld-arm/arm-elf.exp,
        testsuite/ld-arm/non-contiguous-arm2.d,
        testsuite/ld-arm/non-contiguous-arm3.d,
        testsuite/ld-arm/non-contiguous-arm5.d,
        testsuite/ld-arm/non-contiguous-arm6.d,
        testsuite/ld-arm/thumb-plt-got.d, testsuite/ld-arm/thumb-plt.d:
	Pass -z max-page-size=0x10000 explicitly to test that rely on
	that value in output-matching patterns.
2023-01-12 17:24:43 +01:00
Alan Modra
4981a31d52 Use __func__ rather than __FUNCTION__
We already use C99's __func__ in places, use it more generally.  This
patch doesn't change uses in the testsuite.  I've also left one in
gold.h that is protected by GCC_VERSION < 4003.  If any of the
remaining uses bothers anyone I invite patches.

bfd/
	* bfd-in.h: Replace __FUNCTION__ with __func__.
	* elf32-bfin.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-cris.c: Replace __FUNCTION__ with __func__.
	* config/tc-m68hc11.c: Likewise.
	* config/tc-msp430.c: Likewise.
gold/
	* dwp.h: Replace __FUNCTION__ with __func__.
	* gold.h: Likewise, except for use inside GCC_VERSION < 4003.
ld/
	* emultempl/pe.em: Replace __FUNCTION__ with __func__.
	* emultempl/pep.em: Likewise.
	* pe-dll.c: Likewise.
2023-01-12 17:20:21 +10:30
Alan Modra
1b9876fa8d Fix XPASS weak symbols on x86_64-mingw32
Fixes commit 16fea92ccd.

	* testsuite/ld-scripts/weak.exp: Don't xfail x86_64 PE targets.
	Do xfail other PE OS triplets by moving code setting xfails.
2023-01-11 23:31:01 +10:30
Mark Harmstone
16fea92ccd Add aarch64-w64-mingw32 target
This adds a mingw target for aarch64, including windres and dlltool.

Note that the old value of jmp_aarch64_bytes was wrong, and this does
the same thing as MSVC does.
2023-01-10 23:30:49 +00:00
Mark Harmstone
528e4f463f Add .secrel32 for pe-aarch64
Adds the .secrel32 pseudo-directive and its corresponding relocation.
2023-01-10 23:30:46 +00:00
Mark Harmstone
b152649d51 Add pe-aarch64 relocations
This adds the remaining pe-aarch64 relocations, and gets them working.
It also brings in the constant directives from ELF, as otherwise .word
would be 2 rather than 4 bytes, and .xword and .dword wouldn't be
defined.
2023-01-10 23:30:44 +00:00
Stefan Schulze Frielinghaus
aefebe82dc IBM zSystems: Fix offset relative to static TLS
For local exec TLS relocations of the form foo@NTPOFF+x the addend was
ignored.

bfd/ChangeLog:

	* elf32-s390.c (elf_s390_relocate_section): Honor addend for
	R_390_TLS_LE32.
	* elf64-s390.c (elf_s390_relocate_section): Honor addend for
	R_390_TLS_LE64.

ld/ChangeLog:

	* testsuite/ld-s390/reloctlsle-1.d: New test.
	* testsuite/ld-s390/reloctlsle-1.s: New test.
2023-01-10 14:34:16 +01:00
Christophe Lyon
7a43fe0185 Skip ld/pr23169 test on arm.
The test is already skipped on several targets (including AArch64)
because it's invalid.

	* testsuite/ld-ifunc/ifunc.exp: Skip pr23169 on arm.
2023-01-09 16:51:57 +01:00
Christophe Lyon
2b70b1b838 Fix PR18841 ifunc relocation ordering
In order to get the ifunc relocs properly sorted the correct class
needs to be returned.  The code mimics what has been done for AArch64.

Fixes:
FAIL: Run pr18841 with libpr18841b.so
FAIL: Run pr18841 with libpr18841c.so
FAIL: Run pr18841 with libpr18841bn.so (-z now)
FAIL: Run pr18841 with libpr18841cn.so (-z now)

	bfd/
	PR ld/18841
	* elf32-arm.c (elf32_arm_reloc_type_class): Return
	reloc_class_ifunc for ifunc symbols.

	ld/testsuite/
	* ld-arm/ifunc-12.rd: Update relocations order.
	* ld-arm/ifunc-3.rd: Likewise.
	* ld-arm/ifunc-4.rd: Likewise.
2023-01-09 16:51:53 +01:00
Jan Beulich
47bb5b33f7 ld: yet another PDB build fix (or workaround)
Older bash looks to improperly deal with backslashes in here-documents,
leaving them in place on the escaped double quotes inside the parameter
expansion. Convert to a model without using such a construct, by simply
splitting the here-documents into three ones.
2023-01-06 13:36:39 +01:00
Nick Clifton
59e1f50fef Updated Bulgarian and Russian translations for LD and BFD respectively 2023-01-06 11:00:47 +00:00
Alan Modra
10df41b188 Tidy pe flag in coff_data
Make it a bool, use obj_pe accessor everywhere.
2023-01-06 21:06:15 +10:30
Nick Clifton
beb6b61d1e Add an extra emulation called arm64pe to the aarch64pe emulation. 2023-01-05 11:00:35 +00:00
Andreas K. Huettel
b26c8438c7 Un xfail the PR19719 test for the AArch64 architecture 2023-01-05 08:35:18 +00:00
Alan Modra
478eebf831 Re: Avoid unaligned pointer reads in PEP .idata section
Fix testsuite fallout.

	* testsuite/ld-pe/cfi.d: Adjust for changed .idata padding.
	* testsuite/ld-pe/secidx_64.d: Likewise.
	* testsuite/ld-pe/secrel_64.d: Likewise.
2023-01-04 23:52:26 +10:30
Andreas K. Huettel
502c7218da Fix AArch64 linker testsuite failures trigeered by differences in build environments.
PR 29843
	* testsuite/ld-aarch64/bti-plt-5.d: Relax regxps slightly to allow
	for differences in build environments.
	* testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: Likewise.
2023-01-04 09:30:14 +00:00
Mark Harmstone
8819b23615 Avoid unaligned pointer reads in PEP .idata section
This is something I discovered when working on aarch64, though it's
relevant to x86_64 too.

The PE32+ imports are located in the .idata section, which starts off
with a 20-byte structure for each DLL, containing offsets into the rest
of the section. This is the Import Directory Table in
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format, which
is a concatenation of the .idata$2 sections. This is then followed by an
20 zero bytes generated by the linker script, which calls this .idata$3.

After this comes the .idata$4 entries for each function, which the
loader overwrites with the function pointers. Because there's no padding
between .idata$3 and .idata$4, this means that if there's an even number
of DLLs, the function pointers won't be aligned on an 8-byte boundary.

Misaligned reads are slower on x86_64, but this is more important on
aarch64, as the e.g. `ldr x0, [x0, :lo12:__imp__func]` the compiler
might generate requires __imp__func (the .idata$4 entry) to be aligned
to 8 bytes. Without this you get IMAGE_REL_ARM64_PAGEOFFSET_12L overflow
errors.
2023-01-04 03:47:09 +00:00
Nick Clifton
11982f9f8b Updated translations for various languages and sub-directories 2023-01-03 11:32:42 +00:00
Alan Modra
3002e78a7d obsolete target tidy
Delete a few files only used for obsolete targets, and tidy config,
xfails and other pieces of support specific to those targets.  And
since I was editing target triplets in test files, fix the nm
alpha-linuxecoff fails.
2023-01-02 14:03:22 +10:30
Alan Modra
d87bef3a7b Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
Nick Clifton
96e786d198 Update version number and regenerate files 2022-12-31 12:23:00 +00:00
Nick Clifton
a72b07181d Add markers for 2.40 branch 2022-12-31 12:05:28 +00:00
Mark Harmstone
a667697f36 ld/testsuite: Don't add index to sizes in pdb.exp 2022-12-31 19:26:23 +10:30
Mark Harmstone
5c9e42e0e9 ld: Handle LF_VFTABLE types in PDBs 2022-12-31 19:26:23 +10:30
Mark Harmstone
fdf591c4c6 ld: Handle extended-length data structures in PDB types
A few fixes to minor issues I've discovered in my PDB patches.

* If sizes or offsets are greater than 0x8000, they get encoded as
extended values in the same way as for enum values - e.g. a LF_ULONG
.short followed by a .long.

* I've managed to coax MSVC to produce another type, LF_VFTABLE, which
is seen when dealing with COM. I don't think LLVM emits this. Note that
we can't just implement everything in Microsoft's header files, as most
of it is obsolete.

* Fixes a stupid bug in the test program, where I was adding an index to
a size. The index was hard-coded to 0, so this didn't cause any actual
issues.
2022-12-31 19:26:23 +10:30
H.J. Lu
9eb71a53bf x86-64: Allocate input section memory if needed
When --no-keep-memory is used, the input section memory may not be cached.
Allocate input section memory for -z pack-relative-relocs if needed.

bfd/

	PR ld/29939
	* elfxx-x86.c (elf_x86_size_or_finish_relative_reloc): Allocate
	input section memory if needed.

ld/

	PR ld/29939
	* testsuite/ld-elf/dt-relr-2i.d: New test.
2022-12-27 11:46:30 -08:00
Flavio Cruz
aac7ae599a Add support for x86_64-*-gnu-* targets to build x86_64 gnumach/hurd 2022-12-26 22:50:24 +10:30
Mark Harmstone
8d25f5ef2c ld: Write linker symbols in PDB 2022-12-23 21:10:09 +10:30
Mark Harmstone
5d9c033689 ld: Copy other symbols into PDB file 2022-12-23 21:02:21 +10:30
Mark Harmstone
81814b6f5b ld: Write globals stream in PDB 2022-12-23 20:54:40 +10:30
Mark Harmstone
817840046a ld: Parse LF_UDT_SRC_LINE records when creating PDB file 2022-12-23 20:45:30 +10:30
Mark Harmstone
fca9096a94 ld: Write types into IPI stream of PDB 2022-12-23 20:13:31 +10:30
Mark Harmstone
d5b4c0ddb9 ld: Write types into TPI stream of PDB 2022-12-23 20:05:48 +10:30
Mark Harmstone
598c1ae610 ld: Write DEBUG_S_LINES entries in PDB file 2022-12-23 19:57:56 +10:30