[PATCH v1 02/27] aarch64: new tests covering the merge of feature markings

Matthieu Longo matthieu.longo@arm.com
Mon Dec 2 14:21:54 GMT 2024


---
 .../protections/aarch64-protections.exp       |  3 +-
 .../gnu-note-properties-maskable-merged.inc   | 28 ++++++++++
 .../gnu-note-properties-maskable-split.inc    | 51 +++++++++++++++++++
 .../gnu-note-properties-selectable-merged.inc | 28 ++++++++++
 .../gnu-note-properties-selectable-split.inc  | 51 +++++++++++++++++++
 .../protections/gnu-properties-1-all-merged.d | 11 ++++
 .../protections/gnu-properties-1-all-split.d  | 11 ++++
 .../protections/gnu-properties-all.s          | 28 ++++++++++
 .../gnu-properties-combine-2-all-all.d        | 12 +++++
 .../gnu-properties-combine-2-all-bti.d        | 12 +++++
 .../gnu-properties-combine-2-all-pac.d        | 12 +++++
 .../protections/gnu-properties-maskable.s     | 22 ++++++++
 .../protections/gnu-properties-selectable.s   | 22 ++++++++
 13 files changed, 290 insertions(+), 1 deletion(-)
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-merged.inc
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-split.inc
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-merged.inc
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-split.inc
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-merged.d
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-split.d
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-all.s
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-all.d
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-bti.d
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-pac.d
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-maskable.s
 create mode 100644 ld/testsuite/ld-aarch64/protections/gnu-properties-selectable.s

diff --git a/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp b/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
index 803405e0ed5..233384da523 100644
--- a/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
+++ b/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
@@ -55,5 +55,6 @@ foreach t $test_lp64_list {
 
 foreach t $test_list {
   # We need to strip the ".d", but can leave the dirname.
-  run_dump_test [file rootname $t]
+  run_dump_test [file rootname $t] \
+    [list [list as "-I\$srcdir/\$subdir"]]
 }
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-merged.inc b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-merged.inc
new file mode 100644
index 00000000000..5d88a760529
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-merged.inc
@@ -0,0 +1,28 @@
+	.set NT_GNU_PROPERTY_TYPE_0,             5
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0
+.ifndef __mask_property_bti__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI )
+.endif
+.ifndef __mask_property_pac__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC )
+.endif
+.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE
+	.section ".note.gnu.property", "a"
+	.p2align 3
+	.long 1f - 0f			/* name length */
+	.long 5f - 2f			/* data length */
+	.long NT_GNU_PROPERTY_TYPE_0	/* note type */
+0:	.asciz "GNU"			/* vendor name */
+1:
+	.p2align 3
+2:	.long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type.  */
+	.long 4f - 3f				 /* pr_datasz.  */
+3:
+	.long GNU_PROPERTY_AARCH64_FEATURE_1_VALUE
+4:
+	.p2align 3
+5:
+.endif
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-split.inc b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-split.inc
new file mode 100644
index 00000000000..d575bb56b62
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-split.inc
@@ -0,0 +1,51 @@
+	.set NT_GNU_PROPERTY_TYPE_0,             5
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1)
+
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0
+.ifndef __mask_property_bti__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI )
+.endif
+.ifndef __mask_property_pac__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC )
+.endif
+
+.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE
+	.section ".note.gnu.property", "a"
+
+.ifndef __mask_property_bti__
+	.p2align 3
+	.long 1f - 0f			/* name length */
+	.long 5f - 2f			/* data length */
+	.long NT_GNU_PROPERTY_TYPE_0	/* note type */
+0:	.asciz "GNU"			/* vendor name */
+1:
+	.p2align 3
+2:	.long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type.  */
+	.long 4f - 3f				 /* pr_datasz.  */
+3:
+	.long GNU_PROPERTY_AARCH64_FEATURE_1_BTI
+4:
+	.p2align 3
+5:
+.endif
+
+.ifndef __mask_property_pac__
+	.p2align 3
+	.long 1f - 0f			/* name length */
+	.long 5f - 2f			/* data length */
+	.long NT_GNU_PROPERTY_TYPE_0	/* note type */
+0:	.asciz "GNU"			/* vendor name */
+1:
+	.p2align 3
+2:	.long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type.  */
+	.long 4f - 3f				 /* pr_datasz.  */
+3:
+	.long GNU_PROPERTY_AARCH64_FEATURE_1_PAC
+4:
+	.p2align 3
+5:
+.endif
+
+.endif
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-merged.inc b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-merged.inc
new file mode 100644
index 00000000000..ad4c778a23c
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-merged.inc
@@ -0,0 +1,28 @@
+	.set NT_GNU_PROPERTY_TYPE_0,             5
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0
+.ifdef __property_bti__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI )
+.endif
+.ifdef __property_pac__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC )
+.endif
+.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE
+	.section ".note.gnu.property", "a"
+	.p2align 3
+	.long 1f - 0f			/* name length */
+	.long 5f - 2f			/* data length */
+	.long NT_GNU_PROPERTY_TYPE_0	/* note type */
+0:	.asciz "GNU"			/* vendor name */
+1:
+	.p2align 3
+2:	.long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type.  */
+	.long 4f - 3f				 /* pr_datasz.  */
+3:
+	.long GNU_PROPERTY_AARCH64_FEATURE_1_VALUE
+4:
+	.p2align 3
+5:
+.endif
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-split.inc b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-split.inc
new file mode 100644
index 00000000000..0bc37269cb9
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-split.inc
@@ -0,0 +1,51 @@
+	.set NT_GNU_PROPERTY_TYPE_0,             5
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1)
+
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, 0x0
+.ifndef __mask_property_bti__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_BTI )
+.endif
+.ifndef __mask_property_pac__
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_VALUE | GNU_PROPERTY_AARCH64_FEATURE_1_PAC )
+.endif
+
+.if GNU_PROPERTY_AARCH64_FEATURE_1_VALUE
+	.section ".note.gnu.property", "a"
+
+.ifdef __property_bti__
+	.p2align 3
+	.long 1f - 0f			/* name length */
+	.long 5f - 2f			/* data length */
+	.long NT_GNU_PROPERTY_TYPE_0	/* note type */
+0:	.asciz "GNU"			/* vendor name */
+1:
+	.p2align 3
+2:	.long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type.  */
+	.long 4f - 3f				 /* pr_datasz.  */
+3:
+	.long GNU_PROPERTY_AARCH64_FEATURE_1_BTI
+4:
+	.p2align 3
+5:
+.endif
+
+.ifdef __property_pac__
+	.p2align 3
+	.long 1f - 0f			/* name length */
+	.long 5f - 2f			/* data length */
+	.long NT_GNU_PROPERTY_TYPE_0	/* note type */
+0:	.asciz "GNU"			/* vendor name */
+1:
+	.p2align 3
+2:	.long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type.  */
+	.long 4f - 3f				 /* pr_datasz.  */
+3:
+	.long GNU_PROPERTY_AARCH64_FEATURE_1_PAC
+4:
+	.p2align 3
+5:
+.endif
+
+.endif
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-merged.d b/ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-merged.d
new file mode 100644
index 00000000000..cad64c4b184
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-merged.d
@@ -0,0 +1,11 @@
+#name: GNU Property: readelf (single input, all GNU prop values merged in one)
+#source: gnu-properties-maskable.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv8.5-a
+#ld: -shared
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ 	]+Owner[ 	]+Data size[ 	]+Description
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: BTI, PAC
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-split.d b/ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-split.d
new file mode 100644
index 00000000000..c9a447e9edd
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-split.d
@@ -0,0 +1,11 @@
+#name: GNU Property: readelf (single input, combine several GNU prop values)
+#source: gnu-properties-maskable.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv8.5-a -defsym __split_gnu_properties__=1
+#ld: -shared
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ 	]+Owner[ 	]+Data size[ 	]+Description
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: BTI, PAC
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-all.s b/ld/testsuite/ld-aarch64/protections/gnu-properties-all.s
new file mode 100644
index 00000000000..2b52eccf15e
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-all.s
@@ -0,0 +1,28 @@
+	.text
+	.globl _start
+	.type _start,@function
+_start:
+	mov x1, #2
+	bl foo
+
+	.set NT_GNU_PROPERTY_TYPE_0,             5
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, (0x1 << 0)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_PAC, (0x1 << 1)
+	.set GNU_PROPERTY_AARCH64_FEATURE_1_VALUE, ( GNU_PROPERTY_AARCH64_FEATURE_1_BTI | GNU_PROPERTY_AARCH64_FEATURE_1_PAC )
+
+	.section ".note.gnu.property", "a"
+	.p2align 3
+	.long 1f - 0f			/* name length */
+	.long 5f - 2f			/* data length */
+	.long NT_GNU_PROPERTY_TYPE_0	/* note type */
+0:	.asciz "GNU"			/* vendor name */
+1:
+	.p2align 3
+2:	.long GNU_PROPERTY_AARCH64_FEATURE_1_AND /* pr_type.  */
+	.long 4f - 3f				 /* pr_datasz.  */
+3:
+	.long GNU_PROPERTY_AARCH64_FEATURE_1_VALUE
+4:
+	.p2align 3
+5:
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-all.d b/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-all.d
new file mode 100644
index 00000000000..af95020d9b9
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-all.d
@@ -0,0 +1,12 @@
+#name: GNU Property: readelf (combine 2 object files: all + all)
+#source: gnu-properties-all.s
+#source: gnu-properties-selectable.s
+#as: -mabi=lp64 -defsym __property_bti__=1 -defsym __property_pac__=1
+#ld: -e _start
+#readelf: -n
+#target: *linux*
+
+Displaying notes found in: .note.gnu.property
+[ 	]+Owner[ 	]+Data size[ 	]+Description
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: BTI, PAC
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-bti.d b/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-bti.d
new file mode 100644
index 00000000000..ffd1833a4f2
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-bti.d
@@ -0,0 +1,12 @@
+#name: GNU Property: readelf (combine 2 object files: all + BTI only)
+#source: gnu-properties-all.s
+#source: gnu-properties-selectable.s
+#as: -mabi=lp64 -defsym __property_bti__=1
+#ld: -e _start
+#readelf: -n
+#target: *linux*
+
+Displaying notes found in: .note.gnu.property
+[ 	]+Owner[ 	]+Data size[ 	]+Description
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: BTI
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-pac.d b/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-pac.d
new file mode 100644
index 00000000000..c2cad82d2e8
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-pac.d
@@ -0,0 +1,12 @@
+#name: GNU Property: readelf (combine 2 object files: all + PAC only)
+#source: gnu-properties-all.s
+#source: gnu-properties-selectable.s
+#as: -mabi=lp64 -defsym __property_pac__=1
+#ld: -e _start
+#readelf: -n
+#target: *linux*
+
+Displaying notes found in: .note.gnu.property
+[ 	]+Owner[ 	]+Data size[ 	]+Description
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: PAC
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-maskable.s b/ld/testsuite/ld-aarch64/protections/gnu-properties-maskable.s
new file mode 100644
index 00000000000..bf81fd192ce
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-maskable.s
@@ -0,0 +1,22 @@
+	.text
+	.global	foo
+	.type	foo, %function
+foo:
+	sub	sp, sp, #16
+	mov	w0, 9
+	str	w0, [sp, 12]
+	ldr	w0, [sp, 12]
+	add	w0, w0, 4
+	str	w0, [sp, 12]
+	nop
+	add	sp, sp, 16
+	ret
+	.size	foo, .-foo
+	.global	bar
+	.type	bar, %function
+
+.ifdef __split_gnu_properties__
+.include "gnu-note-properties-maskable-split.inc"
+.else
+.include "gnu-note-properties-maskable-merged.inc"
+.endif
diff --git a/ld/testsuite/ld-aarch64/protections/gnu-properties-selectable.s b/ld/testsuite/ld-aarch64/protections/gnu-properties-selectable.s
new file mode 100644
index 00000000000..46ef59c70de
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/gnu-properties-selectable.s
@@ -0,0 +1,22 @@
+	.text
+	.global	foo
+	.type	foo, %function
+foo:
+	sub	sp, sp, #16
+	mov	w0, 9
+	str	w0, [sp, 12]
+	ldr	w0, [sp, 12]
+	add	w0, w0, 4
+	str	w0, [sp, 12]
+	nop
+	add	sp, sp, 16
+	ret
+	.size	foo, .-foo
+	.global	bar
+	.type	bar, %function
+
+.ifdef __split_gnu_properties__
+.include "gnu-note-properties-selectable-split.inc"
+.else
+.include "gnu-note-properties-selectable-merged.inc"
+.endif
-- 
2.47.0



More information about the Binutils mailing list