]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: new tests covering the merge of feature markings
authorMatthieu Longo <matthieu.longo@arm.com>
Fri, 29 Nov 2024 15:24:20 +0000 (15:24 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Mon, 2 Dec 2024 15:18:40 +0000 (15:18 +0000)
13 files changed:
ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-merged.inc [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-note-properties-maskable-split.inc [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-merged.inc [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-note-properties-selectable-split.inc [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-merged.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-1-all-split.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-all.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-all.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-bti.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-combine-2-all-pac.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-maskable.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gnu-properties-selectable.s [new file with mode: 0644]

index 803405e0ed5b7eb45d77563259217766a1163bd7..233384da5231eecc4ba9b8921b74d45ebfd28e0c 100644 (file)
@@ -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 (file)
index 0000000..5d88a76
--- /dev/null
@@ -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 (file)
index 0000000..d575bb5
--- /dev/null
@@ -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 (file)
index 0000000..ad4c778
--- /dev/null
@@ -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 (file)
index 0000000..0bc3726
--- /dev/null
@@ -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 (file)
index 0000000..cad64c4
--- /dev/null
@@ -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 (file)
index 0000000..c9a447e
--- /dev/null
@@ -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 (file)
index 0000000..2b52ecc
--- /dev/null
@@ -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 (file)
index 0000000..af95020
--- /dev/null
@@ -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 (file)
index 0000000..ffd1833
--- /dev/null
@@ -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 (file)
index 0000000..c2cad82
--- /dev/null
@@ -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 (file)
index 0000000..bf81fd1
--- /dev/null
@@ -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 (file)
index 0000000..46ef59c
--- /dev/null
@@ -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