]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas: sframe: i386: have the backend specify the RA too
authorIndu Bhagat <indu.bhagat@oracle.com>
Mon, 19 May 2025 07:01:29 +0000 (00:01 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Mon, 19 May 2025 07:01:29 +0000 (00:01 -0700)
commit9819d849419de078b46c3f123e9dbc6503ab36d0
tree17ac959316993d1f752d51c313464f1818e8484a
parentc32952066a1b376d9a41ccfb5b34b63132c86724
gas: sframe: i386: have the backend specify the RA too

To process some CFI directives like .cfi_undefined and .cfi_same_value,
it is necessary for correctness to detect all cases when the register
used is one of SP, FP or RA.

Currently, the backends needed to specify the SFRAME_CFA_RA_REG only in
the case of those ABIs where RA tracking was necessary, e.g. AArch64.
For AMD64, since the return address is always at a fixed offset from the
CFA, RA tracking was disabled.

The backends must now specify the applicable return address register via
SFRAME_CFA_RA_REG.  This is necessary so that SFrame generation code can
then properly handle the cases when RA is used like so:
   .cfi_undefined <RA>
or,
   .cfi_same_value <RA>

Detecting these cases is necessary for correctness.  E.g., on AMD64, we
need to skip FDE generation as the above constructs cannot be
represented in SFrame yet.

This change is a prerequisite to fixing the two PRs:

PR gas/32952 - sframe: incorrect handling of .cfi_undefined in gas
PR gas/32953 - sframe: incorrect handling of .cfi_same_value in gas

In the SFrame generation code in gen-sframe.c, instead of using
SFRAME_FRE_RA_TRACKING ifdef's, we now simply rely on the API
sframe_ra_tracking_p () to detect if RA-tracking is enabled for the
target.

While at it, use const variables for x86 backend.

ChangeLog:

        * gas/config/tc-i386.c (x86_sframe_cfa_ra_reg): New definition.
        * gas/config/tc-i386.h (REG_RA): New definition.
(SFRAME_CFA_RA_REG): New declaration.
        * gas/gen-sframe.c (SFRAME_FRE_RA_TRACKING): Remove.
gas/config/tc-i386.c
gas/config/tc-i386.h
gas/gen-sframe.c