[gas] Implement .cfi_negate_ra_state directive
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Fri, 6 Dec 2019 10:46:32 +0000 (10:46 +0000)
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>
Fri, 6 Dec 2019 10:46:32 +0000 (10:46 +0000)
This patch implements the .cfi_negate_ra_state to be consistent with
LLVM (https://reviews.llvm.org/D50136). The relevant DWARF code DW_CFA_AARCH64_negate_ra_state
is multiplexed on top of DW_CFA_GNU_window_save, as per
https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00753.html

I believe this is the simplest patch implementing this and is needed to
allow users to build, for example, the Linux kernel with Armv8.3-A
pointer authentication support with Clang while using gas as the
assembler, which is a common usecase.

gas/
2019-12-06  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    * dw2gencfi.c (cfi_pseudo_table): Add cfi_negate_ra_state.
    * testsuite/gas/aarch64/pac_negate_ra_state.s: New file.
    * testsuite/gas/aarch64/pac_negate_ra_state.d: Likewise.

gas/ChangeLog
gas/dw2gencfi.c
gas/testsuite/gas/aarch64/pac_negate_ra_state.d [new file with mode: 0644]
gas/testsuite/gas/aarch64/pac_negate_ra_state.s [new file with mode: 0644]

index e3db70a9ebf5cec9f477496ed25b173dd0c30c70..95712ae85c2f9828b9c065c8d5d298ad9a34cc0b 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-06  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * dw2gencfi.c (cfi_pseudo_table): Add cfi_negate_ra_state.
+       * testsuite/gas/aarch64/pac_negate_ra_state.s: New file.
+       * testsuite/gas/aarch64/pac_negate_ra_state.d: Likewise.
+
 2019-12-05  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-aarch64.c (aarch64_features): Drop redundant AES and
index c1b5becc0a69937bf5524581ca98bd9592460269..39f9de4b2837eee6a56cd864089f95f2f22b30e0 100644 (file)
@@ -726,6 +726,7 @@ const pseudo_typeS cfi_pseudo_table[] =
     { "cfi_remember_state", dot_cfi, DW_CFA_remember_state },
     { "cfi_restore_state", dot_cfi, DW_CFA_restore_state },
     { "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save },
+    { "cfi_negate_ra_state", dot_cfi, DW_CFA_AARCH64_negate_ra_state },
     { "cfi_escape", dot_cfi_escape, 0 },
     { "cfi_signal_frame", dot_cfi, CFI_signal_frame },
     { "cfi_personality", dot_cfi_personality, 0 },
diff --git a/gas/testsuite/gas/aarch64/pac_negate_ra_state.d b/gas/testsuite/gas/aarch64/pac_negate_ra_state.d
new file mode 100644 (file)
index 0000000..7ab0f23
--- /dev/null
@@ -0,0 +1,26 @@
+#objdump: --dwarf=frames
+
+.+:     file .+
+
+Contents of the .eh_frame section:
+
+00000000 0000000000000010 00000000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 4
+  Data alignment factor: -8
+  Return address column: 30
+  Augmentation data:     1b
+  DW_CFA_def_cfa: r31 \(sp\) ofs 0
+
+00000014 0000000000000018 00000018 FDE cie=00000000 pc=0000000000000000..0000000000000008
+  DW_CFA_advance_loc: 4 to 0000000000000004
+  DW_CFA_GNU_window_save
+  DW_CFA_advance_loc: 4 to 0000000000000008
+  DW_CFA_def_cfa_offset: 16
+  DW_CFA_offset: r29 \(x29\) at cfa-16
+  DW_CFA_offset: r30 \(x30\) at cfa-8
+  DW_CFA_nop
+  DW_CFA_nop
+
+
diff --git a/gas/testsuite/gas/aarch64/pac_negate_ra_state.s b/gas/testsuite/gas/aarch64/pac_negate_ra_state.s
new file mode 100644 (file)
index 0000000..36ddbeb
--- /dev/null
@@ -0,0 +1,20 @@
+       .arch armv8-a
+       .text
+       .align  2
+       .global _Z5foo_av
+       .type   _Z5foo_av, %function
+_Z5foo_av:
+.LFB0:
+       .cfi_startproc
+       hint    25 // paciasp
+       .cfi_negate_ra_state
+       stp     x29, x30, [sp, -16]!
+       .cfi_def_cfa_offset 16
+       .cfi_offset 29, -16
+       .cfi_offset 30, -8
+       .cfi_endproc
+.LFE0:
+       .size   _Z5foo_av, .-_Z5foo_av
+       .align  2
+       .global _Z5foo_bv
+       .type   _Z5foo_bv, %function
This page took 0.02742 seconds and 4 git commands to generate.