gas: scfi: bugfixes for SCFI state propagation
commitf1c5d46cae3fa4a3c41c05c796c69d52eef97067
authorIndu Bhagat <indu.bhagat@oracle.com>
Wed, 10 Apr 2024 20:46:37 +0000 (10 13:46 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 10 Apr 2024 20:46:37 +0000 (10 13:46 -0700)
treeed39ef5f849d97ec7a38758e3f232ba7cdcbe819
parenta1c6a60cc55a17b5f3c8e26f1bc68b4ee2470e54
gas: scfi: bugfixes for SCFI state propagation

There are two state propagation functions in SCFI machinery - forward
and backward flow.  The patch addresses two issues:
  - In forward_flow_scfi_state (), the state being compared in forward flow
    must be that at the exit of a prev bb and that at the entry of the
    next bb.  The variable holding the state to be compared was
    previously (erroneously) stale.
  - In cmp_scfi_state (), the assumption that two different control
    flows, leading to the same basic block, cannot have a mismatched
    notion of CFA base register, is not true.  Remove the assertion and
    instead return err if mismatch.

Fixing these issues helps correctly synthesize CFI, when previously
SCFI was erroring out for an otherwise valid input asm.

gas/
* scfi.c (cmp_scfi_state): Remove assertion and return mismatch
in return value as applicable.
(forward_flow_scfi_state): Update state object to be the same as
the exit state of the prev bb before comparing.

gas/testsuite/
* gas/scfi/x86_64/scfi-x86-64.exp: Add new test.
* gas/scfi/x86_64/scfi-cfg-5.d: New test.
* gas/scfi/x86_64/scfi-cfg-5.l: New test.
* gas/scfi/x86_64/scfi-cfg-5.s: New test.
gas/scfi.c
gas/testsuite/gas/scfi/x86_64/scfi-cfg-5.d [new file with mode: 0644]
gas/testsuite/gas/scfi/x86_64/scfi-cfg-5.l [new file with mode: 0644]
gas/testsuite/gas/scfi/x86_64/scfi-cfg-5.s [new file with mode: 0644]
gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp