Commit Graph

7940 Commits

Author SHA1 Message Date
Jan Beulich
b6b2252830 v850: improve linker scripts for relocatable linking
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.
2025-03-07 08:29:20 +01:00
Alan Modra
3dab78a686 Re: ld: Add a test for PR ld/25237
Delete the test.  It doesn't make sense to check a linker hack for
a meaningless p_offset.
2025-03-07 09:17:37 +10:30
H.J. Lu
5ccf7a5512 ld: Update PR ld/25237 test
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>
2025-03-06 06:59:55 +08:00
H.J. Lu
9b1e14e5e9 ld: Add a test for PR ld/25237
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>
2025-03-05 12:55:32 +08:00
H.J. Lu
78d7038b15 ld: Pass -Wl,-z,lazy to compiler for i386 lazy binding tests
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>
2025-03-05 12:50:54 +08:00
H.J. Lu
c44400b6ad x86-64: Pass -z separate-code to ld for -z mark-plt tests
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>
2025-02-27 08:19:29 +08:00
Clément Chigot
5e0032993a ld/testsuite: add -z separate-code to sframe x86_64 tests
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.
2025-02-26 09:02:18 +01:00
Alan Modra
a021382482 PR 32731 ub sanitizer accessing filenames_reversed
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.
2025-02-23 21:04:29 +10:30
Jan Beulich
5649b9dc86 ix86: restrict use of GOT32X relocs
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.
2025-02-21 10:26:59 +01:00
Jan Beulich
010a8fd409 x86-64: further tighten convert-load-reloc checking
REX2.M affects what insn we're actually dealing with, so we better check
this to avoid transforming (future) insns we must not touch.
2025-02-21 10:25:41 +01:00
Jan Beulich
11c2852449 x86: widen @got{,pcrel} support to PUSH and APX IMUL
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.
2025-02-21 10:24:50 +01:00
Jan Beulich
922fe9449a x86/APX: use CS: in place of ES: in @gotpcrel and @gottpoff relaxation
H.J. requested this adjustment; I'm unaware of any specific technical
background.
2025-02-21 10:23:21 +01:00
Jan Beulich
e6dc092038 ix86: tighten convert-load-reloc checking
Just like was done recently for x86-64 (commit 4998f9ea9d): 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).
2025-02-21 10:22:50 +01:00
Alan Modra
6592258718 PR32715, ld-elf/pr29072 fail with --disable-default-execstack
--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.
2025-02-19 08:40:38 +10:30
H.J. Lu
1256b9860f ld: Add tests for PR ld/32690
Without

commit 230a788eb2
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>
2025-02-18 12:31:30 +08:00
Alan Modra
d26161914c PR 32603, more ld -w misbehaviour
Commit 8d97c1a53f 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.
2025-02-18 09:16:57 +10:30
Ivan Kokshaysky
0813652eef alpha, ld: remove -taso option
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>
2025-02-15 01:30:58 +00:00
H.J. Lu
d4d66eb19f x86: Return error for invalid relocation offset
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>
2025-02-10 06:35:34 +08:00
Alexandre Oliva
fd82d5ddf5 sparc: define _GLOBAL_OFFSET_TABLE_ when referenced
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.
2025-02-08 03:12:24 -03:00
Alan Modra
1240a10806 Re: x86-64: Estimate output section layout before sizing dynamic sections
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.
2025-02-08 09:29:58 +10:30
H.J. Lu
73ab3b9825 x86-64: Estimate output section layout before sizing dynamic sections
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>
2025-02-07 06:02:05 +08:00
Alan Modra
8d97c1a53f PR 32603, ld -w misbehaviour
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.
2025-02-06 22:15:08 +10:30
Nick Clifton
6be6e5b8ee Fix illegal memory access when linking a corrupt input file.
PR 32647
2025-02-06 09:55:03 +00:00
H.J. Lu
bc61d5916a elf: Store __ehdr_start hash in elf_link_hash_table
Since

commit 97da0e2677
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>
2025-02-04 13:02:58 +08:00
Lulu Cai
a73d904700 LoongArch: Do not relax against __[start|stop]_SECNAME symbol 2025-01-31 10:38:14 +00:00
Jan Beulich
43a7719af5 x86/APX: correct libbfd's EVEX Rn -> Bn transformations
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).
2025-01-31 10:07:54 +01:00
H.J. Lu
625cadfb85 x86-64: Remove pr19609-4c.d and pr19609-4d.d
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>
2025-01-30 12:17:57 +08:00
Nick Clifton
d2030a099b Add translations for various sub-directories 2025-01-28 16:33:47 +00:00
Jens Remus
98d9fe6cb6 s390: Generate .eh_frame unwind information for .plt section
Enable unwinding using .eh_frame information through PLT entries.  Based
on x86-64.

This enhances stack traces if the instruction pointer is in a PLT entry.
For instance perf call graphs, when using --call-graph=dwarf, and Glibc
backtraces, when using backtrace() e.g. from a signal handler.
Note that GDB could already unwind through PLT entries using its s390-
specific prologue unwinder.

Furthermore this lays the foundation to generate SFrame information for
the PLT section in the future.

bfd/
	* elf64-s390.c: Include dwarf2.h.
	(PLT_CIE_SIZE, PLT_FDE_SIZE,
	PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET,
	elf_s390x_eh_frame_plt): New .eh_frame template for .plt
	section.
	(elf_s390_link_hash_table): Add plt_eh_frame field.
	(elf_s390_create_dynamic_sections): New s390-specific wrapper
	around _bfd_elf_create_dynamic_sections.  Create .eh_frame
	section for .plt section.
	(elf_backend_create_dynamic_sections): Register s390-specific
	elf_s390_create_dynamic_sections.
	(elf_s390_late_size_sections): Fill in .eh_frame section for
	.plt section.  Write .plt section size into .eh_frame FDE
	covering .plt section.
	(elf_s390_finish_dynamic_sections): Write .plt section start
	into .eh_frame FDE covering .plt section.  Call
	_bfd_elf_write_section_eh_frame on on htab->plt_eh_frame
	section.

ld/
	* NEWS: Add news entry.
	* emulparams/elf64_s390.sh: Include plt_unwind.sh.

ld/testsuite/
	* ld-s390/plt_64-1_eh.wf: New PLT .eh_frame generation test.
	* ld-s390/s390.exp: Link some existing test cases with
	--no-ld-generated-unwind-info so that they do not fail.  Run
	new PLT .eh_frame generation test.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-01-27 16:47:10 +01:00
Jens Remus
6dbc8a3ef4 s390: Add basic PLT generation tests
ld/testsuite/
	* ld-s390/plt_31_non-pic-1.pd: New non-PIC/PIE PLT generation
	test for 31-bit.
	* ld-s390/plt_31_pic-1.pd: New PIC/PIE PLT generation test for
	31-bit.
	* ld-s390/plt_31-1.wf: New PLT generation test for 31-bit.
	* ld-s390/plt_64-1.pd: New PLT generation test for 64-bit.
	* ld-s390/plt_64-1.wf: Likewise.
	* ld-s390/plt-1.s: New PLT generation test for 31/64-bit.
	* ld-s390/pltlib.s: Likewise.
	* ld-s390/s390.exp: Run new PLT generation tests.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-01-27 16:47:10 +01:00
Jens Remus
6af6a9497b s390: Fix linker s390 emulation option parsing
Append s390-specific emulation options to the shell variables instead of
replacing their contents.

ld/
	* emultempl/s390.em (PARSE_AND_LIST_LONGOPTS,
	PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Append to
	emulation options instead of replacing them.

Fixes: b4cbbe8f72 ("S/390: Add support for pgste marker")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-01-27 16:47:10 +01:00
Yury Khrustalev
2a20abdd81 Fix some broken links in docs and comments
Reviewed-By Richard Earnshaw <richard.earnshaw@arm.com>
2025-01-27 09:15:51 +00:00
Christopher Wellons
18df3e8323 Exclude libpthread from automatic export generation
Before this change, static linking libwinpthread, commonly distributed
as part of Mingw-w64, while using automatic symbol exports would export
the entire threading API, which is never wanted. This is always the case
when static linking libstdc++ built against libpthread.
2025-01-27 14:25:20 +10:30
H.J. Lu
5be27d2ebc ld-x86-64/pr19609-2d.d: Move "#pass" to the end
* testsuite/ld-x86-64/pr19609-2d.d:  Move "#pass" to the end.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-26 18:23:21 +08:00
Jan Beulich
4998f9ea9d x86-64: tighten convert-load-reloc checking
Even if the assembler avoids using relaxable relocations for
inapplicable insns, such relocations 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).
2025-01-24 10:26:46 +01:00
Jan Beulich
6a7a2387ad x86/APX: widen @gotpcrel and @gottpoff support (incl to MOVRS)
If legacy-encoded arithmetic insns are eligible for @gotpcrel
relaxation, EVEX-encoded ones ought to be, too.

Further anything that MOV-from-memory can be used for (and transformed
from) should then also extend to MOVRS.

While extending the apx-load* testcases add  -mrelax-relocations=yes to
the two ones which were missing this: Without this option the intended
testing would not occur on configurations defaulting the option to off.
2025-01-24 10:26:02 +01:00
Torbjörn SVENSSON
014a7c0fa3 ld: fix alignment issue for ARM thumb long branch stub using PureCode section
When pure-code option is activated. The linker creates for M-profile architecures
a 2-bytes branch instruction. This causes the section alignment to be set to 2-byte
alignment instead of 4-byte alignment. This is a problem for long branch stub
without pure-code section as it contains a 32-bit address as data, which is expected
to be 4-byte aligned. Hence creating a long branch stub for PureCode section followed
by a long branch stub will result in a misalignment for the 32-bit address.

An easy fix is to add a nop instruction after the branch to keep the section alignment
to 4 bytes.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Guillaume VACHERIAS <guillaume.vacherias@st.com>
2025-01-23 10:36:03 +01:00
Alan Modra
90bea4932e ld plugin.c concat leaks
* ldlang.c: Whitespace.
	(stat_free, stat_concat): New functions.
	* ldlang.h (stat_free, stat_concat): Declare.
	* plugin.c (asymbol_from_plugin_symbol): Use stat_concat.
2025-01-23 11:40:40 +10:30
Alan Modra
a62e0f8597 Another ldelf_before_allocation leak
This fixes an even more obvious leak.

	* ldelf.c (ldelf_before_allocation): Free copied elf_dt_audit.
	Simplify loop.
2025-01-23 11:40:40 +10:30
Alan Modra
63488ec7b8 More ld testsuite fixes
* testsuite/ld-elf/indirect.exp: Run compiler capability checks
	using run_host_noleak.
	* testsuite/ld-ifunc/ifunc.exp: Don't exit without restoring
	ASFLAGS.  Don't run ifuncmod5 twice.
2025-01-23 11:40:40 +10:30
Sam James
6999916e6c ld: fix bashism in scripttempl/elf.sc
ld/
	PR ld/32580

	* scripttempl/elf.sc: Fix '==' bashism.
2025-01-23 00:04:59 +00:00
Jan Beulich
196fda592e ld: replace another @progbits etc in an ELF testcase
The canonical form (in the testsuite) is %progbits and alike.
2025-01-22 09:51:00 +01:00
Nick Clifton
50505c486e More updated translations 2025-01-21 10:48:02 +00:00
Alan Modra
bea261b937 asan ld builds without detect_leaks=0
I found that building binutils with -fsanitize=address,undefined
results in much of the testsuite not being run.  The problem is that
running gcc results in linker plugin memory leaks which of course are
errors, so the testsuite sees this as lack of compiler support.

	* testsuite/lib/ld-lib.exp (run_host_noleak): New proc.
	(check_compiler_available, check_lto_available),
	(check_lto_fat_available, check_lto_shared_available),
	(check_ifunc_available, check_ifunc_attribute_available),
	(check_libdl_available, check_gnu2_tls_available),
	(compile_one_cc): Use run_host_noleak.
	* testsuite/config/default.exp (compiler_supports): Likewise.
2025-01-21 08:42:44 +10:30
Maciej W. Rozycki
17973a4fee LD: Remove duplicate 2.44 NEWS marker
Delete an extra 2.44 NEWS marker that has crept in by chance.
2025-01-20 17:29:18 +00:00
Nick Clifton
8ae7da3ae8 Update translations for various sub-directories 2025-01-20 16:19:22 +00:00
Lulu Cai
8f8cc1d0c4 gas/NEWS,ld/NEWS: Announce LoongArch changes in 2.44 2025-01-20 15:04:36 +00:00
Alan Modra
bf2da5d57d ldelf_before_allocation leak
ldelf_before_allocation is passed the audit and depaudit strings built
from command line args, then possibly adds to the depaudit string,
freeing the original.  The new string isn't freed.  Fix this leak by
keeping the string attached to the static vars.

	* ldelf.c (ldelf_before_allocation): Pass char** for audit
	and depaudit.  Adjust uses.
	* ldelf.h (ldelf_before_allocation): Update prototype.
	* gld${EMULATION_NAME}_before_allocation: Update call.
2025-01-20 18:16:15 +10:30
Alan Modra
cb6326b5ce sec->alloced and freeing section contents
This modifies _bfd_elf_free_cached_info to unmap/free section
contents.  To do that we need to *not* free sections where contents
are bfd_alloc'd or point to constant strings or somesuch.  I've chosen
to implement this be adding another flag to struct bfd_section,
"alloced" to say the section contents can't be freed.  Most of the
patch is about setting that flag in many places.
2025-01-20 07:13:46 +10:30
Alan Modra
d4115c2c8d Replace xmalloc with stat_alloc in ld parser
A few place dealing with ld script handling made some attempt to free
memory, but this was generally ignored and would be quite a lot of
work to implement.  Instead, use the stat_obstack rather than
mallocing in many more cases.

	* ldexp.c (exp_get_fill): Use stat_alloc for fill.
	* ldfile.c (ldfile_try_open_bfd): Don't free yylval fields.
	* ldgram.y: Replace xmalloc with stat_alloc throughout.
	* ldlang.c (stat_memdup, stat_strdup): New functions.
	(ldirname): Use stat_memdup.  Don't strdup ".".
	(output_section_callback_sort): Use stat_alloc.
	(output_section_callback_tree_to_list): Don't free.
	(lang_memory_region_lookup): Use stat_strdup.
	(lang_memory_region_alias): Likewise.
	(add_excluded_libs): Use stat_alloc and stat_memdup.
	(ldlang_add_undef, ldlang_add_require_defined): Use stat_strdup.
	(lang_add_nocrossref, lang_leave_overlay): Use stat_alloc.
	(realsymbol): Use stat_strdup for return value and always
	free symbol.
	(lang_new_vers_pattern, lang_new_vers_node): Use stat_alloc.
	(lang_finalize_version_expr_head): Don't free.  Delete FIXME.
	(lang_register_vers_node): Don't free.
	(lang_add_vers_depend): Use stat_alloc.
	(lang_do_version_exports_section): Likewise.
	(lang_add_unique): Use stat_alloc and stat_strdup.
	(lang_append_dynamic_list): Use stat_alloc.
	* ldlang.h (stat_memdup, stat_strdup): Declare.
	* ldlex.l: Replace xstrdup with stat_strdup throughout.
	Replace xmemdup with stat_memdup too.
	* lexsup.c (parse_args): Don't free export list or dynamic
	list.
2025-01-20 07:13:46 +10:30