gnu /
gcc /
7809e19f8d18d08ae5cc59810e7fda177b5127f4 [13/13] arm: Add support for dwarf debug directives and pseudo hard-register for PAC feature.
Hello,
This patch teaches the DWARF support in gcc about RA_AUTH_CODE pseudo hard-register and also
.save {ra_auth_code} and .cfi_offset ra_auth_code <offset> dwarf directives for the PAC feature
in Armv8.1-M architecture.
RA_AUTH_CODE register number is 107 and it's dwarf register number is 143.
When compiled with " -march=armv8.1-m.main -mbranch-protection=pac-ret+leaf+bti -mthumb
-mfloat-abi=soft -fasynchronous-unwind-tables -g -O2 -S" command line options, the assembly
output after this patch looks like below:
...
.cfi_startproc
pacbti ip, lr, sp
movs r1, #40
push {ip, lr}
.save {ra_auth_code, lr}
.cfi_def_cfa_offset 8
.cfi_offset 143, -8
.cfi_offset 14, -4
...
pop {ip, lr}
.cfi_restore 14
.cfi_restore 143
.cfi_def_cfa_offset 0
movs r0, #0
aut ip, lr, sp
bx lr
.cfi_endproc
...
Regression tested on arm-none-eabi target and found no regressions.
Ok for master?
Regards,
Srinath.
gcc/ChangeLog:
2022-08-17 Srinath Parvathaneni <srinath.parvathaneni@arm.com>
* config/arm/aout.h (ra_auth_code): Add to enum.
* config/arm/arm.cc (emit_multi_reg_push): Add RA_AUTH_CODE register to
dwarf frame expression.
(arm_emit_multi_reg_pop): Restore RA_AUTH_CODE register.
(arm_expand_prologue): Mark as frame related insn.
(arm_regno_class): Check for pac pseudo reigster.
(arm_dbx_register_number): Assign ra_auth_code register number in dwarf.
(arm_unwind_emit_sequence): Print .save directive with ra_auth_code
register.
(arm_conditional_register_usage): Mark ra_auth_code in fixed reigsters.
* config/arm/arm.h (FIRST_PSEUDO_REGISTER): Modify.
(IS_PAC_Pseudo_REGNUM): Define.
(enum reg_class): Add PAC_REG entry.
* config/arm/arm.md (RA_AUTH_CODE): Define.
gcc/testsuite/ChangeLog:
2022-08-17 Srinath Parvathaneni <srinath.parvathaneni@arm.com>
* g++.target/arm/pac-1.C: New test.
* gcc.target/arm/pac-9.c: Likewise.
Testing Done:
@IP [Low Risk]: No to Q20 and no short-cut.
Arm specific changes.
==============
Rev 4:
@IP [Low Risk]: No to Q20 and no short-cut.
New testcase added.
===============
Rev 5.
@IP [Low Risk]: No to Q20 and no short-cut.
=======
Rev 6.
This is for internal discussion and testing.
=======
Rev 7.
Re-based the patch on internal branch origin/dsg/andcor03/pacbti-upstream-rebased.
This patch is under internal discussion and testing.
=====
Rev 8.
@IP: [Low Risk]: No to Q20 and no short-cut.
====
Rev 9.
@IP: [Low Risk]: No to Q20 and no short-cut.
Arm specific changes,
Re-based the patch on vendors/ARM/arm-12-m-pacbti branch and fixed build issue
related to stack offset in case of RA_AUTH_CODE register.
Bugs closed: GNUTOOLS-13069
Reviewed at http://pdtlreviewboard.cambridge.arm.com/r/14831/
6 files changed