Age | Commit message (Collapse) | Author | Files | Lines |
|
A fix for commit c4fce3ef2927.
|
|
This test is not supposed to use -z force-bti
|
|
Both BTI and memory sealing require use of GNU properties and
we should check that there is no interference.
|
|
Fix commit c4fce3ef2927 brace position.
|
|
Add -fPIC when compiling the test, to fix complaints on some targets
about certains relocation not being valid for shared libraries.
|
|
While commit ef6379e16dd1 ("Set the default DLL chracteristics to 0 for
Cygwin based targets") tried to undo the too broad earlier 514b4e191d5f
("Change the default characteristics of DLLs built by the linker to more
secure settings"), it didn't go quite far enough. Apparently the
assumption was that if it's not MinGW, it must be Cygwin. Whether it
really is okay to default three of the flags to non-zero on MinGW also
remains unclear - sadly neither of the commits came with any description
whatsoever. (Documentation also wasn't updated to indicate the restored
default.)
Setting effectively any of the DLL characteristics flags depends on
properties of the binary being linked. While defaulting to "more secure"
is a fair goal, it's only the programmer who can know whether their code
is actually compatible with the respective settings. On the assumption
that the change of defaults was indeed deliberate (and justifiable) for
MinGW, limit them to just that. In particular, don't default any of the
flags to set also for non-MinGW, non-Cygwin targets, like e.g. UEFI. At
least the mere applicability of the high-entropy-VA bit is pretty
questionable there in the first place - UEFI applications, after all,
run in "physical mode", i.e. either unpaged or (where paging is a
requirement, like for x86-64) direct-mapped.
The situation is particularly problematic with NX-compat: Many UEFI
implementations respect the "physical mode" property, where permissions
can't be enforced anyway. Some, like reportedly OVMF, even have a build
option to behave either way. Hence successfully testing a UEFI binary on
any number of systems does not guarantee it won't crash elsewhere if the
flag is wrongly set.
Get rid of excess semicolons as well.
|
|
commit 2707d55e539ef323dd14a1293e762bf3d9739ee7
Author: Michael Matz <matz@suse.de>
Date: Mon Mar 31 15:57:08 2025 +0200
skipped the LTO archive member even when the earlier item is also an
archive. Instead, skip the LTO archive member only if the earlier item
is a shared library.
bfd/
PR ld/32846
PR ld/32854
* elflink.c (elf_link_add_archive_symbols): Skip the LTO archive
member only if the earlier item is a shared library.
ld/
PR ld/32846
PR ld/32854
* testsuite/ld-plugin/lto.exp: Run ld/32846 test.
* testsuite/ld-plugin/pr32846a.c: New file.
* testsuite/ld-plugin/pr32846b.c: Likewise.
* testsuite/ld-plugin/pr32846c.c: Likewise.
* testsuite/ld-plugin/pr32846d.c: Likewise.
* testsuite/ld-plugin/pr32846e.c: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
when a shared library defines 'foo@@FOO' (default version),
a static archive defines 'foo', the shared lib comes in front
of the archive and under effect of --as-needed, and the requesting
object file uses LTO, then the link editor was wrongly including
the definition from the static archive. It must use the one
from the shared lib, like in the non-LTO or the --no-as-needed case.
See the added testcase that would wrongly print "FAIL" before
this patch.
The problem stems from several connected problems:
(1) only the decorated symbol was entered into first_hash (the hash
table designed to handle definition order in the pre-LTO-plugin
phase of the symbol table walks)
(2) in the archive symbol walk only the undecorated name would be
looked up in first_hash (and hence not found due to (1))
(3) in the archive symbol walk first_hash would only be consulted
when the linker hash table had a defined symbol. In pre-LTO
phase shared lib symbols aren't entered into the linker symbol
table.
So: add also the undecorated name into first_hash when it stems from
a default version and consult first_hash in the archive walker also
for currently undefined symbols. If it has an entry which doesn't
point to the archive, then it comes from an earlier library (shared or
static), and so _this_ archive won't provide the definition.
|
|
The need for this has disappeared with dc12032bca08 ("Remove m68k-aout
and m68k-coff support"); avoid the unnecessary indirection.
Sadly, with ld/pe-dll.c using the wrapper, the removal requires moving
the declaration out of libcoff.h, to properly export the underlying BFD
function.
|
|
Signed-off-by: LIU Hao <lh_mouse@126.com>
ld/ChangeLog:
* testsuite/ld-pe/secidx.d: Escape dots in regular expressions.
|
|
extra resource use information to be reported.
|
|
Since 2020, mingw-w64 provides a C runtime import library variant
named "libucrtapp" too, exclude this one from autoexports like
the others.
Signed-off-by: Martin Storsjö <martin@martin.st>
|
|
Some distributions configure GCC with --enable-default-pie, so that it
defaults to compile with -fPIE and link with -pie, which is unexpected
by some of the tests. Therefore link the PDE test programs with
$NOPIE_LDFLAGS to disable PIE.
This complements commit a7eaf017f959 ("Use NOPIE_CFLAGS and
NOPIE_LDFLAGS to disable PIE").
ld/testsuite/
PR ld/21090
* ld-x86-64/x86-64.exp (undefined_weak): Use NOPIE_LDFLAGS to
disable PIE for the non-PIE versions of the test.
Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
|
|
Some distributions configure GCC with --enable-default-pie, so that it
defaults to compile with -fPIE and link with -pie, which is unexpected
by the test. Therefore compile the non-PIC sources with $NOPIE_CFLAGS
and link the test programs with $NOPIE_LDFLAGS.
Commit 922109c71828 ("Pass $NOPIE_CFLAGS to ELF visibility tests") added
$NOPIE_CFLAGS when compiling sh1np.o and sh2np.o. It missed to add it
to mainnp.o.
ld/testsuite/
PR ld/21090
* ld-vsb/vsb.exp (visibility_test): Add support for optional
ldflags argument and use it when linking the test program.
(mainnp.o): Compile with $NOPIE_CFLAGS.
(vnp, vp, vmpnp, vmpp): Link with $NOPIE_LDFLAGS.
Fixes: 922109c71828 ("Pass $NOPIE_CFLAGS to ELF visibility tests")
Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
|
|
Some distributions configure GCC with --enable-default-pie, so that it
defaults to compile with -fPIE and link with -pie, which is unexpected
by the test. Therefore compile the non-PIC sources with $NOPIE_CFLAGS
and link the test programs with $NOPIE_LDFLAGS.
Commit 9d1c54ed7f3a ("Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF
tests") added $NOPIE_CFLAGS when compiling sh1np.o. It missed to add it
to sh2np.o and mainnp.o.
ld/testsuite/
PR ld/21090
* ld-shared/shared.exp (shared_test): Add support for optional
ldflags argument and use it when linking the test program.
(sh2np.o, mainnp.o): Compile with $NOPIE_CFLAGS.
(shnp, shp, shmpnp, shmpp): Link with $NOPIE_LDFLAGS.
Fixes: 9d1c54ed7f3a ("Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF tests")
Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
|
|
Linker test "pr21964-4" fails on s390x on Ubuntu 24.10 but not on
Fedora 41. The reason is that GCC on Ubuntu is configured with
--enable-default-pie, so that it defaults to compile with -fPIE
and link with -pie, which causes the test to erroneously fail.
ld/testsuite/
PR ld/21090
* ld-elf/shared.exp: Compile pr21964-4 with $NOPIE_CFLAGS and
link with $NOPIE_LDFLAGS.
Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
|
|
Linker test "pr19719 fun defined" (non PIE) fails on s390x on Fedora 41
but not on Ubuntu 24.10. The reason is that GCC on Ubuntu is configured
with --enable-default-pie, so that it defaults to compile with -fPIE
and link with -pie, which hides the test fail.
ld/testsuite/
PR ld/21090
* ld-elf/shared.exp: Compile pr19719 (non-PIE) with
$NOPIE_CFLAGS and link with $NOPIE_LDFLAGS.
Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
|
|
The suffix "defined/undefined" in the ld test pr19719 name specifies
whether weak fun() is defined or undefined is mixed up.
The test builds an executable and a shared library. The latter in two
flavors, one with weak fun() defined (libpr19719a.so, "defined") and
one without weak fun() defined (libpr19719b.so, "undefined").
The first "Run $exe fun [...]" invocation uses libpr19719b.so as
libpr19719.so, which is build from dummy.c, which does not define fun.
Thus fun is undefined during this test run.
The second "Run $exe fun [...]" invocation uses libpr19719a.so as
libpr19719.so, which is build from pr19719d.c, which does define fun.
Thus fun is defined during this test run.
Correct the test naming mix-up accordingly.
ld/testsuite/
* ld-elf/shared.exp (mix_pic_and_non_pic): Correct test naming
mix-up of when weak fun is un-/defined.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
|
|
Other *-elf targets set COMMONPAGESIZE in emulparams/*.sh and so
enable `-z relro` and related features. Make aarch64-elf match.
There is no reason to think that a "generic ELF" target should
have any particular set of features disabled.
|
|
Remove the unused pr19636-3d.d since static Position Dependent Executable
doesn't have a dynamic symbol table.
PR ld/32807
* testsuite/ld-x86-64/pr19636-3d.d: Removed.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
A GNU property section is now always generated when `-z stack-size` is
passed. This was probably introduced by GNU Property refactoring
within elfxx-aarch64.c.
|
|
When generating an ELF output file, if a note section is marked as
NOLOAD, clear the SEC_ALLOC bit so that it won't be treated as an
SHF_ALLOC section, like a .bss style section.
PR ld/32787
* ld.texi: Update NOLOAD for ELF output files.
* ldlang.c (lang_add_section): Clear the SEC_ALLOC bit for NOLOAD
note sections for ELF output files.
* testsuite/ld-elf/pr32787.d: New file.
* testsuite/ld-elf/pr32787.t: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Quite a few constructs where unconditional when they should take
$RELOCATING into account. The original observation was that output of
"ld -r" had .text start at 0x00100000.
|
|
Delete the test. It doesn't make sense to check a linker hack for
a meaningless p_offset.
|
|
1. Skip targets which don't support the .bss section alignment, 1 << 16.
2. Replace .bss with ".section .bss".
3. Use ".zero 0xb60000" for targets which pad the section to its alignment.
PR ld/25237
* testsuite/ld-elf/pr25237.d: Skip avr-*-* and h8300-*-*.
Update expected segment size to 0xb60000.
* testsuite/ld-elf/pr25237.s: Use ".section .bss" and
".zero 0xb60000".
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
PR ld/25237
* testsuite/ld-elf/pr25237.d: New file.
* testsuite/ld-elf/pr25237.s: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Pass -Wl,-z,lazy to compiler for i386 tests which require lazy binding
to support compilers which default to non-lazy binding.
PR ld/32762
* testsuite/ld-i386/i386.exp: Pass -Wl,-z,lazy for
"Build ifunc-1a with PIE -z ibtplt" test.
* testsuite/ld-i386/no-plt.exp: Pass -Wl,-z,lazy for
"Build libno-plt-1b.so", "No PLT (dynamic 1a)",
"No PLT (dynamic 1b)", "No PLT (dynamic 1c)",
"No PLT (PIE 1e)", "No PLT (PIE 1f)", "No PLT (PIE 1g)" tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Pass -z separate-code to ld for -z mark-plt tests to fix:
FAIL: ld-x86-64/mark-plt-1a
FAIL: ld-x86-64/mark-plt-1b
FAIL: ld-x86-64/mark-plt-1c
FAIL: ld-x86-64/mark-plt-1d
FAIL: ld-x86-64/mark-plt-1a-x32
FAIL: ld-x86-64/mark-plt-1b-x32
FAIL: ld-x86-64/mark-plt-1c-x32
FAIL: ld-x86-64/mark-plt-1d-x32
when binutils is configured with --disable-separate-code.
* ld-x86-64/mark-plt-1a-x32.d: Pass -z separate-code to ld.
* ld-x86-64/mark-plt-1a.d: Likewise.
* ld-x86-64/mark-plt-1b-x32.d: Likewise.
* ld-x86-64/mark-plt-1b.d: Likewise.
* ld-x86-64/mark-plt-1c-x32.d: Likewise.
* ld-x86-64/mark-plt-1c.d: Likewise.
* ld-x86-64/mark-plt-1d-x32.d: Likewise.
* ld-x86-64/mark-plt-1d.d: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Those tests were generated by a linker having "-z separate-code" on by
default. However, being controlled by a configure option, it can be off
by default. Forcing the option as part of the tests ensures clean
results in both cases.
|
|
tic4x-coff and mcore-pe tickle this bug by a peculiarity of their
default ld scripts.
PR 32731
* ldlang.c (lang_add_wild): Init filenames_reversed when no
filespec.
|
|
The ELF linker rejects use of this reloc type without a base register
for PIC code. Suppress its use by gas in such cases.
To keep things building for non-ELF, include the entire containing if()
in an #ifdef: All consumers of ->fx_tcbit* live in such conditionals as
well, hence there's no reason to keep the producer active.
|
|
REX2.M affects what insn we're actually dealing with, so we better check
this to avoid transforming (future) insns we must not touch.
|
|
With us doing the transformation to an immediate operand for MOV and
various ALU insns, there's little reason to then not support the same
conversion for the other two insns which have respective immediate
operand forms. Unfortunately for IMUL (due to the 0F opcode prefix)
there's no suitable relocation, so the pre-APX forms cannot be marked
for relaxation in the assembler.
|
|
H.J. requested this adjustment; I'm unaware of any specific technical
background.
|
|
Just like was done recently for x86-64 (commit 4998f9ea9d35): Even if
the assembler avoids using the relaxable relocation for inapplicable
insns, the relocation type can still appear for other reasons. Be more
thorough in the opcode checking we do, to avoid bogusly altering other
insns.
Furthermore correct an opcode mask (even if with the added condition
that's now fully benign).
|
|
--disable-default-stack is an alias for --enable-default-execstack=no.
The existing check only looked for the latter config option.
PR 32715
* testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Look
in config.h for result of --enable-default-execstack.
|
|
Without
commit 230a788eb28a64d628e623068c44add2a24aa5d3
Author: Alan Modra <amodra@gmail.com>
Date: Tue Feb 18 08:54:06 2025 +1030
PR32690, assertion failure in lang_size_relro_segment
this test triggers the linker error:
.../ld: internal error .../ld/ldlang.c 6618
collect2: error: ld returned 1 exit status
with GCC 10 or above on x86-64.
PR ld/32690
* testsuite/ld-elf/elf.exp: Run PR ld/32690 tests.
* testsuite/ld-elf/pr32690.h: New file.
* testsuite/ld-elf/pr32690a.c: Likewise.
* testsuite/ld-elf/pr32690b.c: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Commit 8d97c1a53f3d claimed to replace all einfo calls using %F with
a call to fatal. It did so only for the ld/ directory. This patch
adds a "fatal" to linker callbacks, and replaces those calls in bfd/
too.
|
|
The -taso switch was quite useful 25 years ago for porting 32-bit
code with broken integer-pointer casting. Not anymore. The EF_ALPHA_32BIT
Linux support is going to be dropped in kernel v6.14 [1], NetBSD and OpenBSD
never had it, so there is no point in keeping the -taso option around.
Also remove alpha special case that uses -taso from gdb.base/dump.exp
in gdb testsuite.
[1] https://lore.kernel.org/all/87jzb2tdb7.fsf_-_@email.froward.int.ebiederm.org
Signed-off-by: Ivan Kokshaysky <ink@unseen.parts>
Reviewed-By: Maciej W. Rozycki <macro@orcam.me.uk>
Approved-By: Andrew Burgess <aburgess@redhat.com>
|
|
Return error if relocation offset + relocation size > section size.
bfd/
PR ld/32665
* elf32-i386.c (elf_i386_scan_relocs): Return error for invalid
relocation offset.
* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
ld/
PR ld/32665
* testsuite/ld-x86-64/pr32665.err: New file.
* testsuite/ld-x86-64/pr32665.o.bz2: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/32665 test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
GCC testsuite gcc.dg/20050321-2.c hit link errors on undefined
_GLOBAL_OFFSET_TABLE_. The compiler output referenced only
_GLOBAL_OFFSET_TABLE_-offsets to set it up, and to compute the
GOT-relative address of local symbols, none of which triggered the
machinery that enabled the creation of the dynamic section, so
_GLOBAL_OFFSET_TABLE_ ended up undefined.
Enable the dynamic section if we find a relocation involving
_GLOBAL_OFFSET_TABLE_. While at that, optimize checks for references
to it.
for bfd/ChangeLog
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Check for
_GLOBAL_OFFSET_TABLE_ references early, then compare hashed
symbols instead of strings.
(_bfd_sparc_elf_relocate_section): Compare hashed symbols.
for ld/ChangeLog
* testsuite/ld-sparc/got-def.s: New test.
* testsuite/ld-sparc/sparc.exp: Add it.
|
|
Commit 73ab3b9825 results in a warning compiling eelf_x86_64_sol2.c,
breaking --enable-targets=all builds.
warning: ‘elf_x86_64_before_allocation’ defined but not used
Fix this by hooking up the chain of before_allocation functions, so
x86_64-solaris2 calls elf_x86_64_before_allocation, while
sparc64-solaris2 calls gldelf64_sparc_sol2_before_allocation.
|
|
When sizing dynamic sections, elf_x86_64_scan_relocs converts GOTPCREL
relocations to R_X86_64_PC32, R_X86_64_32S or R_X86_64_32 for local
symbols. But at that time, since the output section layout is unknown,
the local symbol values can't be determined. Later linker issues an
error if the converted relocation overflows when resolving relocations
against these local symbols. Update the x86-64 ELF linker to estimate
output section layout before sizing dynamic sections and use the
preliminary output section layout info to skip the GOTPCREL relocation
conversion if the converted relocation overflows.
bfd/
PR ld/32591
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Add an input
section argument. Use the lowest-addressed section to estimate
the __ehdr_start symbol value. Don't convert relocation if the
converted relocation will overflow.
ld/
PR ld/32591
* emultempl/elf-x86.em (elf_x86_64_before_allocation):
New. Defined for x86-64.
(LDEMUL_BEFORE_ALLOCATION): Likewise.
* testsuite/ld-x86-64/pr19609-2a.d: Don't fail.
* testsuite/ld-x86-64/pr19609-2b.d: Likewise.
* testsuite/ld-x86-64/pr19609-4a.d: Likewise.
* testsuite/ld-x86-64/pr19609-5d.d: Likewise.
* testsuite/ld-x86-64/pr19609-7a.d: Likewise.
* testsuite/ld-x86-64/pr19609-7c.d: Likewise.
* testsuite/ld-x86-64/pr32591-1.s: New file.
* testsuite/ld-x86-64/pr32591-1a-x32.d: Likewise.
* testsuite/ld-x86-64/pr32591-1a.d: Likewise.
* testsuite/ld-x86-64/pr32591-1a.t: Likewise.
* testsuite/ld-x86-64/pr32591-1b-x32.d: Likewise.
* testsuite/ld-x86-64/pr32591-1b.d: Likewise.
* testsuite/ld-x86-64/pr32591-1b.t: Likewise.
* testsuite/ld-x86-64/pr32591-1c-x32.d: Likewise.
* testsuite/ld-x86-64/pr32591-1c.d: Likewise.
* testsuite/ld-x86-64/pr32591-1c.t: Likewise.
* testsuite/ld-x86-64/pr32591-1d-x32.d: Likewise.
* testsuite/ld-x86-64/pr32591-1d.d: Likewise.
* testsuite/ld-x86-64/pr32591-1d.t: Likewise.
* testsuite/ld-x86-64/pr32591-2.s: Likewise.
* testsuite/ld-x86-64/pr32591-2-x32.d: Likewise.
* testsuite/ld-x86-64/pr32591-2.d: Likewise.
* testsuite/ld-x86-64/pr32591-2.t: Likewise.
* testsuite/ld-x86-64/pr32591-3.s: Likewise.
* testsuite/ld-x86-64/pr32591-3-x32.d: Likewise.
* testsuite/ld-x86-64/pr32591-3.d: Likewise.
* testsuite/ld-x86-64/pr32591-3.t: Likewise.
* testsuite/ld-x86-64/pr32591-4.s: Likewise.
* testsuite/ld-x86-64/pr32591-4-x32.d: Likewise.
* testsuite/ld-x86-64/pr32591-4.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/32591 tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
ld -w currently causes segmentation faults and other misbehaviour
since it changes einfo with %F in the format string (fatal error) to
not exit. This patch fixes that by introducing a new variant of einfo
called "fatal" that always exits, and replaces all einfo calls using
%F with a call to fatal without the %F. I considered modifying einfo
to inspect the first 2 or 4 chars in the format string, looking for
%F, but decided that was probably a bad idea given that translators
might have moved the %F. It's also a little nicer to inform the
compiler of a function that doesn't return.
The patch also fixes some formatting nits, and makes use of %pA
to print section names in a couple of places in aix.em.
|
|
PR 32647
|
|
Since
commit 97da0e2677c4a38df2406576428ec27d1da26e7c
Author: Alan Modra <amodra@gmail.com>
Date: Wed Jan 12 23:42:23 2022 +1030
tweak __ehdr_start visibility and flags for check_relocs
creates __ehdr_start hash in lang_symbol_tweaks, store __ehdr_start hash
in elf_link_hash_table so that we just need to lookup it up only once.
bfd/
* elf-bfd.h (elf_link_hash_table): Add hehdr_start.
* elf.c (assign_file_positions_for_load_sections): Use
hehdr_start.
ld/
* ldelf.c (ldelf_before_allocation): Use hehdr_start for
__ehdr_start hash.
* ldlang.c (lang_symbol_tweaks): Store hehdr_start hash in
hehdr_start.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
In the recent GOTPCREL addition I screwed up, in clearing the Rn bits
afterwards rather than setting them. While that ought to be benign (for
the bits being ignored in situations like this), we still want to leave
"canonical" encodings.
The pre-existing GOTTPOFF conversion wasn't doing quite correctly
either: We cannot assume the incoming Bn bits to be in a particular
state, as for the addressing form in question they're ignored as well.
To address both, introduce a helper function. This is then also an
overall reduction of (source) code size (and use of "magic" numbers).
|
|
Remove pr19609-4c.d and pr19609-4d.d since they are identical to
pr19609-4a.d and pr19609-4b.d, respectively.
* testsuite/ld-x86-64/pr19609-4c.d: Removed.
* testsuite/ld-x86-64/pr19609-4d.d: Likewise.
* testsuite/ld-x86-64/pr19609-4e.d: Renamed to ...
* testsuite/ld-x86-64/pr19609-4c.d: This.
* testsuite/ld-x86-64/x86-64.exp: Updated.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|