[PATCH 0/8] s390: Support to generate .sframe in assembler and linker
Jens Remus
jremus@linux.ibm.com
Wed Apr 2 16:11:55 GMT 2025
Notable changes in v1 from RFC v3:
- S390-specific SFrame extension to represent FP without RA saved using
a padding RA offset.
- S390-specific SFrame extension to store the CFA offset adjusted
by -160 and then scaled by 8 to enable and improve the use of 8-bit
offsets.
- Support to generate .sframe for linker- generated .plt in the linker,
with support to generate .eh_frame for linker-generated .plt being the
precursor.
- Document S390-specifics in SFrame format specification.
This patch series adds support on s390x to generate SFrame stack trace
information (.sframe section) in the assembler from CFI directives and
in the linker for the linker-generated .plt section.
Patches 1 and 2 are preparatory. Patch 1 resolves an endianness
conversion issue in SFrame common code. Patch 2 restructures the linker
dump tests on s390/s390x, to enable adding SFrame tests that are only
run if SFrame is supported.
Patch 3 adds initial support to generate SFrame stack trace information
from CFI directives in the assembler on s390x. Due to differences in
the s390x ELF ABI [1] compared to the AArch64 and x86-64 AMD64 ELF ABIs
and the simplified assumptions of the SFrame format V2 there are a few
limitations, that mostly get addressed by patches 4 and 5.
Patches 4 and 5 address generic SFrame limitations, by introducing S390-
specific extensions to the SFrame format. Patch 4 enables to represent
FP/RA saved in another register (instead of on the stack), which can be
observed in leaf functions, by encoding the DWARF register number as
FP/RA offset. Patch 5 enables to represent FP without RA saved (on the
stack or in another register), by using an invalid RA offset value as
padding.
Patch 6 adds support to generate SFrame stack trace information for the
linker-generated .plt section in the linker on s390x.
Patches 7 and 8 enable and improve the use of signed 8-bit SFrame CFA,
FP, and RA offsets on S390. Patch 7 enables the use by storing the CFA
offset adjusted by a s390x-specific CFA adjustment of -160. Patch 8
improves the use by additionally storing the CFA offset factorized, with
a s390x-specific CFA offset alignment factor of 8 factored out.
Open issues and limitations that could be addressed in SFrame, GCC, and
Glibc:
- Limitation: Potential use of non-SP/FP register as CFA base register.
The s390x ELF ABI does not designate a dedicated frame pointer (FP)
register. With a recent update it does designate register 11 (r11)
as preferred FP register, which is used by GCC and Clang on s390x.
This will most likely remain a permanent limitation, mostly affecting
hand-written assembler code.
- Issue: GCC use of non-SP/FP register as CFA base register. GCC can
be observed to use the non-FP register r14 as temporary CFA base
register in the stack clash protector of variadic functions. This
could be addressed either in GCC or with the planned SFrame V3
enhancement [2] to support non-SP/FP CFA base registers for topmost
frames.
- Issue: Glibc use of non-preferred FP register r12 as frame pointer
in _dl_runtime_profile. I am working on Glibc patches to improve
SFrame compatibility on s390x, which will resolve this issue.
- Limitation: Glibc use of non-default RA register r0 in mcount/fentry
used for profiling. This will most likely remain a permanent
limitation, that the use of SFrame stack tracing, e.g. using perf,
cannot be combined with profiling. Except if SFrame V3 [2] would
provide support for non-default RA registers for topmost frames.
[1]: s390x ELF ABI, https://github.com/IBM/s390x-abi/releases
[2]: SFrame V3 TODOs,
https://sourceware.org/binutils/wiki/sframe/sframev3todo
Regards,
Jens
Jens Remus (8):
sframe: Ignore section padding when converting endianness
s390: Explicitly list linker dump tests
s390: Initial support to generate .sframe from CFI directives in
assembler
s390: Represent FP/RA saved in register in SFrame
s390: Represent FP without RA saved in SFrame
s390: Add SFrame stack trace information for .plt section
s390: Store SFrame CFA offset adjusted
s390: Store SFrame CFA offset adjusted and scaled down
bfd/elf64-s390.c | 259 ++++++++++++++++++
gas/NEWS | 3 +
gas/config/tc-s390.c | 55 ++++
gas/config/tc-s390.h | 31 +++
gas/gen-sframe.c | 101 ++++++-
.../gas/cfi-sframe/cfi-sframe-s390-1.d | 23 ++
.../gas/cfi-sframe/cfi-sframe-s390-1.s | 37 +++
.../gas/cfi-sframe/cfi-sframe-s390-2.d | 23 ++
.../gas/cfi-sframe/cfi-sframe-s390-2.s | 37 +++
.../gas/cfi-sframe/cfi-sframe-s390-err-1.d | 15 +
.../gas/cfi-sframe/cfi-sframe-s390-err-1.s | 37 +++
.../gas/cfi-sframe/cfi-sframe-s390-err-2.d | 15 +
.../gas/cfi-sframe/cfi-sframe-s390-err-2.s | 37 +++
.../gas/cfi-sframe/cfi-sframe-s390-err-3.d | 15 +
.../gas/cfi-sframe/cfi-sframe-s390-err-3.s | 5 +
.../cfi-sframe-s390-fpra-offset-1.d | 22 ++
.../cfi-sframe-s390-fpra-offset-1.s | 15 +
.../cfi-sframe-s390-fpra-offset-2.d | 22 ++
.../cfi-sframe-s390-fpra-offset-2.s | 15 +
.../cfi-sframe-s390-fpra-register-1.d | 22 ++
.../cfi-sframe-s390-fpra-register-1.s | 15 +
.../cfi-sframe-s390-fpra-register-2.d | 22 ++
.../cfi-sframe-s390-fpra-register-2.s | 15 +
gas/testsuite/gas/cfi-sframe/cfi-sframe.exp | 16 +-
include/sframe.h | 58 +++-
ld/NEWS | 4 +
ld/testsuite/ld-s390/s390.exp | 18 +-
ld/testsuite/ld-s390/sframe-bar.s | 21 ++
ld/testsuite/ld-s390/sframe-foo.s | 9 +
ld/testsuite/ld-s390/sframe-plt-1.d | 28 ++
ld/testsuite/ld-s390/sframe-simple-1.d | 31 +++
libsframe/doc/sframe-spec.texi | 67 ++++-
libsframe/sframe-dump.c | 28 +-
libsframe/sframe.c | 19 +-
34 files changed, 1108 insertions(+), 32 deletions(-)
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-1.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-1.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-2.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-2.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-1.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-1.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-2.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-2.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-3.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-3.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-offset-1.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-offset-1.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-offset-2.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-offset-2.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-register-1.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-register-1.s
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-register-2.d
create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-fpra-register-2.s
create mode 100644 ld/testsuite/ld-s390/sframe-bar.s
create mode 100644 ld/testsuite/ld-s390/sframe-foo.s
create mode 100644 ld/testsuite/ld-s390/sframe-plt-1.d
create mode 100644 ld/testsuite/ld-s390/sframe-simple-1.d
--
2.45.2
More information about the Binutils
mailing list