public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jens Remus <jremus@linux.ibm.com>
To: binutils@sourceware.org, Indu Bhagat <indu.bhagat@oracle.com>
Cc: Jens Remus <jremus@linux.ibm.com>,
	Andreas Krebbel <krebbel@linux.ibm.com>
Subject: [RFC PATCH 0/9] s390: Initial support to generate SFrame info from CFI directives in assembler
Date: Thu, 22 Feb 2024 17:01:14 +0100	[thread overview]
Message-ID: <20240222160123.2554459-1-jremus@linux.ibm.com> (raw)

This patch series adds initial support to the assembler on s390x to
generate SFrame stack trace information from CFI directives. It is
largely based on the respective AArch64 support.

Please be aware that the SFrame support for s390x provided by patch 9
of this series still has some open issues, which need to be addressed.
Any ideas or assistance to overcome the current SFrame limitations
listed below and in the patch description are very welcome.

Patches 1-8 are generic cleanups and enhancements to the generation
of SFrame information in the assembler. Patch 9 adds the initial s390x
support and is purely RFC.


Patches 1-3 are minor cleanups/enhancements to the existing SFrame
support on AArch64 and x86 AMD64.

Patch 4 enables readelf/objdump to dump the SFrame fixed offsets from
CFA to the frame pointer (FP) and return address (RA).

Patch 5 enhances an SFrame warning message to print the human readable
DWARF call frame instruction name.

Patch 6 and 7 resolve issues that cause the assembler to either generate
bad SFrame FDE or to silently skip it. Both issues would be triggered by
s390-specific SFrame error test cases introduced by patch 9.

Patch 8 adds verbose assembler warning messages when generation of
SFrame FDE is skipped.

Patch 9 adds initial support to the assembler on s390x to generate
SFrame stack trace information from CFI directives. Due to differences
in the s390x ELF ABI [1] compared to the AArch64 and x68 AMD64 ELF ABIs
and the simplified assumptions of the current SFrame format V2 there
are several unresolved issues (see also patch description):

- GCC on s390x may save the frame pointer (FP; r11) and/or return
  address (RA; r14) registers in other registers (e.g. floating-point
  registers) instead of saving them on the stack. SFrame currently only
  supports FP/RA tracking on the stack.
  This can be reproduced by using a small inline assembler statement,
  that specifies r11 (FP) and/or r14 (RA) as output operand(s). It can
  also be observed when compiling a minimal C program using GCC without
  optimizations.

- The s390x ELF ABI does not specify a frame pointer register number.
  Currently GCC and clang both mostly use register r11, but GCC can
  also be observed to use r14. On s390x a compiler may choose about
  any register number for that purpose and declare it using CFI
  directives.
  This can be observed when compiling glibc, as parts of its hand-
  written assembler uses register r12 as frame pointer.

- GCC on s390x may copy the return address (RA) from register r14 to
  another register and even use that to return to the caller.
  Effectively this is just a specialization of the first bullet.

If my understanding of the current SFrame format is not wrong I assume
the following enhancements to SFrame would be required to fully support
the s390x architecture:

- Tracking of the CFA base pointer register number specified in CFI
  directives .cfi_def_cfa and .cfi_def_cfa_register.

- Tracking of SP, FP, and RA register contents being saved in other
  registers instead of on the stack, as specified by CFI directive
  .cfi_register.

- Both would effectively require support in SFrame to track all of the
  17 registers specified as saved in the s390x ELF ABI (r6-r13, r15,
  and f8-f15), since SP, FP, and RA could be saved in one of those and
  thus would need to be restored during unwinding.

- Potentially optional, if the use in glibc could be removed:
  Tracking of SP, FP, and RA register contents being CFA+offset, as
  specified by .cfi_val_offset.

[1] ELF ABI s390x Supplement:
    https://github.com/IBM/s390x-abi/releases

Thanks and regards,
Jens

Jens Remus (9):
  x86: Remove unused SFrame CFI RA register variable
  aarch64: Align SFrame terminology in comments to specs and x86
  sframe: Enhance comments for SFRAME_CFA_*_REG macros
  readelf/objdump: Dump SFrame CFA fixed FP and RA offsets
  gas: Print DWARF call frame insn name in SFrame warning message
  gas: Skip SFrame FDE if CFI specifies non-FP/SP base register
  gas: Warn if SFrame FDE is skipped due to non-default return column
  gas: User readable warnings if SFrame FDE is not generated
  s390: Initial support to generate .sframe from CFI directives in
    assembler

 gas/config/tc-aarch64.h                       |   6 +-
 gas/config/tc-i386.c                          |   1 -
 gas/config/tc-i386.h                          |   4 +-
 gas/config/tc-s390.c                          |  55 +++++++
 gas/config/tc-s390.h                          |  31 ++++
 gas/gen-sframe.c                              | 146 ++++++++++++++++--
 gas/gen-sframe.h                              |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-1.d      |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-2.d      |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-3.d      |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-4.d      |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-5.d      |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-6.d      |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-7.d      |   2 +
 .../gas/cfi-sframe/cfi-sframe-common-8.d      |   2 +
 .../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    |   6 +
 .../gas/cfi-sframe/cfi-sframe-s390-err-4.d    |  15 ++
 .../gas/cfi-sframe/cfi-sframe-s390-err-4.s    |   5 +
 .../gas/cfi-sframe/cfi-sframe-x86_64-1.d      |   1 +
 gas/testsuite/gas/cfi-sframe/cfi-sframe.exp   |  13 +-
 gas/testsuite/gas/cfi-sframe/common-empty-1.d |   4 +-
 gas/testsuite/gas/cfi-sframe/common-empty-2.d |   4 +-
 gas/testsuite/gas/cfi-sframe/common-empty-3.d |   3 +
 .../gas/scfi/x86_64/scfi-cfi-sections-1.d     |   2 +
 .../gas/scfi/x86_64/scfi-dyn-stack-1.d        |   2 +
 include/sframe.h                              |   7 +-
 libsframe/doc/sframe-spec.texi                |   8 +-
 libsframe/sframe-dump.c                       |  10 ++
 37 files changed, 549 insertions(+), 31 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-err-4.d
 create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-s390-err-4.s

-- 
2.40.1


             reply	other threads:[~2024-02-22 16:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 16:01 Jens Remus [this message]
2024-02-22 16:01 ` [PATCH 1/9] x86: Remove unused SFrame CFI RA register variable Jens Remus
2024-02-22 16:01 ` [PATCH 2/9] aarch64: Align SFrame terminology in comments to specs and x86 Jens Remus
2024-02-22 16:01 ` [PATCH 3/9] sframe: Enhance comments for SFRAME_CFA_*_REG macros Jens Remus
2024-02-22 16:01 ` [PATCH 4/9] readelf/objdump: Dump SFrame CFA fixed FP and RA offsets Jens Remus
2024-02-22 16:01 ` [PATCH 5/9] gas: Print DWARF call frame insn name in SFrame warning message Jens Remus
2024-02-22 16:01 ` [PATCH 6/9] gas: Skip SFrame FDE if CFI specifies non-FP/SP base register Jens Remus
2024-02-22 16:01 ` [PATCH 7/9] gas: Warn if SFrame FDE is skipped due to non-default return column Jens Remus
2024-02-22 16:01 ` [PATCH 8/9] gas: User readable warnings if SFrame FDE is not generated Jens Remus
2024-02-22 16:01 ` [RFC PATCH 9/9] s390: Initial support to generate .sframe from CFI directives in assembler Jens Remus
2024-02-23 17:07 [RFC PATCH 0/9] s390: Initial support to generate SFrame info " Jens Remus
2024-02-23 17:27 ` Jens Remus
2024-02-23 21:16 ` Indu Bhagat
2024-04-05 18:26   ` Indu Bhagat
2024-04-09 14:19     ` Jens Remus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240222160123.2554459-1-jremus@linux.ibm.com \
    --to=jremus@linux.ibm.com \
    --cc=binutils@sourceware.org \
    --cc=indu.bhagat@oracle.com \
    --cc=krebbel@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).