Commit Graph

4927 Commits

Author SHA1 Message Date
Alan Modra
666edc6b61 PR 33801 strip doesn't remove .gnu.lto_.opts
OK, so people want to be able to partly destroy gcc slim LTO object
files.  I don't see why not, despite HJ's policy-setting slim lto
strip -R tests.  I also don't see why it matters that objcopy/strip
won't similarly break LLVM objects (pr33271).

So out goes the slim lto strip -R tests, and the strip-debug test
expecting slim lto files won't be modified in any way.  strip-debug
now removes a FILE symbol, which isn't unreasonable.

	PR 33801
	PR 33271
	PR 33246
binutils/
	* objcopy.c (copy_archive, copy_file): Do not special case
	gcc LTO IR files.
ld/
	* testsuite/ld-plugin/lto-binutils.exp: Remove slim lto strip -R
	tests.
	(run_pr33246_test): Don't compare slim object files after
	strip-debug.
	* testsuite/ld-plugin/strip-1a-s-all.nd: Delete.
2026-01-18 13:00:19 +10:30
Indu Bhagat
530d779e2b [SFrame-V3] gas: binutils: ld: NEWS: add SFrame v3 related announcements
Add NEWS entries related to the SFrame version 3 release.
2026-01-15 17:02:27 -08:00
Indu Bhagat
2d6c3272da [SFrame-V3] sframe: gas: bfd: ld: format bump to version 3
Bump version to SFRAME_VERSION_3.  Introduce a new definition of SFrame
FDE for version 3, which is a duplicate of SFrame FDE in V2, for now.
In other words, no changes to the format specification yet.

GNU as emits SFrame V3 by default.  SFrame encoder (ld) emits SFrame V3
sections.  In a later commit, we will add a new command line option to
gas: --gsframe-3 which will bind the implementation in gas to emit
SFrame V3.

Also, adjust the testcases for the new version string
"SFRAME_VERSION_3".

bfd/
	* elf-sframe.c (_bfd_elf_merge_section_sframe): Linker emits
	the latest version by default.
	* elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Linker emitted
	PLT sections are also SFRAME_VERSION_3.
	* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Likewise.
gas/
	* gen-sframe.c (sframe_set_version): GAS emits SFrame V3 by
	default.
	(output_sframe): Likewise.
libsframe/
	* sframe-dump.c (dump_sframe): Enable dumping for both
	SFRAME_VERSION_2 and SFRAME_VERSION_3.
include/ChangeLog:
	* sframe.h (SFRAME_VERSION_3): New definition.
	(SFRAME_VERSION): Current version is now SFRAME_VERSION_3.
	(SFRAME_V3_FDE_FUNC_INFO): New definition.
	(SFRAME_V3_FDE_FRE_TYPE): Likewise.
	(SFRAME_V3_FDE_PC_TYPE): Likewise.
	(SFRAME_V3_AARCH64_FDE_PAUTH_KEY): Likewise.
	(SFRAME_V3_FDE_UPDATE_PAUTH_KEY): Likewise.
binutils/testsuite/
	* all affected tests: Replace SFRAME_VERSION_2 with
	SFRAME_VERSION_3.
gas/testsuite/
	* all affected tests: Likewise.
ld/testsuite/
	* all affected tests: Likewise.
libsframe/testsuite/
	* all affected tests: Likewise.
2026-01-15 17:02:24 -08:00
Indu Bhagat
c1ca6c6bdb [SFrame-V3] readelf: testsuite: sframe: add new SFrame V2 test
In subsequent commits, we will add support for SFrame V3.  In the next
GNU Binutils release, GNU as and ld will only generate SFrame V3; SFrame
V2 will not be supported for generation nor linking.

For readelf/objdump, however, continue to support textual dump of SFrame
V2 sections.  Add a binary file (with no debug data) with SFrame V2
section to keep the dumping tested.

Add ET_REL And ET_EXEC binary file based tests for x86_64 and s390x.
Check that both readelf and objdump works on the SFrame V2 sections.

binutils/testsuite/
	* binutils-all/s390/README-sframe-tests: New test.
	* binutils-all/s390/sframe.exp: New test.
	* binutils-all/s390/test-v2-ET_EXEC.sframe.bz2: New test.
	* binutils-all/s390/test-v2-ET_EXEC.sframe.dump: New test.
	* binutils-all/s390/test-v2-ET_REL.sframe.bz2: New test.
	* binutils-all/s390/test-v2-ET_REL.sframe.dump: New test.
	* binutils-all/x86-64/README-sframe-tests: New test.
	* binutils-all/x86-64/sframe.exp: New test.
	* binutils-all/x86-64/test-v2-ET_EXEC.sframe.bz2: New test.
	* binutils-all/x86-64/test-v2-ET_EXEC.sframe.dump: New test.
	* binutils-all/x86-64/test-v2-ET_REL.sframe.bz2: New test.
	* binutils-all/x86-64/test-v2-ET_REL.sframe.dump: New test.
2026-01-15 17:02:23 -08:00
Maciej W. Rozycki
ca2186f9ca BFD: Make `bfd_finalize_section_relocs' return status
Update `bfd_finalize_section_relocs' to return status so that backends
can fail in this interface and propagate that to the respective callers.
Add suitable error reporting there.  No failure cases in the existing
handlers though.
2026-01-14 22:28:43 +00:00
Maciej W. Rozycki
e9499dfeb3 BFD: Rename *_set_reloc' to *_finalize_section_relocs'
The `*_set_reloc' interface is to be called at the conclusion of section
relocation processing, however its name reflects a particular action to
take rather than the context of invocation.  Implementation is already
backend-specific.

Rename the interface such as not to make its name artificially limit the
intended purpose.  Update the callers and documentation accordingly.  No
functional change.
2026-01-14 22:28:43 +00:00
Nelson Chu
ee585288a4 MAINTAINERS: Update my email address 2026-01-14 11:20:49 +08:00
H.J. Lu
2b17961bfb elf: Handle the section flag 'o' linked to special sections
Call _bfd_elf_section_from_bfd_section to get the sh_link value from
the section flag 'o' directive, which may point to special sections,
like SHN_ABS or SHN_COMM.  Update readelf to print the special section
names in the sh_link field and replace "internal->sh_link > num" with
"internal->sh_link >= num".

bfd/

	PR gas/33744
	* elf.c (assign_section_numbers): Call
	_bfd_elf_section_from_bfd_section to get the sh_link value.

binutils/

	PR gas/33744
	* readelf.c (special_defined_section_index): New.
	(get_32bit_section_headers): Don't warn special section indexes
	in the sh_link field.
	(get_64bit_section_headers): Likewise.
	(process_section_headers): Print special defined section names.

gas/

	PR gas/33744
	* testsuite/gas/elf/elf.exp: Run PR gas/33744 tests.
	* testsuite/gas/elf/sh-link-abs-1.d: New file.
	* testsuite/gas/elf/sh-link-abs-2.d: Likewise.
	* testsuite/gas/elf/sh-link-abs-3-32.d: Likewise.
	* testsuite/gas/elf/sh-link-abs-3-64.d: Likewise.
	* testsuite/gas/elf/sh-link-abs-4-32.d: Likewise.
	* testsuite/gas/elf/sh-link-abs-4-64.d: Likewise.
	* testsuite/gas/elf/sh-link-abs.s: Likewise.
	* testsuite/gas/elf/sh-link-common-1.d: Likewise.
	* testsuite/gas/elf/sh-link-common-2.d: Likewise.
	* testsuite/gas/elf/sh-link-common-3-32.d: Likewise.
	* testsuite/gas/elf/sh-link-common-3-64.d: Likewise.
	* testsuite/gas/elf/sh-link-common-4-32.d: Likewise.
	* testsuite/gas/elf/sh-link-common-4-64.d: Likewise.
	* testsuite/gas/elf/sh-link-common.s: Likewise.
	* testsuite/gas/elf/sh-link-large-common-1.d: Likewise.
	* testsuite/gas/elf/sh-link-large-common-2.d: Likewise.
	* testsuite/gas/elf/sh-link-large-common-3.d: Likewise.
	* testsuite/gas/elf/sh-link-large-common-4.d: Likewise.
	* testsuite/gas/elf/sh-link-large-common.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2026-01-14 06:59:28 +08:00
Andreas Schwab
1b87d9d732 objcopy: Set bfd_error_system_call before reporting error from make_tempname 2026-01-13 11:20:02 +01:00
Andreas Schwab
dc0c542c7c readelf: Handle R_RISCV_SET32 2026-01-13 11:20:02 +01:00
Alan Modra
ff31f2e09d Set ELF_OSABI for x86 and sparc
The idea of this patch is to match the solaris target over other
targets if e_ident contains ELFOSABI_SOLARIS.  The solaris target will
continue to recognise ELFOSABI_NONE objects.

This has the side effect of disabling gnu features that require
ELFOSABI_GNU, such as ifuncs.  I think that is correct, so I've made
the required testsuite changes to fix the resulting regressions:
FAIL: nm --ifunc-chars (assembly)
FAIL: mbind sections without SHF_ALLOC

The patch also sets ELF_OSABI for the gnu x86 and sparc targets,
for the same reason as the solaris targets.  This doesn't mean object
files will automatically be marked ELFOSABI_GNU/LINUX.  As before that
will only happen when certain GNU extensions are present.

bfd/
	* elf32-i386.c: Define ELF_OSABI for solaris and gnu targets.
	* elf32-sparc.c: Likewise.
	* elf64-sparc.c: Likewise.
	* elf64-x86-64.c: Likewise.
	* format.c (bfd_check_format_matches): Bump match_priority
	for matching e_ident EI_OSABI.
binutils/
	* testsuite/binutils-all/nm.exp: Use !supports_gnu_osabi to
	disable ifunc test.
gas/
	* testsuite/gas/elf/section13.d: Only run on supports_gnu_osabi
	targets.  Remove xfails.
2026-01-04 19:30:16 +10:30
Alan Modra
39d685b15e elf_backend_data typedef
"const struct elf_backend_data" appears many places in the source,
and in some cases makes a line too long without wrapping.  This patch
introduces a "typedef const struct elf_backend_data elf_backend_data;"
and uses it throughout binutils sources, with a few exceptions for c++
use of header files.
2026-01-04 13:14:22 +10:30
Alan Modra
c8f306af2f Update year range in copyright notice of binutils files
Avoid warnings about invalid escapes in etc/update-copyright.py by
using raw strings, add BinutilsFilter to skip psql.rc and add
"Kalray SA." as another copyright holder.
2026-01-01 23:22:14 +10:30
Lulu Cai
8bea934667 LoongArch: Add disassembly support for ud ui5
ud ui5, also known as amswap.w rd,$r1,rj(rd==rj), is displayed as
"ud ui5" by default during disassembly. Alternatively, the original
instruction can be printed using the objdump -M no-aliases.

To implement this support, a format specifier "ru0:5,ru5:5" for ud is
applied exclusively during disassembly. This specifier indicates that
registers should be printed using their corresponding numeric values,
and when the instruction is identified as ud, only a single parameter
is displayed.

binutils/

        * testsuite/binutils-all/loongarch64/dis-amswap-ud-noaliases.d:
	  New test.
        * testsuite/binutils-all/loongarch64/dis-amswap-ud.d: New test.
        * testsuite/binutils-all/loongarch64/dis-amswap-ud.s: New test.

gas/

        * testsuite/gas/loongarch/macro_ud.d: Update test.

include/

        * opcode/loongarch.h: New macro.

opcodes/

        * loongarch-dis.c (get_loongarch_opcode_by_binfmt): Correct match `ud`.
        (dis_one_arg): Disassemble the `ud` parameter.
        * loongarch-opc.c: Add opcode for "ud" alias.
2025-12-20 10:49:47 +08:00
Peter Damianov
bb80c91f5a Add windres to TOOL_PROGS
I sent a patch to GCC adding support for passing .rc and .res files to the
driver directly, allowing support for doing things like:

gcc file.c file.rc -o file.exe

However, binutils doesn't install windres into the tooldir, so by default, gcc
will be unable to find windres. This patch adds windres to TOOL_PROGS so this
can work.

binutils/ChangeLog:

	* Makefile.am (TOOL_PROGS): Add windres.
	* Makefile.in: Regenerate.

Signed-off-by: Peter Damianov <peter0x44@disroot.org>
2025-12-19 08:52:13 +01:00
Jan Beulich
1669d187cb MAINTAINERS: move three people to "Past Maintainers"
... for the respective emails bouncing. Thanks to them for their past
work. Sadly this renders KVX and XCOFF unmaintained.

While there also restore alphabetic sorting of the list.
2025-12-19 08:51:29 +01:00
Vignesh Balasubramanian
e2b607517e bfd: Add minimal support to handle note that describes xsave layout
This note section is already supported by Linux kernel.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/x86/kernel/fpu/xstate.c?id=ba386777a30b38dabcc7fb8a89ec2869a09915f7

Co-Authored-By: Jini Susan George <jinisusan.george@amd.com>
2025-12-12 14:59:49 +01:00
Alan Modra
bf85c50303 lto-wrapper warning note
Current gcc adds a note to the LTO "using serial compilation" warning.

	* lib/binutils-common.exp (prune_warnings_extra): Remove
	lto-wrapper note.
2025-12-09 11:01:09 +10:30
Alan Modra
b33d520b42 Revert "Re: Add warning message to readelf for local symbols"
This reverts commit f70242a98f.
Nick already applied this..
2025-12-09 07:33:39 +10:30
Alan Modra
f70242a98f Re: Add warning message to readelf for local symbols
Limit the warning to ET_REL.
2025-12-09 07:23:34 +10:30
Alan Modra
6d7e5bcca5 readelf: Only check for out of bounds local symbols in object files 2025-12-08 15:12:26 +00:00
Nick Clifton
45cf0b8293 readelf: Do not warn about mapping symbols that extend beyond the end of mergeable sections 2025-12-08 12:18:03 +00:00
Alan Modra
44b79abd0f PR 33701, abort in byte_get_little_endian
PR 33701
	* dwarf.c (process_debug_info): Set debug_info_p NULL when
	DEBUG_INFO_UNAVAILABLE.
2025-12-08 19:54:03 +10:30
Alan Modra
ea4bc025ab PR 33698 and PR 33700
It is possible for dump_relocations to return on an error from
slurp_rela_relocs or slurp_rel_relocs without writing to
"all_relocations".  In that case an uninitialised r_symbol is passed
to free at the end of process_got_section_contents.

	PR 33698
	PR 33700
	* readelf.c (update_all_relocations): Zero array.  Remove
	unnecessary casts.
2025-12-08 19:53:40 +10:30
Alan Modra
66a3492ce6 PR 33697, fuzzer segfault
PR 33697
	* readelf.c (process_relocs): Don't segfault on no sections.
2025-12-08 19:53:35 +10:30
H.J. Lu
c6ba94c86b elf: Add SHT_SUNW_ctf and SHT_SUNW_symnsort
On Solaris 11.4, there is SHT_SUNW_symnsort and no SHT_SUNW_symtabnsort.
SHT_SUNW_symnsort is defined to 0x6fffffec, which is the same as
SHT_SUNW_symtabnsort.  There is also SHT_SUNW_ctf.  Add SHT_SUNW_ctf and
rename SHT_SUNW_symtabnsort to SHT_SUNW_symnsort.  Move SHT_SUNW_phname
after SHT_SUNW_symnsort.

binutils/

	* readelf.c (get_solaris_section_type): Add SHT_SUNW_ctf and
	SHT_SUNW_symnsort.  Move SHT_SUNW_phname after SHT_SUNW_symnsort.
	Remove SHT_SUNW_symtabnsort.

include/

	* elf/common.h (SHT_SUNW_ctf): New.
	(SHT_SUNW_symtabnsort): Renamed to ...
	(SHT_SUNW_symnsort): This.
	(SHT_SUNW_phname): Moved after SHT_SUNW_symnsort.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-12-08 15:19:12 +08:00
Nick Clifton
a5818f278a Add warning message to readelf for local symbols that reference beyond the end of a mergeable section. 2025-12-04 11:29:47 +00:00
H.J. Lu
bfaa4d5816 copy_object: Re-indent
* objcopy.c (copy_object): Re-indent.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-12-04 08:47:47 +08:00
Nick Clifton
40a04cee22 Synchronize the dwarf2.h and dwarf2.def files with their gcc counterparts, bringing the definitions of DW_AT_language_name and DW_AT_language_version. Add code to binutils/dwarf.c to display these attributes. 2025-12-02 11:06:01 +00:00
Alan Modra
cdb728d4da PR 33637, abort in byte_get
When DWARF5 support was added to binutils in commit 77145576fa,
the loop over CUs in process_debug_info set do_types when finding a
DW_UT_type unit, in order to process the signature and type offset
entries.  Unfortunately that broke debug_information/debug_info_p
handling, which previously was allocated and initialised for each unit
in .debug_info.  debug_info_p was NULL when processing a DWARF4
.debug_types section.  After the 77145576fa change it was possible
for debug_infp_p to be non-NULL but point to zeroed data, in
particular a zeroed offset_size.  A zero for offset_size led to the
byte_get_little_endian abort triggered by the fuzzer testcase.

I haven't investigated whether there is any need for a valid
offset_size when processing a non-fuzzed DWARF4 .debug_types section.
Presumably we'd have found that out in the last 6 years if that was
the case.  We don't want to change debug_information[] for
.debug_types!

	PR 33637
	* dwarf.c (process_debug_info): Don't change DO_TYPES flag bit
	depending on cu_unit_type.  Instead test cu_unit_type along
	with DO_TYPES to handle signature and type_offset for a type
	unit.  Move find_cu_tu_set_v2 call a little later.
2025-11-30 13:44:50 +10:30
Alan Modra
0efa88d649 Re: bfd/Dwarf: Add suitable defines to use at call and use sites
Commit 1f7e70ddd2 made changes to process_debug_info parameters
without adjusting the function comment to suit.  Fix that, and tidy
do_printing flag use.

	* dwarf.c (process_debug_info): Edit function comment.
	Make do_printing a bool.  Fold DO_LOC test into do_printing.
2025-11-30 13:44:50 +10:30
Guillaume VACHERIAS
1f7e70ddd2 bfd/Dwarf: Add suitable defines to use at call and use sites
use do_loc and do_types arguments into a signle unsigned int do_flags for
better code readability.

binutils/

	* dwarf.c (DO_LOC, DO_TYPES): Define.
	(process_debug_info): Change arguments do_loc and do_types
	to a single unsigned int do_flags.
	(find_cu_tu_set_v2): Change parameter do_types from int to bool.

Signed-off-by: Guillaume VACHERIAS <guillaume.vacherias@foss.st.com>
2025-11-28 09:47:43 +01:00
Alan Modra
a6feabfb8f replace tail with sed
The default Solaris tail doesn't support "tail -n +4", apparently.
Use sed instead.

	PR 33396
	* testsuite/binutils-all/objdump.exp: Replace tail with an
	equivalent sed expression in dwarf5 objdump -Wi test.
2025-11-25 07:50:17 +10:30
Michael Matz
365cf9bd15 Make readelf not print 'foo@@' for normal symbols
when a symbol 'foo' is exported and non-hidden and hence is
available for resolving from other objects it's unreasonable
for readelf to print it as 'foo@@'.  If it's not available
for unversioned resolving because its version is hidden
(but without name), then continue printing it as 'foo@' to
indicate that something special goes on.
2025-11-24 15:22:00 +01:00
Alan Modra
d37a8694b2 Re: dlltool memory leaks
I missed one needed strdup of symbol names, needed since the original
symbol name memory is freed on bfd_close.

	PR 33651
	* dlltool.c (scan_filtered_symbols): xstrdup symbol name.
2025-11-22 16:58:34 +10:30
Alan Modra
455446bbdc PR 33639 .debug_loclists output
The fuzzed testcase in this PR prints an almost endless table of
offsets, due to a bogus offset count.  Limit that count, and the total
length too.

	PR 33639
	* dwarf.c (display_loclists_unit_header): Return error on
	length too small to read header.  Limit length to section
	size.  Limit offset count similarly.
2025-11-22 09:52:18 +10:30
Alan Modra
598704a00c PR 33638, debug_rnglists output
The fuzzed testcase in this PR continuously outputs an error about
the debug_rnglists header.  Fixed by taking notice of the error and
stopping output.  The patch also limits the length in all cases, not
just when a relocation is present, and limits the offset entry count
read from the header.  I removed the warning and the test for relocs
because the code can't work reliably with unresolved relocs in the
length field.

	PR 33638
	* dwarf.c (display_debug_rnglists_list): Return bool.  Rename
	"inital_length" to plain "length".  Verify length is large
	enough to read header.  Limit length to rest of section.
	Similarly limit offset_entry_count.
	(display_debug_ranges): Check display_debug_rnglists_unit_header
	return status.  Stop output on error.
2025-11-22 09:22:10 +10:30
Alan Modra
f5336048ae bfd_copy_private_symbol_data
Allow copy_private_symbol_data to replace osym if a target desires.
Change isym similarly for symmetry.  The idea is to make it possible
to give the asymbol an output target specific extension.  Some
targets, eg. som, use such an extension when outputting symbols,
behaving badly if the input object is not som.  There are no
functional changes in this patch; It just changes the signatures.

bfd/
	* elf-bfd.h (_bfd_elf_copy_private_symbol_data): Replace
	asymbol* params with asymbol**.
	* elf.c (_bfd_elf_copy_private_symbol_data): Likewise.
	* libbfd-in.h (_bfd_bool_bfd_asymbol_bfd_asymbol_true): Likewise.
	* libbfd.c (_bfd_bool_bfd_asymbol_bfd_asymbol_true): Likewise.
	* mach-o.c (bfd_mach_o_bfd_copy_private_symbol_data): Likewise.
	* mach-o.h (bfd_mach_o_bfd_copy_private_symbol_data): Likewise.
	* plugin.c (bfd_plugin_bfd_copy_private_symbol_data): Likewise.
	* som.c (som_bfd_copy_private_symbol_data): Likewise.
	* targets.c (bfd_target <_bfd_copy_private_symbol_data>): Likewise.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
binutils/
	* objcopy.c (copy_object): Adjust bfd_copy_private_symbol_data call.
gas/
	* symbols.c symbol_clone): Adjust bfd_copy_private_symbol_data call.
2025-11-22 09:13:26 +10:30
Ezra Sitorus
3c3f58814b bfd/ELF: Core file support for AArch64 FPMR
The Floating Point Mode Register is a new register which controls the
behaviour of FP8 instructions. This is handled by the Linux kernel
through a new NT_ARM_FPMR register set.

This patch adds required code to support core file dumps with
NT_ARM_FPMR in them.
2025-11-17 12:47:09 +00:00
Alan Modra
35e1c33162 objcopy binary symbol type check
This exposes an error on alpha-linux-gnuecoff where the start and end
syms are given the wrong storage class.

	* testsuite/binutils-all/objcopy.exp (binary_symbol): Tighten
	symbol type checking.
2025-11-14 11:50:59 +10:30
Alan Modra
96b8a8a633 objcopy binary symbol test
A small tidy that allows other symbols or warnings to appear in nm
output, and works around the case problem of windows drive letters
by simply omitting the $srcdir match.

	* testsuite/binutils-all/objcopy.exp (binary_symbol): Check
	objcopy and nm return status.  Don't repeat prune_warnings
	already done in binutils_run.  Match each symbol separately,
	reporting which match failed on a failure.  Don't match
	$srcdir in implicit test.
2025-11-11 15:49:55 +10:30
Dennis Dyallo
90a0b08bd0 readelf: Fix typo in --version-info documentation
Change "it they exist" to "if they exist" in the description
of the --version-info option in the readelf man page.
2025-11-10 11:37:43 +01:00
H.J. Lu
2be0f2da21 readelf: Display the base symbol version as empty string
Update readelf to display the base symbol version as

Symbol table for image contains 5 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar@@
     2: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VERS_1
     3: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar@@VERS_1
     4: 0000000000003000     0 OBJECT  GLOBAL DEFAULT   10 foo@

instead of

Symbol table for image contains 5 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar
     2: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VERS_1
     3: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar@@VERS_1
     4: 0000000000003000     0 OBJECT  GLOBAL DEFAULT   10 foo

That is bar@@ and foo@ vs bar and foo.

binutils/

	PR binutils/33599
	* readelf.c (process_version_sections): Replace 0x8001 with
	(VERSYM_HIDDEN | VERSYM_BASE).
	(get_symbol_version_string): Likewise.  Return "" for the base
	version.

include/

	PR binutils/33599
	* elf/common.h (VERSYM_BASE): New.

ld/

	PR binutils/33599
	* testsuite/ld-elf/pr33599.d: New file.
	* testsuite/ld-elf/pr33599.map: Likewise.
	* testsuite/ld-elf/pr33599.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-11-08 06:39:42 +08:00
Jose E. Marchesi
0e7ca0fdc8 binutils/MAINTAINERS: list new gprofng maintainers
As agreed with Nick I will be co-maintaining gprofng moving forward
along with Claudiu.  Update the MAINTAINERS file accordingly.
2025-11-05 20:33:07 +01:00
Nick Clifton
12ef7d5b7b Remove call to abort in the DGB debug format printing code, thus allowing the display of a fuzzed input file to complete without triggering an abort.
PR 33448
2025-11-03 11:49:02 +00:00
Alan Modra
87b6078fc2 tidy m4 plugin config support
In CLANG_PLUGIN_FILE it is possible for plugin_file to be non-NULL
when LLVMgold.so does not exist.

configure output is messy, with results not printed against their
  "checking.." line, eg.
checking for clang... (cached) yes
checking for clang plugin file... checking for x86_64-pc-linux-gnu-ar... (cached) ar --plugin /usr/lib/llvm-20/lib/clang/20/../../LLVMgold.so
/usr/lib/llvm-20/lib/clang/20/../../LLVMgold.so

This patch fixes those problems, and a similar interposition of other
configure output between AC_MSG_CHECKING and AC_MSG_RESULT in
gcc-plugin.m4.  It also tidies some of the message text, and makes
similar code in gcc-plugin.m4 and clang-plugin.m4 a little more
consistent.

config/
	* clang-plugin.m4 (CLANG_PLUGIN_FILE): Don't place checks for
	tools (llvm-config, ar) inside AC_MSG_CHECKING..AC_MSG_RESULT
	for clang plugin file.  Clear plugin_file before loop exit.
	(CLANG_PLUGIN_FILE_FOR_TARGET): Similarly.
	* gcc-plugin.m4 (GCC_PLUGIN_OPTION): Similarly.
	(GCC_PLUGIN_OPTION_FOR_TARGET): Correct AC_MSG_CHECKING.  Tidy
	return code.
binutils/
	* testsuite/lib/binutils-common.exp <llvm_plug_opt>: Set for
	non-native.
	* configure: Regenerate.
/
	* configure: Regenerate.
bfd/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gdb/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
gprofng/
	* configure: Regenerate.
	* libcollector/configure: Regenerate.
ld/
	* configure: Regenerate.
libbacktrace/
	* configure: Regenerate.
libctf/
	* configure: Regenerate.
libiberty/
	* configure: Regenerate.
libsframe/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
sim/
	* configure: Regenerate.
zlib/
	* configure: Regenerate.
2025-11-03 10:59:50 +10:30
Alan Modra
0bb5cbb9b4 Pass -B to objcopy binary symbol test
objcopy -I binary -O some_coff_target does not currently work without
choosing a valid arch with -B.  This used to be the case for ELF
targets too, until commit 6765ee1825.

	* testsuite/binutils-all/objcopy.exp (binary_symbol): Pass
	-B arch to objcopy.  Choose different output object files for
	the two tests.
2025-10-31 09:44:38 +10:30
Alon Bar-Lev
6fa97b38ff objcopy: add option to specify custom prefix for symbol of binary input
When using --input-target=binary, objcopy currently derives symbol names
from a mangled version of the input file name.  This approach can lead to
unpredictable results, as the generated symbols depend on the file path and
working directory.

This patch introduces a new option:

  --binary-symbol-prefix <prefix> Use <prefix> as the base symbol name for
                                    the input file (default: derived from
                                    file name)

It allows specifying an explicit symbol prefix, while preserving the existing
behavior as a fallback.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2025-10-30 15:32:52 +10:30
Pietro Monteiro
4cfcc5412c objcopy: Don't add zstd to the debug compression options if not available
If zstd is not available or was intentionally disabled by the user
don't add it to the list of the available options to compress debug
sections when showing usage.

binutils/
	* objcopy.c (copy_usage): Only output
	--compress-debug-sections=zstd if HAVE_ZSTD.
2025-10-22 13:49:05 +10:30
Jens Remus
5079bf8959 gas: sframe: Represent .cfi_undefined RA as FRE without offsets
In DWARF CFI an "undefined" register rule for the return address (RA)
register indicates that there is no return address and the stack trace
is complete.

Represent DW_CFA_undefined as SFrame FRE without any offsets, so that a
stack tracer implementation can use this as indication that an outermost
frame has been reached and the stack trace is complete.

This representation is backward compatible, as existing stack tracers
should already deal with the case, that an SFrame FRE a so far invalid
offset count of zero and stop the trace.

include/
	* sframe.h (SFRAME_V2_FRE_RA_UNDEFINED_P): New macro to test
	FRE info word for RA undefined (FRE without any offsets).

binutils/
	* NEWS: Mention SFrame can represent an undefined RA as FRE
	without	any offsets.

gas/
	* gen-sframe.h (struct sframe_row_entry): Add ra_undefined_p
	flag.
	* gen-sframe.c (sframe_row_entry_new): Initialize ra_undefined_p
	flag to not set.
	(sframe_row_entry_initialize): Treat ra_undefined_p flag as
	sticky.
	(sframe_fre_set_ra_track): Reset ra_undefined_p flag.
	(sframe_xlate_do_restore): Reset ra_undefined_p flag to saved
	state.
	(sframe_xlate_do_same_value): Reset ra_undefined_p flag.
	(sframe_xlate_do_cfi_undefined): For RA set ra_undefined_p flag.
	(output_sframe_row_entry): Represent RA undefined as SFrame FRE
	without any offsets and FRE info word fields zeroed.
	* NEWS: Mention assembler represents .cfi_undefined RA in SFrame
	as FRE without any offsets.

libsframe/
	* doc/sframe-spec.texi (Changes from Version 1 to Version 2):
	Mention that a SFrame FRE without any offsets flag indicates an
	outermost frame with an undefined RA.
	(fre_offset_count): Document that a FRE offset count of zero
	indicates an outermost frame with an undefined RA.
	* sframe.c (sframe_get_fre_ra_undefined_p): Use macro
	SFRAME_V2_FRE_RA_UNDEFINED_P.
	(sframe_fre_get_fp_offset, sframe_fre_get_ra_offset): Do not
	return fixed FP/RA offset if RA undefined.
	* sframe-dump.c (dump_sframe_func_with_fres): Show FRE without
	any offsets as "RA undefined".

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe.exp: Run tests for .cfi_undefined RA
	on AArch64, s390x, and x86-64.
	* gas/cfi-sframe/cfi-sframe-aarch64-ra-undefined-1.d: Add test
	for .cfi_undefined RA on AArch64.
	* gas/cfi-sframe/cfi-sframe-aarch64-ra-undefined-1.s: Likewise.
	* as/cfi-sframe/cfi-sframe-s390x-ra-undefined-1.d: Add test
	for .cfi_undefined RA on s390x.
	* gas/cfi-sframe/cfi-sframe-s390x-ra-undefined-1.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-x86_64-ra-undefined-1.d: Add test
	for .cfi_undefined RA on x86-64.
	* gas/cfi-sframe/cfi-sframe-x86_64-ra-undefined-1.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-10-15 17:45:48 +02:00