Commit Graph

122950 Commits

Author SHA1 Message Date
Ezra Sitorus
621c0c3469 aarch64: Support for FEAT_LSUI
FEAT_LSUI introduces unprivileged variants of load and store instructions so
that clearing PSTATE.PAN is never required in privileged software.
2025-07-11 12:53:19 +01:00
Ezra Sitorus
b80240ecba aarch64: Support for FEAT_PCDPHINT
FEAT_PCDPHINT - Producer-consumer data placement hints - is an optional
ISA extension that provides hint instructions to indicate:
- a store in the current execution thread is generating data at a specific
location, which a thread of execution on one or more other observers is
waiting on.
- the thread of execution on the current PE will read a location that may not
yet have been written with the value to be consumed.

This extension introduces:
- STSHH, a hint instruction, with operands (policies) keep and strm
- PRFM *IR*, a new prefetch memory operand.
2025-07-11 12:53:09 +01:00
Jens Remus
2b1dd3156b s390: Announce s390 64-bit (s390x) SFrame V2 support in binutils
The preceding commits add s390 64-bit (s390x) support in binutils to
generate SFrame stack trace information (.sframe section) in the
assembler from CFI directives (with option --gsframe), generate .sframe
section for linker-generated .plt section in the linker, and dump SFrame
information in objdump and readelf (with option --sframe).

binutils/
	* NEWS: Announce s390 64-bit (s390x) SFrame V2 support in
	as, ld, objdump, and readelf.

gas/
	* NEWS: Update s390 64-bit (s390x) SFrame V2 support in
	assembler.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
e2dfd75e00 s390: sframe: Test handling of .cfi_def_cfa_register
Port x86-64 test for handling of .cfi_def_cfa_register from commit
3602da6fa2 ("gas: sframe: fix handling of .cfi_def_cfa_register")
to s390x.

gas/testsuite/
	PR gas/32879
	* gas/cfi-sframe/cfi-sframe.exp: Add new test for handling of
	.cfi_def_cfa_register on s390x.
	* gas/cfi-sframe/cfi-sframe-s390x-3.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-3.s: Likewise.

Bug: https://sourceware.org/PR32879
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
95847aaba1 s390: Store SFrame CFA offset adjusted and scaled down
In SFrame V2 the size of the offsets following an SFrame FRE can be
either signed 8-bit, 16-bit, or 32-bit integer, with the largest offset
determining their size:
  1. CFA offset from CFA base register
  2. RA (stack save slot) offset from CFA, usually -48 on s390x if saved
  3. FP (stack save slot) offset from CFA, usually -72 on s390x if saved
The FP and RA offsets from CFA, when FP/RA saved on the stack, usually
have fixed values that fit into signed 8-bit SFrame offsets.  Likewise
the DWARF register numbers on s390x of general registers (GR; 0-15) and
floating-point registers (FPR; 16-31), when FP/RA saved in registers.
With that the CFA offset from CFA base register has the greatest impact
on the signed SFrame offset size.

The s390x ELF ABI defines the stack pointer (SP) to be 8-byte aligned
[1] and the CFA as SP at call site + 160 [2].  The CFA offset from CFA
base register is therefore always a multiple of 8.

On s390x store the SFrame CFA offset from CFA base register scaled down
by the s390x-specific CFA alignment factor of 8, in addition to the
adjustment by the s390x-specific CFA adjustment of -160, to further
improve the use of signed 8-bit SFrame offsets.  This is similar to the
DWARF data alignment factor getting factored out from certain offsets
stored in DWARF CFI.

[1]: s390x ELF ABI, sections "Register Roles" and "Stack Frame
     Allocation", https://github.com/IBM/s390x-abi/releases
[2]: s390x ELF ABI, commit 4e38ad9c8a88 ("Document the CFA"),
     https://github.com/IBM/s390x-abi/commit/4e38ad9c8a88

include/
	* sframe.h (SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR): Define
	s390x-specific CFA offset alignment factor.
	(SFRAME_V2_S390X_CFA_OFFSET_ENCODE,
	SFRAME_V2_S390X_CFA_OFFSET_DECODE): Scale down/up by
	SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR.

libsframe/
	* doc/sframe-spec.texi (s390x,
	SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR): Document s390x-
	specific CFA offset alignment factor.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
c1056133a3 s390: Store SFrame CFA offset adjusted
In SFrame V2 the size of the offsets following an SFrame FRE can be
either signed 8-bit, 16-bit, or 32-bit integer, with the largest offset
determining their size:
  1. CFA offset from CFA base register
  2. RA (stack save slot) offset from CFA, usually -48 on s390x if saved
  3. FP (stack save slot) offset from CFA, usually -72 on s390x if saved
The FP and RA offsets from CFA, when FP/RA saved on the stack, usually
have fixed values that fit into signed 8-bit SFrame offsets.  Likewise
the DWARF register numbers on s390x of general registers (GR; 0-15) and
floating-point registers (FPR; 16-31), when FP/RA saved in registers.
With that the CFA offset from CFA base register has the greatest impact
on the signed SFrame offset size.

The s390x ELF ABI [1] defines the CFA as stack pointer (SP) at call
site +160. [2]  Therefore the minimum CFA offset from CFA base register
on s390x is 160.  This does not fit into a signed 8-bit integer and
therefore effectively prevents any use of signed 8-bit SFrame offsets
on s390x.

For s390x store the CFA offset from CFA base register adjusted by -160
to enable the use of signed 8-bit SFrame offsets.

[1]: s390x ELF ABI, https://github.com/IBM/s390x-abi/releases
[2]: s390x ELF ABI, commit 4e38ad9c8a88 ("Document the CFA"),
     https://github.com/IBM/s390x-abi/commit/4e38ad9c8a88

include/
	* sframe.h (SFRAME_S390X_CFA_OFFSET_ADJUSTMENT): Define
	s390x-specific CFA offset adjustment.
	(SFRAME_V2_S390X_CFA_OFFSET_ENCODE,
	SFRAME_V2_S390X_CFA_OFFSET_DECODE): New s390x-specific
	macros.  Use SFRAME_S390X_CFA_OFFSET_ADJUSTMENT to en-/decode
	CFA offset.

bfd/
	* elf64-s390.c (elf_s390x_sframe_plt_fre): Use
	SFRAME_V2_S390X_CFA_OFFSET_ENCODE on CFA offset to store it
	adjusted and switch to 8-bit offsets.

gas/
	* gen-sframe.c (sframe_fre_set_cfa_offset): For s390x use
	SFRAME_V2_S390X_CFA_OFFSET_ENCODE on CFA offset to store it
	adjusted.
	(sframe_fre_get_cfa_offset): New helper.  For s390x use
	SFRAME_V2_S390X_CFA_OFFSET_DECODE on CFA offset to undo its
	adjustment.
	(sframe_xlate_do_def_cfa_register): Use new helper
	sframe_fre_get_cfa_offset.

libsframe/
	* sframe.c (sframe_fre_get_cfa_offset): For s390x use
	SFRAME_V2_S390X_CFA_OFFSET_DECODE on CFA offset to undo its
	adjustment.
	* doc/sframe-spec.texi (s390x,
	SFRAME_S390X_CFA_OFFSET_ADJUSTMENT,
	SFRAME_V2_S390X_CFA_OFFSET_ENCODE,
	SFRAME_V2_S390X_CFA_OFFSET_DECODE): Document s390x-specific
	adjustment of CFA offset.

libsframe/testsuite/
	* libsframe.find/plt-findfre-2.c (add_plt0_fde, add_pltn_fde):
	Use SFRAME_V2_S390X_CFA_OFFSET_ENCODE to enable use of 1-byte
	SFrame offsets.

Suggested-by: Indu Bhagat <indu.bhagat@oracle.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
0d4d5a2633 libsframe: Add test for PLT0 and PLTN with only one FRE each
On s390x the PLT0 and PLTN entries are described with one SFrame FRE
each.  Add a test case for this particularity.

libsframe/testsuite/
	* libsframe.find/find.exp (plt-findfre-2): Add new test.
	* libsframe.find/plt-findfre-2.c: New test for PLT0 and PLTN
	with only one FRE each.
	* libsframe.find/local.mk (plt-findfre-2): Add new test.

libsframe/
	* Makefile.in: Regenerate.
2025-07-11 10:29:40 +02:00
Jens Remus
22472454fa s390: Add SFrame stack trace information for .plt section
Enable SFrame stack tracing through PLT entries.  Based on x86-64.

On s390x both PLT0 and PLTn entries are 32-bytes in size.  Their code
neither alters the stack pointer (SP), frame pointer (FP), nor return
address (RA) registers.  Therefore the PLT0 can be represented using
a SFrame FDE of type PCINC with a single SFrame FRE and the PLTn can
be represented using a SFrame FDE of type PCMASK, with a repetition
block size of 32 (PLTn size), and a single SFrame FRE.

Note that as both the PLT0 entry and the PLTn entries have equal size
and could both be represented using the identical SFrame FRE, the whole
.plt section on s390x could be represented using a single SFrame FDE of
type PCMASK, with a repetition block size of 32 (PLT0 and PLTn size),
and a single SFrame FRE.  Keep the x86-64 logic with separate SFrame
FDEs for PLT0 and PLTn, to ease potential generalization of the .sframe
for .plt generation logic among architectures.

bfd/
	* elf64-s390.c: Include sframe.h and sframe-api.h.
	(PLT_SFRAME_FDE_START_OFFSET, SFRAME_PLT0_MAX_NUM_FRES,
	SFRAME_PLTN_MAX_NUM_FRES, elf_s390x_sframe_plt_fre,
	elf_s390x_sframe_plt): New .sframe template for .plt section.
	(elf_s390_link_hash_table): Add plt_cfe_ctx, plt_sframe, and
	sframe_plt fields.
	(_bfd_s390_elf_create_sframe_plt): New function.  Fill in
	.sframe section for .plt section.
	(_bfd_s390_elf_write_sframe_plt): New function.  Write .sframe
	section.
	(elf_s390_create_dynamic_sections): Create .sframe section for
	.plt section.
	(elf_s390_late_size_sections): Call
	_bfd_s390_elf_create_sframe_plt and
	_bfd_s390_elf_write_sframe_plt.
	(elf_s390_finish_dynamic_sections): Write .plt section start
	into .sframe FDE covering .plt section.  Call
	_bfd_elf_merge_section_sframe on htab->plt_sframe.

ld/
	* NEWS: Add news entry.

ld/testsuite/
	* ld-s390/s390.exp: Add new test.
	* ld-s390/sframe-plt-1.d: New linker-generated .sframe for .plt
	test.
	* ld-s390/sframe-simple-1.d: Adjust expected test output due to
	linker-generated .sframe for .plt.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
955570f097 s390: Represent FP without RA saved in SFrame
If an architecture uses both SFrame RA and FP tracking SFrame assumes
that the RA offset is the 2nd offset and the FP offset is the 3rd offset
following a SFrame FRE.  An architecture does not necessarily need to
save both on the stack (or in register) at the same time or even at all.
SFrame cannot represent FP without RA saved on stack (or in a register),
since it cannot distinguish whether the 2nd offset is the RA or FP
offset.

For s390x use an invalid SFrame RA offset from CFA value of zero as
padding to represent the FP being saved when the RA is not saved.  This
aligns with the existing invalid SFrame fixed RA offset from CFA value
of zero.  In a stack tracer this then also naturally falls into place,
as it can skip restoring the RA in the topmost frame, if both the fixed
RA offset (from SFrame header) and the RA offset (from FDE) are zero,
without any need to test architecture-specific flags.

include/
	* sframe.h (SFRAME_FRE_RA_OFFSET_INVALID): New define.  Used as
	padding offset.
	* sframe-api.h (sframe_fre_get_ra_offset): Add comment that for
	s390x an offset value of SFRAME_FRE_RA_OFFSET_INVALID indicates
	that the RA is not saved.

gas/
	* gen-sframe.c (get_fre_num_offsets): For s390x account padding
	RA offset, if FP without RA saved.
	(sframe_get_fre_offset_size): Likewise.
	(output_sframe_row_entry): For s390x write a padding RA offset,
	if FP without RA needs to be represented.
	(sframe_do_fde): Enable FP without RA saved to be represented
	on s390x.

libsframe/
	* sframe.c (sframe_fre_get_ra_offset): Add comment that for
	s390x an offset value of SFRAME_FRE_RA_OFFSET_INVALID indicates
	that the RA is not saved.
	* sframe-dump.c (dump_sframe_func_with_fres): Treat invalid
	RA offsets as if they were undefined.  Display them as "U"
	to distinguish them.
	* doc/sframe-spec.texi (s390x): Document s390x-specific use of
	SFRAME_FRE_RA_OFFSET_INVALID to represent FP without RA saved.

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe.exp: Rename s390x-specific tests.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-offset-err-1.s: Rename
	to ...
	* cfi-sframe/cfi-sframe-s390x-fpra-offset-err-1.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-offset-2.s: This.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-offset-2.d: Likewise.
	Update test verification pattern accordingly.
	* cfi-sframe/cfi-sframe-s390x-fpra-register-err-1.s: Rename
	to ...
	* cfi-sframe/cfi-sframe-s390x-fpra-register-err-1.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-2.s: This.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-2.d: Likewise.
	Update test verification pattern accordingly.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
61b808e087 s390: Represent FP/RA saved in register in SFrame
GCC on s390x, when in a leaf function, can be observed to save the
frame pointer (FP) and/or return address (RA) register in a floating-
point registers (FPR) instead of on the stack.  This is declared using
the following CFI directive:

  .cfi_register <fp/ra-regnum>, <fpr-regnum>

SFrame cannot represent the FP and/or RA being saved in another
register.  It does only track the CFA base register (SP/FP), CFA offset
from CFA base register, and FP and RA save area offsets from CFA.

On s390x the FP and/or RA are only saved in another FPR when in a leaf
function.  That is a function that does not call any other function.
Therefore it can ever only be the topmost function in a call chain.
An unwinder by default has access to all registers of the function that
is the topmost on the call stack.  Therefore no further information
is required to restore FP/RA from the FPR.

Represent FP/RA saved in another register on s390x, by encoding the
DWARF register number shifted by one to the left with the least-
significant bit set in the offset as follows:

  offset = (regnum << 1) | 1

The use of the least-significant bit of the offset as indication is
possible, as the stack pointer (SP), the CFA, and any register save
area slots are 8-byte aligned according to the s390x ELF ABI:
- The stack pointer (SP) "shall maintain an 8-byte alignment". [1]
- The CFA is defined as SP at call site +160. [2]
- Pointers and 8-byte integers, such as general register values, must
  be 8-byte aligned. [3]
SFrame FP and RA stack offsets must therefore always be a multiple of
8 on s390x.  Note that for the same reason the DWARF data alignment
factor is -8 on s390x (see DWARF2_CIE_DATA_ALIGNMENT).

Add s390x-specific SFrame (error) tests for FP/RA saved in FPRs in leaf
function.

[1]: s390x ELF ABI, sections "Register Roles" and "Stack Frame
     Allocation", https://github.com/IBM/s390x-abi/releases
[2]: s390x ELF ABI, commit 4e38ad9c8a88 ("Document the CFA"),
     https://github.com/IBM/s390x-abi/commit/4e38ad9c8a88
[3]: s390x ELF ABI, section "Fundamental Types", table "Scalar types",
     https://github.com/IBM/s390x-abi/releases

include/
	* sframe.h (SFRAME_V2_S390X_OFFSET_IS_REGNUM): New s390x-
	specific macro to test whether an SFrame FP/RA offset is a DWARF
	register number.
	(SFRAME_V2_S390X_OFFSET_ENCODE_REGNUM): New s390x-specific macro
	to encode a DWARF register number into an SFrame FP/RA offset.
	(SFRAME_V2_S390X_OFFSET_DECODE_REGNUM): New s390x-specific macro
	to decode an SFrame FP/RA offset into a DWARF register number.
	* sframe-api.h (sframe_fre_get_fp_offset,
	sframe_fre_get_fp_offset): Add comment that for s390x the offset
	may be an encoded register number.

gas/
	* gen-sframe.c (s390_sframe_xlate_do_register): New S390-
	specific function.  Uses SFRAME_V2_S390X_OFFSET_ENCODE_REGNUM to
	represent FP/RA saved in another register on s390x.
	(sframe_xlate_do_register): Invoke s390_sframe_xlate_do_register
	on s390x.

libsframe/
	* sframe.c (sframe_fre_get_fp_offset, sframe_fre_get_fp_offset):
	Add comment that for s390x the offset may be an encoded register
	number.
	* sframe-dump.c (is_sframe_abi_arch_s390x): New helper to test
	whether ABI/arch is s390x.
	(dump_sframe_func_with_fres): Use
	SFRAME_V2_S390X_OFFSET_IS_REGNUM and
	SFRAME_V2_S390X_OFFSET_DECODE_REGNUM to dump FP/RA saved in
	another register on s390x.
	* doc/sframe-spec.texi (s390x): Document s390x-specific
	representation of FP/RA saved in another register.

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe.exp: Update s390x-specific SFrame
	(error) tests.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-err-2.s: Rename
	to ...
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-err-2.d:
	Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-1.s: This.  Test
	no longer triggers a warning, as SFrame can represent FP and RA
	saved in registers.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-1.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-err-1.d: Test
	now triggers a different warning, as SFrame can represent FP and
	RA saved in registers, but not FP without RA saved in register.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
d27d82f560 s390: Initial support to generate .sframe from CFI directives in assembler
This introduces initial support to generate .sframe from CFI directives
in assembler on s390 64-bit (s390x).  Due to SFrame V2 format
limitations it has the following limitations, some of them getting
addressed by subsequent patches, which cause generation of SFrame FDE
to be skipped:

- SFrame FP/RA tracking only supports register contents being saved on
  the stack (i.e. .cfi_offset).  It does not support FP/RA register
  contents being saved in other registers (i.e. .cfi_register).  GCC on
  s390x can be observed to save the FP/RA register contents in floating-
  point registers, but only in leaf functions.
  This issue is detailed further and resolved in the subsequent commit
  "s390: Represent FP/RA saved in register in SFrame".

- SFrame FP/RA tracking cannot represent FP without RA saved.  This is
  because the format assumes SFrame FDE offset2 to be the RA offset, if
  there are two offsets, and offset3 to be the FP offset, if there are
  three offsets.  There is no mean to distinguish whether offset2 is the
  RA or FP offset, if there are only two offsets.
  This issue is detailed further and resolved in the subsequent commit
  "s390: Represent FP without RA saved in SFrame".

- SFrame assumes a dedicated FP register number.  The s390x ELF ABI [1]
  does only designate register 11 as preferred FP register number.  In
  general GCC and Clang on s390x use register 11 as frame pointer.
  GCC on s390x can be observed to use register 14 as frame pointer in
  the stack clash protector in the function prologue.
  glibc on s390x contains hand-written assembler code that uses
  register 12 as frame pointer.

This s390x support is largely based on the AArch64 support from commit
b52c4ee466 ("gas: generate .sframe from CFI directives").

The SFrame ABI/arch identifier SFRAME_ABI_S390X_ENDIAN_BIG is introduced
for s390x and added to the SFrame format specification.

The s390x ELF ABI [1] specifies the following C calling conventions for
s390x architecture:
- Register 15 is the stack pointer (SP).
- Register 14 contains the return address (RA) at function entry.
- There is no dedicated frame pointer register.  Register 11 is the
  preferred frame pointer (FP). [2]  GCC and Clang in general use
  register 11 as frame pointer.
- The CFA is defined as SP at call site +160. [3]  The SP at call site
  can therefore be derived from the CFA using a SP value offset from CFA
  of -160.

The s390x ELF ABI [1] does not assign any standard save slot to each
register in the register save area of a stack frame.  Neither the
return address (RA, r14) nor preferred frame pointer (FP, r11)
necessarily need to be saved.  Therefore SFrame RA and FP tracking is
used.

Support for SFrame on s390 is only enabled for the 64-bit s390x ELF ABI
(z/Architecture with 64-bit addressing mode).  It is disabled for the
32-bit s390 ELF ABI (ESA/390 or z/Architecture with 32-bit addressing
mode).

s390x-specific SFrame assembler and linker tests are added, including
error tests for use of a non-preferred frame pointer (FP) register and
specification of a non-default return address (RA) register.

[1]: s390x ELF ABI, https://github.com/IBM/s390x-abi/releases
[2]: s390x ELF ABI, commit f00421825979 ("Add information about the frame
     pointer register"),
     https://github.com/IBM/s390x-abi/commit/f00421825979
[3]: s390x ELF ABI, commit 4e38ad9c8a88 ("Document the CFA"),
     https://github.com/IBM/s390x-abi/commit/4e38ad9c8a88

include/
	* sframe.h: Add reference to s390x architecture in comments.
	(SFRAME_ABI_S390X_ENDIAN_BIG): Define SFrame ABI/arch identifier
	for s390x.
	(SFRAME_S390X_SP_VAL_OFFSET): Define s390x-specific SP value
	offset from CFA.

libsframe/
	* sframe.c (need_swapping): Add SFRAME_ABI_S390X_ENDIAN_BIG.
	* doc/sframe-spec.texi (SFRAME_ABI_S390X_ENDIAN_BIG, s390x,
	SFRAME_S390X_SP_VAL_OFFSET): Document SFrame ABI/arch identifier
	for s390x, add references to s390x architecture, and document
	s390x-specifics, such as the SP value offset from CFA of -160.

gas/
	* config/tc-s390.h: s390x support to generate .sframe from CFI
	directives in assembler.
	(support_sframe_p): Define.
	(SFRAME_CFA_SP_REG, SFRAME_CFA_FP_REG, SFRAME_CFA_RA_REG):
	Define.
	(sframe_ra_tracking_p): Define.
	(sframe_cfa_ra_offset): Define.
	(sframe_get_abi_arch): Define.
	* config/tc-s390.c: s390x support to generate .sframe from CFI
	directives in assembler.
	(s390_sframe_cfa_sp_reg, s390_sframe_cfa_fp_reg,
	s390_sframe_cfa_ra_reg): New.  Initialize to DWARF register
	numbers of stack pointer (SP, r15), preferred frame pointer
	(FP, r11), and return address (RA, r14) registers.
	(s390_support_sframe_p): New function.  Return true if s390x.
	(s390_sframe_ra_tracking_p): New function.  Return true.
	(s390_sframe_cfa_ra_offset): New function.  Return
	SFRAME_CFA_FIXED_RA_INVALID.
	(s390_sframe_get_abi_arch): New function.  Return
	SFRAME_ABI_S390X_ENDIAN_BIG if s390x, otherwise zero.
	* gen-sframe.c: Add reference to s390x architecture in comments.
	(sframe_xlate_do_val_offset): Add support for s390x-specific
	SFRAME_S390X_SP_VAL_OFFSET.
	* NEWS: Add news entry.

gas/testsuite/
	* gas/cfi-sframe/cfi-sframe.exp: Enable common SFrame tests for
	s390x.  Add s390x-specific SFrame (error) tests.
	* gas/cfi-sframe/cfi-sframe-s390x-1.d: New s390x-specific SFrame
	test.
	* gas/cfi-sframe/cfi-sframe-s390x-1.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-2.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-2.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-err-1.d: New s390x-specific
	SFrame error test that uses a non-default frame-pointer register
	as CFA base register.
	* gas/cfi-sframe/cfi-sframe-s390x-err-1.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-err-2.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-err-2.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-err-3.d: New s390x-specific
	SFrame error test that uses a non-default return address
	register.
	* gas/cfi-sframe/cfi-sframe-s390x-err-3.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-offset-1.d: New s390x-
	specific SFrame test that saves RA and FP individually on the
	stack.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-offset-1.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-offset-err-1.d: New
	s390x-specific SFrame error test that saves FP and RA
	individually, to trigger FP without RA saved.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-offset-err-1.s: Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-err-1.d: New
	s390x-specific SFrame error test that saves FP and RA
	individually in registers.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-err-1.s:
	Likewise.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-err-2.d: New
	s390x-specific SFrame error test that saves RA and FP
	individually in registers.
	* gas/cfi-sframe/cfi-sframe-s390x-fpra-register-err-2.s:
	Likewise.

ld/testsuite/
	* ld-s390/s390.exp: Add simple SFrame test.
	* ld-s390/sframe-simple-1.d: New simple SFrame test.
	* ld-s390/sframe-bar.s: Likewise.
	* ld-s390/sframe-foo.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
1b1ff68e4c s390: Explicitly list linker dump tests
Generating the linker dump test list using file globbing makes it
difficult to exclude specific tests under certain circumstances.  List
them explicitly instead.  This enables to add tests in the future that
can be excluded.  While at it reorganize how s390 linker tests get
run for s390x.

ld/testsuite/
	* ld-s390/s390.exp: Reorganize and explicitly list linker dump
	tests.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
Jens Remus
b36a8e57ea sframe: Ignore section padding when converting endianness
The .sframe section may have a trailing padding due to the architecture-
specific default section alignment.  Do not treat this padding as error
when converting between target and host endianness.

This can be observed when building Binutils with SFrame s390x support on
x86-64 for s390x using configure option "--target=s390x-ibm-linux-gnu"
and running the GAS test suite.

While at it reuse the determined SFrame section header size.

libsframe/
	* sframe.c (flip_sframe): Ignore .sframe section padding.  Reuse
	SFrame header size.

Reported-by: Indu Bhagat <indu.bhagat@oracle.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-11 10:29:40 +02:00
GDB Administrator
cbc7579dd2 Automatic date update in version.in 2025-07-11 00:01:22 +00:00
Alan Modra
d72ad17caa AM_PO_SUBDIRS
Swap AM_PO_SUBDIRS and ZW_GNU_GETTEXT_SISTER_DIR lines in
*/configure.ac.  ZW_GNU_GETTEXT_SISTER_DIR indirectly invokes
AC_REQUIRE(AM_PO_SUBDIRS) so results in AM_PO_SUBDIRS being emitted
before ZW_GNU_GETTEXT_SISTER_DIR if it hasn't already been invoked.
2025-07-11 08:23:40 +09:30
Alan Modra
6398ac7e8b gas v850 md_convert_frag
The v850 md_convert_frag function oddly calls subseg_change twice
(commit 1cd986c585).  Neither call is needed, because that is done
in size_seg.

Convert the fr_opcode fixup field back (to an opindex, not fx_r_type)
using a cast rather than a union, since we used casts when setting up
those values.  I guess the union was added to silence compiler
warnings about wrong-size casts, but unfortunately results in the
wrong value being retrieved on big-endian hosts.

Change "buffer" to a char* as there is no need to make it an
unsigned char*, and that way requires fewer casts.  Finally, fix
formatting and use uintptr_t when make the rs_machine_dependent frags.

Remove subseg_change calls from cr16, crx, mn10200, mn10300, and sh
md_convert_frag too.
2025-07-11 08:23:40 +09:30
Alan Modra
7507184dbe union alpha_macro_arg
Rename the old enum alpha_macro_arg to alpha_macro_argset, and create
a union alpha_macro_arg to use in all the alpha_macro.emit functions.
This avoids intptr_t casts on retrieving index values and void* casts
on storing them in the alpha_macros array.
2025-07-11 08:16:26 +09:30
Nelson Chu
a6a177d0a2 sim: riscv: Fix build issue due to INSN_CLASS_C was changed to INSN_CLASS_ZCA 2025-07-10 21:50:19 +08:00
Matthieu Longo
7694eb6393 libiberty: sync with gcc
Import the following commits from GCC as of r16-2170-g2f2e9bcfb0fd9c:
	0fd98b6f9f2 libiberty: add routines to handle type-sensitive doubly linked lists
2025-07-10 14:26:10 +01:00
Nelson Chu
0e16f1550a RISC-V: Fixed wrong imply result for zce when -march=rv32id_zce
The entry of "zce imply zcf" needs check_implicit_for_zcf, so it needs to be
placed after the entries of "whatever imply f".  Otherwise the implicit zcf
may be missed.  Also merge the march-implu-zce* testcases into imply testcases.
2025-07-10 19:32:09 +08:00
Nelson Chu
34fcc16e79 RISC-V: Clarify the imply rule of c
This also fix the imply result for .option rvc.

Imply zcf when c and f and rv32
Imply zcd when c and d
Imply zca when c

Changed INSN_CLASS_C to INSN_CLASS_ZCA
Changed INSN_CLASS_F_AND_C to INSN_CLASS_ZCF
Changed INSN_CLASS_D_AND_C to INSN_CLASS_ZCD
Changed INSN_CLASS_ZIHINTNTL_AND_C to INSN_CLASS_ZIHINTNTL_AND_ZCA
2025-07-10 19:32:07 +08:00
Nelson Chu
bb13e094aa RISC-V: Deprecate ".option arch, -ext" for users due to its controversial use
Before we figure out the whole remove situations for ".option arch, -ext", and
have any RISC-V public spec defines it, we should just deprecate it.
2025-07-10 19:16:33 +08:00
GDB Administrator
4cc811f637 Automatic date update in version.in 2025-07-10 00:01:08 +00:00
Indu Bhagat
61be442011 gas: ld: sframe: add new internal header
for SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS.

The intention of creating an abstraction like
SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS is to address the concern that there
should be a central place to enforce harmonious flags between GNU as and
ld.  At the moment, the only flag that needs to be enforced is
SFRAME_F_FDE_FUNC_START_PCREL.

sframe.h and sframe-api.h are installed headers by libsframe for the
specification and implementation respectively.  Adding a definition like
SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS does not fit in either.  Create a
new internal header instead to keep the definition uncoupled from
sframe.h and sframe-api.h.  Rename the previously added
SFRAME_F_LD_MUSTHAVE_FLAGS to define the new
SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS.

bfd/
	* elf-sframe.c (_bfd_elf_merge_section_sframe): Use the new
	internal header and SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS.
gas/
	* gen-sframe.c (output_sframe_internal): Likewise.
include/
	* sframe-api.h (SFRAME_F_LD_MUSTHAVE_FLAGS): Move from..
	* sframe-internal.h: ..to here.  New file.
2025-07-09 01:40:41 -07:00
Alan Modra
5942dd9913 Merge init_private_section_data with copy_private_section_data
init_private_section_data is used by the linker and is a special case
of copy_private_section_data that copies a reduced set of section data
from input to output.  Merge the two functions, adding a link_info
param to copy_private_section_data and remove init_private_section_data.
2025-07-09 11:13:55 +09:30
Alan Modra
e76715632c gas remove assorted unnecessary casts
This continues the saga of removing unnecessary casts, and making
small code tidies in gas.  Hopefully this sees the last of K&R
anachronisms.
2025-07-09 09:35:07 +09:30
Alan Modra
a093ef7af4 gas standardise md_section_align
The point here is that when valueT is 64 bits and int is 32 bits,
1 << align doesn't work for shifts larger than the size of int.  (Not
that anyone is likely to use such large alignments in real code.)
2025-07-09 09:35:07 +09:30
Alan Modra
c78eda50fe gas function arg casts
This patch removes more unnecessary arg casts in various function
calls.
2025-07-09 09:35:07 +09:30
Alan Modra
48753009c1 gas fixups
Remove unnecessary arg casts in fix_new and similar calls.
2025-07-09 09:35:07 +09:30
Alan Modra
a32922a7b9 gas char/unsigned char casts
This patch removes many unneeded casts to char or unsigned char.  It's
worth noting that safe-ctype.h macros ISDIGIT and the like cope with
either signed or unsigned char.
In some cases a cast to unsigned char is replaced by anding with 0xff,
which accomplishes the same thing but doesn't rely on char being eight
bits.  The patch also removes pointer casts, and a few unsigned char
pointer variables.
2025-07-09 09:35:07 +09:30
Alan Modra
4df44a4aea gas alpha sign extension macros
Use standard sign extend and range checking using unsigned
expressions that don't rely on implementation defined right shifts or
size of short and int.
2025-07-09 09:35:07 +09:30
Alan Modra
b413e25432 gas md_number_to_chars
Calls to md_number_to_chars don't need to cast their value arg (*).
Remove those casts.  avr_output_property_recode made a call to
md_number_to_chars with size of 1.  Simplify that.  tc-bpf.c
md_convert_frag used write_insn_bytes that simply copied input to
output.  Dispense with that nonsense, and similarly in a couple of
other places where md_number_to_chars was called with size 1.

*) unless the value arg is an expression that needs a cast, eg. tic54x
   emit_insn where the shift left could trigger signed overflow UB
   without a cast.
2025-07-09 09:35:07 +09:30
Alan Modra
4da111f55a z8k opcode_entry_type
z8k opcode_entry_type.func is never used as a function pointer, only
as a pointer to a pseudo_typeS.  Change it to a void*.
2025-07-09 09:35:07 +09:30
Alan Modra
a5b6fadf88 gas various other void* casts
This removes assorted unneeded casts of void* pointers, and casts when
passing args to void* parameters or storing to void* pointers.  The
patch also changes obj-coff.c stack_push to take a void* parameter,
and replaces an odd memcpy in tc-metag.c find_insn_templates with a
simple assignment.
2025-07-09 09:35:07 +09:30
Alan Modra
d24a60f9fc gas various other const pointer changes
This removes a bunch of casts involving const pointers, in some cases
by making variables const pointers so a cast is not needed.  In a
couple of places the cast hid errors with "&array" written rather than
"array", see iq2000_macro_defs and s_pru_align.  tc-xgate.c cmp_opcode
is changed to be the standard qsort predicate to avoid a function
cast.
2025-07-09 09:35:07 +09:30
Alan Modra
de8acd2005 gas d30v_insn plus other non-const pointers
d30v has a bunch of casts that are only needed due to various types
missing a const.  Fix that.
2025-07-09 09:35:07 +09:30
Alan Modra
60ba816bc1 gas alloc casts
All of the various memory allocation function return a "void *"
pointer, which needs no cast to assign to other pointer types.
2025-07-09 09:35:07 +09:30
Alan Modra
3dcea21160 gas bfd_put and bfd_get arg casts
bfd_{h_,}put_* and bfd_{h_,}get_* have "void *" pointer params
nowadays.  We don't need casts on their pointer args.  We also don't
need to cast values passed to bfd_put.
2025-07-09 09:35:06 +09:30
Alan Modra
1a12e548ba gas NULL casts
This removes many unnecessary NULL casts.  I'm also adding a few arg
casts in concat calls, to make the code consistent.  Advice from quite
a few years ago was that it's better to use the exact type for args
corresponding to function ellipses, in case NULL is defined as plain
0.  (I think that happened with some early 64-bit systems.  Plain NULL
ought to be OK nowadays.)
2025-07-09 09:35:06 +09:30
Alan Modra
a0f33694e2 gas s3_FAIL and s7_FAIL
s3_FAIL is defined as 0x80000000 which is unsigned, but everywhere it
is used it is cast to int.  Get rid of that silliness, and likewise
for s7_FAIL.
2025-07-09 09:35:06 +09:30
Alan Modra
76d630291d gas more enum casts
Remove more unnecessary enum casts.
2025-07-09 09:35:06 +09:30
Alan Modra
7b13f65ccb gas bfd_reloc_code_real_type
Enumeration constants are integer types, so there should be no need to
cast such constants to int in expressions.  (Perhaps some older gccs
warned, I checked back to gcc-4.5.)  Remove some of those unnecessary
casts.  Also remove unnecessary casts to bfd_reloc_code_real_type.
2025-07-09 09:35:06 +09:30
Alan Modra
4d2eb1bb7c gas add_ecoff_symbol
* ecoff.c: Remove unnecessary arg casts in add_ecoff_symbol
	calls throughout file.
2025-07-09 09:35:06 +09:30
Alan Modra
37899b113c gas frag_var
Many frag_var calls have unnecessary casts on arguments, no doubt from
the days when binutils was written for K&R C.  (ie. functions were not
prototyped so you needed to cast anything that didn't match the
expected type after default promotions, as you still do for args
matching a function ellipsis.)  Remove those casts.

	* config/tc-alpha.c (s_alpha_comm): Use offset_T for cur_size
	to avoid need for casts.  Remove casts from frag_var args.
	* config/tc-ia64.c (obj_elf_vms_common): Remove casts from
	frag_var args.
	* config/tc-m32r.c (m32r_scomm): Likewise.
	* config/tc-m68hc11.c (build_jump_insn): Likewise.
	(build_dbranch_insn): Likewise.
	* config/tc-m68k.c (md_assemble): Likewise.
	* config/tc-microblaze.c (microblaze_s_lcomm): Likewise.
	* config/tc-mmix.c (s_loc): Likewise.
	* config/tc-ppc.c (ppc_elf_lcomm, ppc_comm): Likewise.
	* config/tc-score.c (s3_s_score_lcomm): Likewise.
	* config/tc-score7.c (s7_s_score_lcomm): Likewise.
	* config/tc-sh.c (sh_cons_align): Likewise.
	* config/tc-sparc.c (s_reserve, s_common): Likewise.
	(sparc_cons_align): Likewise.
	* config/tc-tic4x.c (tic4x_seg_alloc, tic4x_bss): Likewise.
	* config/tc-tic54x.c (tic54x_bss, tic54x_space): Likewise.
	(tic54x_usect, tic54x_field): Likewise.
	* config/tc-tic6x.c (s_tic6x_scomm): Likewise.
	* config/tc-v850.c (v850_offset, v850_comm): Likewise.
	* frags.c (frag_align, frag_align_pattern, frag_align_code): Likewise.
	* gen-sframe.c (output_sframe_row_entry): Likewise.
	(output_sframe_funcdesc): Likewise.
	* read.c (s_fill, do_org, s_space, emit_leb128_expr): Likewise.
	* symbols.c (colon)): Likewise.
2025-07-09 09:35:06 +09:30
Alan Modra
b6ef2d0c2f gas pointer to int and vice versa
Use "intptr_t" or "uintptr_t" for these conversions, not "long" which
is wrong on LLP64 systems, or "size_t" which is better but still not
the correct type.

	* config/tc-alpha.c (emit_ldXu, emit_ldX, emit_uldXu, emit_uldX),
	(emit_stX, emit_ustX, emit_sextX): Use correct type when
	converting vlgsize pointer to in.  Use "int" rather than
	"long" for result.
	* config/tc-ia64.c (generate_unwind_image): Use intptr_t cast
	when passing personality_routine to frag_var.
	* config/tc-ppc.c (ppc_frob_symbol <coff>): Use uintptr_t cast
	when converting symbol pointer to valueT.
	* config/tc-v850.c (md_assemble): Use intptr_t cast when
	loading integer opindex.
2025-07-09 09:35:06 +09:30
GDB Administrator
4ff3ce6fcd Automatic date update in version.in 2025-07-09 00:01:27 +00:00
Alice Carlotti
e68a412e16 aarch64: Add support for FEAT_SVE2p2 and FEAT_SME2p2 2025-07-08 21:15:43 +01:00
Alice Carlotti
f4d1a953fe aarch64: Reorder virtual feature dependencies
This will improve readability when more combinations of "SVE* or SME*"
are added.
2025-07-08 21:15:43 +01:00
First Last
5fe1ef6f78 gdb/reverse: Add 2 AVX instructions VADDSUBPS and VADDSUBPD
add support to recording 2 missing AVX instructions: vaddsubps and vaddsubpd, and add associated tests.

Approved-By: Guinevere Larsen <guinevere@redhat.com>
2025-07-08 17:13:11 -03:00
Vladimir Mezentsev
64fae1b70d gprofng: support external debug info
Use bfd_follow_gnu_debuglink() and bfd_follow_gnu_debugaltlink() to find files
with debug info.
If necessary, gprofng-archive copies these files to EXP/archives.

For each executable, gprofng creates the Elf class twice.
One of them was a memory leak.
Fixed this by adding a new argument to Stabs::Stabs().

gprofng/ChangeLog
2025-07-07  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR 32147
	PR 30194
	* src/Disasm.cc (get_funcname_in_plt): Use the executable file instead
	of the debug information file.
	* src/Dwarf.h: Define debug_alt_strSec.
	* src/DwarfLib.cc: Add support for DW_FORM_GNU_ref_alt,
	DW_FORM_GNU_strp_alt.
	* src/Elf.h (find_gnu_debug_files, get_dwr_section): New functions.
	* src/Elf.cc: Likewise.
	* src/Experiment.cc (copy_file): Add the const qualifier.
	* src/Experiment.h: Likewise.
	* src/LoadObject.cc (get_elf, openDebugInfo): Find files with debug info.
	* src/LoadObject.h: Remove unused variables.
	* src/Module.cc: Remove an argument in openDebugInfo().
	* src/Stabs.cc (Stabs::Stabs): Add the Elf* argument.
	* src/Stabs.h: Likewise.
	* src/gp-archive.cc: Archive files with debug info.
	* src/gp-archive.h (archive_file): New function.
2025-07-08 10:11:05 -07:00