[0/5] SFrame: add support for .cfi_b_key_frame

Message ID 20221214200756.1234528-1-indu.bhagat@oracle.com
Headers
Series SFrame: add support for .cfi_b_key_frame |

Message

Indu Bhagat Dec. 14, 2022, 8:07 p.m. UTC
  Hello,

This patchset adds support for handling the .cfi_b_key_frame assembler
directive to the SFrame format: SFrame format representation now allows to
encode which of the pauth A key / B key are used (for signing return
addresses on aarch64), and gas, readelf/objdump now allow for generation
and textual dump of this information.

Testing notes:

- Regression tested cross build of several targets on an x86_64 host and an
aarch64 host using a regression script that checks for failures in gas, ld,
binutils, libctf and libsframe.
- Regression tested native builds on x86_64 and aarch64.
- binutils/gdb try bot showed no new regressions.

PS: This patchset assumes that the SFrame support for .cfi_negate_ra_state is
in place already.  Please apply the recently sent "[PATCH 0/6] SFrame: support
for .cfi_negate_ra_state in aarch64" series prior to applying this series, if
you intend to experiment with this patchset.

Thanks,

Indu Bhagat (5):
  [1/5] sframe.h: add support for .cfi_b_key_frame
  [2/5] gas: sframe: add support for .cfi_b_key_frame
  [3/5] objdump/readelf: sframe: emit marker for SFrame FDE with B key
  [4/5] gas: sframe: testsuite: add testcase for .cfi_b_key_frame
  [5/5] sframe: doc: update documentation for pauth key in SFrame FDE

 gas/gen-sframe.c                              | 26 +++++++++++---
 gas/gen-sframe.h                              |  2 +-
 gas/sframe-opt.c                              |  3 ++
 .../cfi-sframe-aarch64-pac-ab-key-1.d         | 25 +++++++++++++
 .../cfi-sframe-aarch64-pac-ab-key-1.s         | 36 +++++++++++++++++++
 gas/testsuite/gas/cfi-sframe/cfi-sframe.exp   |  1 +
 include/sframe.h                              | 25 +++++++++----
 libsframe/doc/sframe-spec.texi                |  8 ++++-
 libsframe/sframe-dump.c                       | 19 ++++++++++
 9 files changed, 133 insertions(+), 12 deletions(-)
 create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.d
 create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.s
  

Comments

Nick Clifton Dec. 19, 2022, 3:36 p.m. UTC | #1
Hi Indu,

> - Regression tested cross build of several targets on an x86_64 host and an
> aarch64 host using a regression script that checks for failures in gas, ld,
> binutils, libctf and libsframe.

With this patch series applied on top of today's (19 dec) sources I see one
new failure in the gas testsuite for a toolchain configured as aarch64-linux-gnu:

   regexp_diff match failure
   regexp "^    Num FREs: 4$"
   line   "    Num FREs: 6"
   regexp_diff match failure
   regexp "^    0+0008 +sp\+16 +c-16 +c-8\[s\] +$"
   line   "    0000000000000004  sp+0      u         u[s]         "
   regexp_diff match failure
   regexp "^    func idx \[1\]: pc = 0x0, size = 20 bytes, pauth = B key$"
   line   "    0000000000000008  sp+16     c-16      c-8[s]       "
   regexp_diff match failure
   regexp "^    STARTPC + CFA + FP +  RA +$"
   line   "    func idx [1]: pc = 0x0, size = 20 bytes, pauth = B key"
   regexp_diff match failure
   regexp "^    0+0000 +sp\+0 +u +u +$"
   line   "    STARTPC         CFA       FP        RA           "
   regexp_diff match failure
   regexp "^    0+0008 +sp\+16 +c-16 +c-8\[s\] +$"
   line   "    0000000000000000  sp+0      u         u            "
   FAIL: SFrame cfi_b_key_frame and cfi_negate_ra_state composite test

Possibly this is because another patch needs to be applied first ?  Please could
you check and let me know.

Cheers
   Nick
  
Indu Bhagat Dec. 19, 2022, 5:27 p.m. UTC | #2
On 12/19/22 7:36 AM, Nick Clifton wrote:
> Hi Indu,
> 
>> - Regression tested cross build of several targets on an x86_64 host 
>> and an
>> aarch64 host using a regression script that checks for failures in 
>> gas, ld,
>> binutils, libctf and libsframe.
> 
> With this patch series applied on top of today's (19 dec) sources I see one
> new failure in the gas testsuite for a toolchain configured as 
> aarch64-linux-gnu:
> 
>    regexp_diff match failure
>    regexp "^    Num FREs: 4$"
>    line   "    Num FREs: 6"
>    regexp_diff match failure
>    regexp "^    0+0008 +sp\+16 +c-16 +c-8\[s\] +$"
>    line   "    0000000000000004  sp+0      u         u[s]         "
>    regexp_diff match failure
>    regexp "^    func idx \[1\]: pc = 0x0, size = 20 bytes, pauth = B key$"
>    line   "    0000000000000008  sp+16     c-16      c-8[s]       "
>    regexp_diff match failure
>    regexp "^    STARTPC + CFA + FP +  RA +$"
>    line   "    func idx [1]: pc = 0x0, size = 20 bytes, pauth = B key"
>    regexp_diff match failure
>    regexp "^    0+0000 +sp\+0 +u +u +$"
>    line   "    STARTPC         CFA       FP        RA           "
>    regexp_diff match failure
>    regexp "^    0+0008 +sp\+16 +c-16 +c-8\[s\] +$"
>    line   "    0000000000000000  sp+0      u         u            "
>    FAIL: SFrame cfi_b_key_frame and cfi_negate_ra_state composite test
> 
> Possibly this is because another patch needs to be applied first ?  
> Please could
> you check and let me know.
> 

This series now needs to be rebased with some changes to the testsuite 
necessary.  This is because the V2 version of the series which added 
support for .cfi_negate_ra_state was committed with "[s]" being emitted 
when RA is in register or stack.

Will rebase, post V2 after retesting.

Thanks
Indu