[binutils-gdb] aarch64: adapt BTI tests to use selectable GNU properties

Matthieu Longo mlongo@sourceware.org
Mon Dec 2 15:21:16 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=79aff6ea0e8766a72c70679ae04767b6e57e192b

commit 79aff6ea0e8766a72c70679ae04767b6e57e192b
Author: Matthieu Longo <matthieu.longo@arm.com>
Date:   Sat Nov 30 10:27:41 2024 +0000

    aarch64: adapt BTI tests to use selectable GNU properties

Diff:
---
 ld/testsuite/ld-aarch64/protections/bti-plt-1.d    |  2 +-
 ld/testsuite/ld-aarch64/protections/bti-plt-1.s    | 38 +++-----------------
 ld/testsuite/ld-aarch64/protections/bti-plt-2.d    |  2 +-
 ld/testsuite/ld-aarch64/protections/bti-plt-2.s    | 27 ++++++---------
 ld/testsuite/ld-aarch64/protections/bti-plt-3.d    |  2 +-
 ld/testsuite/ld-aarch64/protections/bti-plt-4.d    |  2 +-
 ld/testsuite/ld-aarch64/protections/bti-plt-5.d    |  2 +-
 ld/testsuite/ld-aarch64/protections/bti-warn.d     | 10 +++---
 .../ld-aarch64/protections/property-bti-pac1.s     | 35 +++----------------
 .../ld-aarch64/protections/property-bti-pac2.s     | 40 +++-------------------
 10 files changed, 35 insertions(+), 125 deletions(-)

diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-1.d b/ld/testsuite/ld-aarch64/protections/bti-plt-1.d
index 9fd7c6b2ce7..b7d5f51a553 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-1.d
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-1.d
@@ -1,7 +1,7 @@
 #name: Check -z force-bti emits BTI PLT (shared)
 #source: bti-plt-1.s
 #target: [check_shared_lib_support]
-#as: -mabi=lp64
+#as: -mabi=lp64 -defsym __property_bti__=1
 #ld: -shared -z force-bti -T bti-plt.ld
 #objdump: -dr -j .plt
 
diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-1.s b/ld/testsuite/ld-aarch64/protections/bti-plt-1.s
index 8bb39c44f8d..413e24b2e60 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-1.s
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-1.s
@@ -4,37 +4,9 @@
 _start:
 	bl foo
 	bl bar
-.ifndef __guard_property_bti__
-	.section ".note.gnu.property", "a"
-	.p2align 3
-	.long 1f - 0f		/* name length */
-	.long 5f - 2f		/* data length */
-	.long 5			/* note type */
-0:	.asciz "GNU"		/* vendor name */
-1:
-	.p2align 3
-2:	.long 0xc0000000	/* pr_type.  */
-	.long 4f - 3f		/* pr_datasz.  */
-3:
-	.long 0x1		/* BTI.  */
-4:
-	.p2align 3
-5:
-.endif
-.ifdef __property_pac__
-	.section ".note.gnu.property", "a"
-	.p2align 3
-	.long 1f - 0f		/* name length */
-	.long 5f - 2f		/* data length */
-	.long 5			/* note type */
-0:	.asciz "GNU"		/* vendor name */
-1:
-	.p2align 3
-2:	.long 0xc0000000	/* pr_type.  */
-	.long 4f - 3f		/* pr_datasz.  */
-3:
-	.long 0x2		/* PAC.  */
-4:
-	.p2align 3
-5:
+
+.ifdef __split_gnu_properties__
+.include "gnu-note-properties-selectable-split.inc"
+.else
+.include "gnu-note-properties-selectable-merged.inc"
 .endif
diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-2.d b/ld/testsuite/ld-aarch64/protections/bti-plt-2.d
index c34ab47bf54..e404d532832 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-2.d
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-2.d
@@ -2,7 +2,7 @@
 #source: bti-plt-1.s
 #source: bti-plt-2.s
 #target: [check_shared_lib_support]
-#as: -mabi=lp64
+#as: -mabi=lp64 -defsym __property_bti__=1
 #ld: -shared -z force-bti -T bti-plt.ld
 #readelf: -n
 
diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-2.s b/ld/testsuite/ld-aarch64/protections/bti-plt-2.s
index fff945c9f42..db06621df2b 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-2.s
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-2.s
@@ -1,21 +1,14 @@
 	.text
-	.globl _start
-	.type _start,@function
+	.globl func2
+	.type func2,@function
 func2:
 	bl foo2
 	bl bar2
-	.section ".note.gnu.property", "a"
-	.p2align 3
-	.long 1f - 0f		/* name length */
-	.long 5f - 2f		/* data length */
-	.long 5			/* note type */
-0:	.asciz "GNU"		/* vendor name */
-1:
-	.p2align 3
-2:	.long 0xc0000000	/* pr_type.  */
-	.long 4f - 3f		/* pr_datasz.  */
-3:
-	.long 0x1		/* BTI.  */
-4:
-	.p2align 3
-5:
+	ret
+	.size	func2, .-func2
+
+.ifdef __split_gnu_properties__
+.include "gnu-note-properties-selectable-split.inc"
+.else
+.include "gnu-note-properties-selectable-merged.inc"
+.endif
diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-3.d b/ld/testsuite/ld-aarch64/protections/bti-plt-3.d
index c82878e1eb5..80dbceccf64 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-3.d
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-3.d
@@ -1,7 +1,7 @@
 #name: Check -z force-bti emits BTI PLT (exec)
 #source: bti-plt-1.s
 #target: [check_shared_lib_support]
-#as: -mabi=lp64
+#as: -mabi=lp64 -defsym __property_bti__=1
 #ld: -z force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
 #objdump: -dr -j .plt
 
diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-4.d b/ld/testsuite/ld-aarch64/protections/bti-plt-4.d
index 04d3c7d963f..24a213b6b83 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-4.d
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-4.d
@@ -1,7 +1,7 @@
 #name: Check -z force-bti emits BTI feature (exec)
 #source: bti-plt-1.s
 #target: [check_shared_lib_support]
-#as: -mabi=lp64
+#as: -mabi=lp64 -defsym __property_bti__=1
 #ld: -z force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
 #readelf: -n
 
diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-5.d b/ld/testsuite/ld-aarch64/protections/bti-plt-5.d
index ed0029b8de1..b26fe5b461d 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-5.d
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-5.d
@@ -1,6 +1,6 @@
 #name: BTI PLT with only GNU PROP
 #source: property-bti-pac1.s
-#as: -mabi=lp64 -defsym __property_bti__=1
+#as: -mabi=lp64
 #ld: -e _start -L./tmpdir -lbti-plt-so
 #objdump: -dr -j .plt
 #target: *linux*
diff --git a/ld/testsuite/ld-aarch64/protections/bti-warn.d b/ld/testsuite/ld-aarch64/protections/bti-warn.d
index d10cd104006..9ec6e12650c 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-warn.d
+++ b/ld/testsuite/ld-aarch64/protections/bti-warn.d
@@ -1,11 +1,11 @@
 #name: Warn when both have GNU prop but neither BTI
-#source: property-bti-pac2.s
-#source: bti-plt-1.s
+#source: property-bti-pac1.s
+#source: bti-plt-2.s
 #target: [check_shared_lib_support]
-#as: -mabi=lp64 --defsym __guard_property_bti__=1 --defsym __property_pac__=1
+#as: -mabi=lp64 --defsym __mask_property_bti__=1 --defsym __property_pac__=1
 #ld: -shared -z force-bti
-#warning: .*property-bti-pac2.*: warning: BTI turned on by -z force-bti.*
-#warning: .*bti-plt-1.*: warning: BTI turned on by -z force-bti.*
+#warning: .*property-bti-pac1.*: warning: BTI turned on by -z force-bti.*
+#warning: .*bti-plt-2.*: warning: BTI turned on by -z force-bti.*
 #readelf: -n
 
 # Should warn about the missing input BTI NOTE but should
diff --git a/ld/testsuite/ld-aarch64/protections/property-bti-pac1.s b/ld/testsuite/ld-aarch64/protections/property-bti-pac1.s
index 414c9277f1d..17568c9e6b4 100644
--- a/ld/testsuite/ld-aarch64/protections/property-bti-pac1.s
+++ b/ld/testsuite/ld-aarch64/protections/property-bti-pac1.s
@@ -3,35 +3,10 @@
 	.type _start,@function
 _start:
 	mov x1, #2
-.ifndef __mult__
 	bl foo
+
+.ifdef __split_gnu_properties__
+.include "gnu-note-properties-maskable-split.inc"
+.else
+.include "gnu-note-properties-maskable-merged.inc"
 .endif
-	.section ".note.gnu.property", "a"
-	.p2align 3
-	.long 1f - 0f		/* name length */
-	.long 5f - 2f		/* data length */
-	.long 5			/* note type */
-0:	.asciz "GNU"		/* vendor name */
-1:
-	.p2align 3
-2:	.long 0xc0000000	/* pr_type.  */
-	.long 4f - 3f		/* pr_datasz.  */
-3:
-	.long 0x2		/* PAC.  */
-4:
-	.p2align 3
-5:
-	.p2align 3
-	.long 1f - 0f		/* name length */
-	.long 5f - 2f		/* data length */
-	.long 5			/* note type */
-0:	.asciz "GNU"		/* vendor name */
-1:
-	.p2align 3
-2:	.long 0xc0000000	/* pr_type.  */
-	.long 4f - 3f		/* pr_datasz.  */
-3:
-	.long 0x1		/* BTI.  */
-4:
-	.p2align 3
-5:
diff --git a/ld/testsuite/ld-aarch64/protections/property-bti-pac2.s b/ld/testsuite/ld-aarch64/protections/property-bti-pac2.s
index cdec8d99872..071640cb24e 100644
--- a/ld/testsuite/ld-aarch64/protections/property-bti-pac2.s
+++ b/ld/testsuite/ld-aarch64/protections/property-bti-pac2.s
@@ -12,39 +12,9 @@ foo:
 	add	sp, sp, 16
 	ret
 	.size	foo, .-foo
-	.global	bar
-	.type	bar, %function
-.ifdef __property_bti__
-	.section ".note.gnu.property", "a"
-	.p2align 3
-	.long 1f - 0f		/* name length */
-	.long 5f - 2f		/* data length */
-	.long 5			/* note type */
-0:	.asciz "GNU"		/* vendor name */
-1:
-	.p2align 3
-2:	.long 0xc0000000	/* pr_type.  */
-	.long 4f - 3f		/* pr_datasz.  */
-3:
-	.long 0x1		/* BTI.  */
-4:
-	.p2align 3
-5:
-.endif
-.ifdef __property_pac__
-	.section ".note.gnu.property", "a"
-	.p2align 3
-	.long 1f - 0f		/* name length */
-	.long 5f - 2f		/* data length */
-	.long 5			/* note type */
-0:	.asciz "GNU"		/* vendor name */
-1:
-	.p2align 3
-2:	.long 0xc0000000	/* pr_type.  */
-	.long 4f - 3f		/* pr_datasz.  */
-3:
-	.long 0x2		/* PAC.  */
-4:
-	.p2align 3
-5:
+
+.ifdef __split_gnu_properties__
+.include "gnu-note-properties-selectable-split.inc"
+.else
+.include "gnu-note-properties-selectable-merged.inc"
 .endif


More information about the Binutils-cvs mailing list