[Binutils,gas] arm: Add support for new unwinder directive ".pacspval".

Message ID c5ab35f0-595a-439c-b120-f93bd109ab96@AZ-NEU-EX04.Arm.com
State Not Applicable
Headers
Series [Binutils,gas] arm: Add support for new unwinder directive ".pacspval". |

Checks

Context Check Description
snail/binutils-gdb-check fail Git am fail log

Commit Message

Srinath Parvathaneni Nov. 11, 2022, 10:51 a.m. UTC
  Hi,

This patch adds the assembler support for the new unwinder directive
".pacspval" and encodes this directives with opcode "0xb5". This opcode
indicates the unwinder to use effective vsp as modifier for PAC validation.

Regression testing for arm-none-eabi target and found no regressions.

Ok for binutils-master?

Regards,
Srinath.

gas/ChangeLog:

2022-11-07  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

        * doc/c-arm.texi: Document directive.
        * config/tc-arm.c (s_arm_unwind_pacspval): Define function.
        (md_pseudo_table): Add entry for pacspval directive.
        * testsuite/gas/arm/ehabi-pacbti-m.d: New test.
        * testsuite/gas/arm/ehabi-pacbti-m.s: Likewise.


###############     Attachment also inlined for ease of reply    ###############
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 0f7d7695c0eb9b2eb5431ca314c54edfed9b633e..c7837195e667a03d3f8f6d16b62c01ac875ee5fd 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -4929,6 +4929,22 @@ s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
+/* Parse an unwind_pacspval directive.  */
+
+static void
+s_arm_unwind_pacspval (int ignored ATTRIBUTE_UNUSED)
+{
+  valueT op;
+
+  if (!unwind.proc_start)
+    as_bad (MISSING_FNSTART);
+
+  demand_empty_rest_of_line ();
+
+  op = 0xb5;
+  add_unwind_opcode (op, 1);
+}
+
 /* Parse an unwind_setfp directive.  */
 
 static void
@@ -5205,6 +5221,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "vsave",		s_arm_unwind_save,	1 },
   { "movsp",		s_arm_unwind_movsp,	0 },
   { "pad",		s_arm_unwind_pad,	0 },
+  { "pacspval",		s_arm_unwind_pacspval,	0 },
   { "setfp",		s_arm_unwind_setfp,	0 },
   { "unwind_raw",	s_arm_unwind_raw,	0 },
   { "eabi_attribute",	s_arm_eabi_attribute,	0 },
diff --git a/gas/doc/c-arm.texi b/gas/doc/c-arm.texi
index 4016d3a76957e545ad8d3f1fad2067b94bb9b83e..8e00ccf55a5c86443e2977c3b8c6f4e6d7ef39d9 100644
--- a/gas/doc/c-arm.texi
+++ b/gas/doc/c-arm.texi
@@ -1085,6 +1085,12 @@ This directive writes 12-byte packed floating-point values to the
 output section.  These are not compatible with current ARM processors
 or ABIs.
 
+@anchor{arm_pacspval}
+@cindex @code{.pacspval} directive, ARM
+@item .pacspval
+Generate unwinder annotations to use effective vsp as modifier in PAC
+validation.
+
 @anchor{arm_pad}
 @cindex @code{.pad} directive, ARM
 @item .pad #@var{count}
diff --git a/gas/testsuite/gas/arm/ehabi-pacbti-m.d b/gas/testsuite/gas/arm/ehabi-pacbti-m.d
new file mode 100644
index 0000000000000000000000000000000000000000..6039945f931a2975ae4752a5f711e62a00b6ce69
--- /dev/null
+++ b/gas/testsuite/gas/arm/ehabi-pacbti-m.d
@@ -0,0 +1,15 @@
+# name: Unwind Stack Frame information for Armv8.1-M.Mainline PAC extension
+# source: ehabi-pacbti-m.s
+# as: -march=armv8.1-m.main+mve+pacbti
+# readelf: -u
+
+Unwind section '.ARM.exidx' at offset 0x5c contains 1 entry:
+
+0x0: @0x0
+  Compact model index: 1
+  0xb1 0x08 pop {r3}
+  0x80 0x08 pop {r7}
+  0xb4      pop {ra_auth_code}
+  0x84 0x00 pop {r14}
+  0xb1 0x0f pop {r0, r1, r2, r3}
+  0xb5      vsp as modifier for PAC validation
diff --git a/gas/testsuite/gas/arm/ehabi-pacbti-m.s b/gas/testsuite/gas/arm/ehabi-pacbti-m.s
new file mode 100644
index 0000000000000000000000000000000000000000..10185484c8c9716c394ab0cbe171c626b9847bfc
--- /dev/null
+++ b/gas/testsuite/gas/arm/ehabi-pacbti-m.s
@@ -0,0 +1,38 @@
+        .syntax unified
+        .thumb
+        .thumb_func
+	.fnstart
+	.cfi_startproc
+	.pacspval
+	pac	ip, lr, sp
+	.cfi_register 143, 12
+	push	{r0, r1, r2, r3}
+	.save {r0, r1, r2, r3}
+	.cfi_def_cfa_offset 16
+	.cfi_offset 0, -16
+	.cfi_offset 1, -12
+	.cfi_offset 2, -8
+	.cfi_offset 3, -4
+	push	{r3, r7, ip, lr}
+	.save {r3, r7, ra_auth_code, lr}
+	.cfi_def_cfa_offset 32
+	.cfi_offset 3, -32
+	.cfi_offset 7, -28
+	.cfi_offset 143, -24
+	.cfi_offset 14, -20
+	pop	{r3, r7, ip, lr}
+	.cfi_restore 14
+	.cfi_restore 143
+	.cfi_restore 7
+	.cfi_restore 3
+	.cfi_def_cfa_offset 0
+	add	sp, sp, #16
+	.cfi_restore 3
+	.cfi_restore 2
+	.cfi_restore 1
+	.cfi_restore 0
+	.cfi_def_cfa_offset -16
+	aut	ip, lr, sp
+	bx	lr
+	.cfi_endproc
+	.fnend
  

Comments

Nick Clifton Nov. 14, 2022, 2:20 p.m. UTC | #1
Hi Srinath,

> 2022-11-07  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
> 
>          * doc/c-arm.texi: Document directive.
>          * config/tc-arm.c (s_arm_unwind_pacspval): Define function.
>          (md_pseudo_table): Add entry for pacspval directive.
>          * testsuite/gas/arm/ehabi-pacbti-m.d: New test.
>          * testsuite/gas/arm/ehabi-pacbti-m.s: Likewise.

Approved - please apply.

Note - for future reference - when one patch depends upon another
it is helpful to mention it.  For example, when I was testing this
patch I did not have your patch to readelf applied, so the new test
failed.  Once I had noticed this and applied the readelf patch,
everything worked OK, but it would have saved me time if I had known
that I needed to apply both patches at the same time.

Cheers
   Nick
  
Alan Modra Nov. 15, 2022, 9:51 p.m. UTC | #2
On Mon, Nov 14, 2022 at 02:20:43PM +0000, Nick Clifton via Binutils wrote:
> >          * testsuite/gas/arm/ehabi-pacbti-m.d: New test.
> >          * testsuite/gas/arm/ehabi-pacbti-m.s: Likewise.

New tests should be widely tested.  This on fails on arm-pe and other
non-ELF targets with complaints that .cfi directives are unknown.

	* testsuite/gas/arm/ehabi-pacbti-m.d: Limit test to ELF.

diff --git a/gas/testsuite/gas/arm/ehabi-pacbti-m.d b/gas/testsuite/gas/arm/ehabi-pacbti-m.d
index 6039945f931..1b13020835c 100644
--- a/gas/testsuite/gas/arm/ehabi-pacbti-m.d
+++ b/gas/testsuite/gas/arm/ehabi-pacbti-m.d
@@ -1,7 +1,8 @@
-# name: Unwind Stack Frame information for Armv8.1-M.Mainline PAC extension
-# source: ehabi-pacbti-m.s
-# as: -march=armv8.1-m.main+mve+pacbti
-# readelf: -u
+#name: Unwind Stack Frame information for Armv8.1-M.Mainline PAC extension
+#source: ehabi-pacbti-m.s
+#as: -march=armv8.1-m.main+mve+pacbti
+#readelf: -u
+#target: [is_elf_format]
 
 Unwind section '.ARM.exidx' at offset 0x5c contains 1 entry:
  

Patch

diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 0f7d7695c0eb9b2eb5431ca314c54edfed9b633e..c7837195e667a03d3f8f6d16b62c01ac875ee5fd 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -4929,6 +4929,22 @@  s_arm_unwind_pad (int ignored ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
+/* Parse an unwind_pacspval directive.  */
+
+static void
+s_arm_unwind_pacspval (int ignored ATTRIBUTE_UNUSED)
+{
+  valueT op;
+
+  if (!unwind.proc_start)
+    as_bad (MISSING_FNSTART);
+
+  demand_empty_rest_of_line ();
+
+  op = 0xb5;
+  add_unwind_opcode (op, 1);
+}
+
 /* Parse an unwind_setfp directive.  */
 
 static void
@@ -5205,6 +5221,7 @@  const pseudo_typeS md_pseudo_table[] =
   { "vsave",		s_arm_unwind_save,	1 },
   { "movsp",		s_arm_unwind_movsp,	0 },
   { "pad",		s_arm_unwind_pad,	0 },
+  { "pacspval",		s_arm_unwind_pacspval,	0 },
   { "setfp",		s_arm_unwind_setfp,	0 },
   { "unwind_raw",	s_arm_unwind_raw,	0 },
   { "eabi_attribute",	s_arm_eabi_attribute,	0 },
diff --git a/gas/doc/c-arm.texi b/gas/doc/c-arm.texi
index 4016d3a76957e545ad8d3f1fad2067b94bb9b83e..8e00ccf55a5c86443e2977c3b8c6f4e6d7ef39d9 100644
--- a/gas/doc/c-arm.texi
+++ b/gas/doc/c-arm.texi
@@ -1085,6 +1085,12 @@  This directive writes 12-byte packed floating-point values to the
 output section.  These are not compatible with current ARM processors
 or ABIs.
 
+@anchor{arm_pacspval}
+@cindex @code{.pacspval} directive, ARM
+@item .pacspval
+Generate unwinder annotations to use effective vsp as modifier in PAC
+validation.
+
 @anchor{arm_pad}
 @cindex @code{.pad} directive, ARM
 @item .pad #@var{count}
diff --git a/gas/testsuite/gas/arm/ehabi-pacbti-m.d b/gas/testsuite/gas/arm/ehabi-pacbti-m.d
new file mode 100644
index 0000000000000000000000000000000000000000..6039945f931a2975ae4752a5f711e62a00b6ce69
--- /dev/null
+++ b/gas/testsuite/gas/arm/ehabi-pacbti-m.d
@@ -0,0 +1,15 @@ 
+# name: Unwind Stack Frame information for Armv8.1-M.Mainline PAC extension
+# source: ehabi-pacbti-m.s
+# as: -march=armv8.1-m.main+mve+pacbti
+# readelf: -u
+
+Unwind section '.ARM.exidx' at offset 0x5c contains 1 entry:
+
+0x0: @0x0
+  Compact model index: 1
+  0xb1 0x08 pop {r3}
+  0x80 0x08 pop {r7}
+  0xb4      pop {ra_auth_code}
+  0x84 0x00 pop {r14}
+  0xb1 0x0f pop {r0, r1, r2, r3}
+  0xb5      vsp as modifier for PAC validation
diff --git a/gas/testsuite/gas/arm/ehabi-pacbti-m.s b/gas/testsuite/gas/arm/ehabi-pacbti-m.s
new file mode 100644
index 0000000000000000000000000000000000000000..10185484c8c9716c394ab0cbe171c626b9847bfc
--- /dev/null
+++ b/gas/testsuite/gas/arm/ehabi-pacbti-m.s
@@ -0,0 +1,38 @@ 
+        .syntax unified
+        .thumb
+        .thumb_func
+	.fnstart
+	.cfi_startproc
+	.pacspval
+	pac	ip, lr, sp
+	.cfi_register 143, 12
+	push	{r0, r1, r2, r3}
+	.save {r0, r1, r2, r3}
+	.cfi_def_cfa_offset 16
+	.cfi_offset 0, -16
+	.cfi_offset 1, -12
+	.cfi_offset 2, -8
+	.cfi_offset 3, -4
+	push	{r3, r7, ip, lr}
+	.save {r3, r7, ra_auth_code, lr}
+	.cfi_def_cfa_offset 32
+	.cfi_offset 3, -32
+	.cfi_offset 7, -28
+	.cfi_offset 143, -24
+	.cfi_offset 14, -20
+	pop	{r3, r7, ip, lr}
+	.cfi_restore 14
+	.cfi_restore 143
+	.cfi_restore 7
+	.cfi_restore 3
+	.cfi_def_cfa_offset 0
+	add	sp, sp, #16
+	.cfi_restore 3
+	.cfi_restore 2
+	.cfi_restore 1
+	.cfi_restore 0
+	.cfi_def_cfa_offset -16
+	aut	ip, lr, sp
+	bx	lr
+	.cfi_endproc
+	.fnend