[PATCH v1 05/27] aarch64: new tests for BTI & PAC PLT to use selectable GNU properties
Matthieu Longo
matthieu.longo@arm.com
Mon Dec 2 14:21:57 GMT 2024
---
.../ld-aarch64/protections/bti-pac-plt-1-a.d | 32 +++++++++++++++++
.../ld-aarch64/protections/bti-pac-plt-1-b.d | 36 +++++++++++++++++++
.../ld-aarch64/protections/bti-pac-plt-2-a.d | 36 +++++++++++++++++++
.../ld-aarch64/protections/bti-pac-plt-2-b.d | 36 +++++++++++++++++++
.../ld-aarch64/protections/bti-pac-plt-3-a.d | 36 +++++++++++++++++++
.../ld-aarch64/protections/bti-pac-plt-3-b.d | 36 +++++++++++++++++++
.../ld-aarch64/protections/bti-pac-plt.s | 12 +++++++
7 files changed, 224 insertions(+)
create mode 100644 ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-a.d
create mode 100644 ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-b.d
create mode 100644 ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-a.d
create mode 100644 ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-b.d
create mode 100644 ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-a.d
create mode 100644 ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-b.d
create mode 100644 ld/testsuite/ld-aarch64/protections/bti-pac-plt.s
diff --git a/ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-a.d b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-a.d
new file mode 100644
index 00000000000..96268d3e7d4
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-a.d
@@ -0,0 +1,32 @@
+#name: No '-z force-bti' nor '-z pac-plt' with no feature properties does not generate a BTI & PAC PLT (shared)
+#source: bti-pac-plt.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64
+#ld: -shared -T bti-plt.ld
+#objdump: -dr -j .plt
+
+[^:]*: *file format elf64-.*aarch64
+
+Disassembly of section \.plt:
+
+[0-9a-f]+ <\.plt>:
+.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]!
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9400e11 ldr x17, \[x16, #24\]
+.*: 91006210 add x16, x16, #0x18
+.*: d61f0220 br x17
+.*: d503201f nop
+.*: d503201f nop
+.*: d503201f nop
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401211 ldr x17, \[x16, #32\]
+.*: 91008210 add x16, x16, #0x20
+.*: d61f0220 br x17
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401611 ldr x17, \[x16, #40\]
+.*: 9100a210 add x16, x16, #0x28
+.*: d61f0220 br x17
diff --git a/ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-b.d b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-b.d
new file mode 100644
index 00000000000..041bf22415d
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-1-b.d
@@ -0,0 +1,36 @@
+#name: No '-z force-bti' nor '-z pac-plt' with feature properties (BTI & PAC) forces the generation of BTI PLT without PAC (shared)
+## Note: Use of PAC in PLT sequences is a contract between the dynamic loader
+## and the static linker, it is independent of whether the relocatable objects
+## use PAC. So it means that the PAC flag in the GNU property can be completely
+## ignored contrarily to BTI which is all or nothing property for a link unit.
+#source: bti-pac-plt.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64 -defsym __property_bti__=1 -defsym __property_pac__=1
+#ld: -shared -T bti-plt.ld
+#objdump: -dr -j .plt
+
+[^:]*: *file format elf64-.*aarch64
+
+Disassembly of section \.plt:
+
+[0-9a-f]+ <\.plt>:
+.*: d503245f bti c
+.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]!
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9400e11 ldr x17, \[x16, #24\]
+.*: 91006210 add x16, x16, #0x18
+.*: d61f0220 br x17
+.*: d503201f nop
+.*: d503201f nop
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401211 ldr x17, \[x16, #32\]
+.*: 91008210 add x16, x16, #0x20
+.*: d61f0220 br x17
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401611 ldr x17, \[x16, #40\]
+.*: 9100a210 add x16, x16, #0x28
+.*: d61f0220 br x17
diff --git a/ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-a.d b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-a.d
new file mode 100644
index 00000000000..f1ae3cd9b09
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-a.d
@@ -0,0 +1,36 @@
+#name: Specifying '-z force-bti' and '-z pac-plt' along feature properties (BTI only) forces the generation of BTI & PAC PLT (shared)
+#source: bti-pac-plt.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64 -defsym __property_bti__=1
+#ld: -shared -z force-bti -z pac-plt -T bti-plt.ld
+#objdump: -dr -j .plt
+
+[^:]*: *file format elf64-.*aarch64
+
+Disassembly of section \.plt:
+
+[0-9a-f]+ <\.plt>:
+.*: d503245f bti c
+.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]!
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9400e11 ldr x17, \[x16, #24\]
+.*: 91006210 add x16, x16, #0x18
+.*: d61f0220 br x17
+.*: d503201f nop
+.*: d503201f nop
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401211 ldr x17, \[x16, #32\]
+.*: 91008210 add x16, x16, #0x20
+.*: d503219f autia1716
+.*: d61f0220 br x17
+.*: d503201f nop
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401611 ldr x17, \[x16, #40\]
+.*: 9100a210 add x16, x16, #0x28
+.*: d503219f autia1716
+.*: d61f0220 br x17
+.*: d503201f nop
diff --git a/ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-b.d b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-b.d
new file mode 100644
index 00000000000..69ccaab4993
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-2-b.d
@@ -0,0 +1,36 @@
+#name: Specifying '-z force-bti' and '-z pac-plt' along feature properties (BTI only) forces the generation of BTI & PAC PLT (exec)
+#source: bti-pac-plt.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64 -defsym __property_bti__=1
+#ld: -z force-bti -z pac-plt -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
+#objdump: -dr -j .plt
+
+[^:]*: *file format elf64-.*aarch64
+
+Disassembly of section \.plt:
+
+[0-9]+ <\.plt>:
+.*: d503245f bti c
+.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]!
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9400e11 ldr x17, \[x16, #24\]
+.*: 91006210 add x16, x16, #0x18
+.*: d61f0220 br x17
+.*: d503201f nop
+.*: d503201f nop
+
+[0-9]+ <.*>:
+.*: d503245f bti c
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401211 ldr x17, \[x16, #32\]
+.*: 91008210 add x16, x16, #0x20
+.*: d503219f autia1716
+.*: d61f0220 br x17
+
+[0-9]+ <.*>:
+.*: d503245f bti c
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401611 ldr x17, \[x16, #40\]
+.*: 9100a210 add x16, x16, #0x28
+.*: d503219f autia1716
+.*: d61f0220 br x17
diff --git a/ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-a.d b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-a.d
new file mode 100644
index 00000000000..c0c0bdb2af0
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-a.d
@@ -0,0 +1,36 @@
+#name: Specifying '-z pac-plt' along feature properties (BTI only) forces the generation of BTI & PAC PLT (shared)
+#source: bti-pac-plt.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64 -defsym __property_bti__=1
+#ld: -shared -z pac-plt -T bti-plt.ld
+#objdump: -dr -j .plt
+
+[^:]*: *file format elf64-.*aarch64
+
+Disassembly of section \.plt:
+
+[0-9a-f]+ <\.plt>:
+.*: d503245f bti c
+.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]!
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9400e11 ldr x17, \[x16, #24\]
+.*: 91006210 add x16, x16, #0x18
+.*: d61f0220 br x17
+.*: d503201f nop
+.*: d503201f nop
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401211 ldr x17, \[x16, #32\]
+.*: 91008210 add x16, x16, #0x20
+.*: d503219f autia1716
+.*: d61f0220 br x17
+.*: d503201f nop
+
+[0-9a-f]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401611 ldr x17, \[x16, #40\]
+.*: 9100a210 add x16, x16, #0x28
+.*: d503219f autia1716
+.*: d61f0220 br x17
+.*: d503201f nop
diff --git a/ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-b.d b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-b.d
new file mode 100644
index 00000000000..89a08ae6b7c
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-pac-plt-3-b.d
@@ -0,0 +1,36 @@
+#name: Specifying '-z pac-plt' along feature properties (BTI only) forces the generation of BTI & PAC PLT (exec)
+#source: bti-pac-plt.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64 -defsym __property_bti__=1
+#ld: -z pac-plt -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
+#objdump: -dr -j .plt
+
+[^:]*: *file format elf64-.*aarch64
+
+Disassembly of section \.plt:
+
+[0-9]+ <\.plt>:
+.*: d503245f bti c
+.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]!
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9400e11 ldr x17, \[x16, #24\]
+.*: 91006210 add x16, x16, #0x18
+.*: d61f0220 br x17
+.*: d503201f nop
+.*: d503201f nop
+
+[0-9]+ <.*>:
+.*: d503245f bti c
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401211 ldr x17, \[x16, #32\]
+.*: 91008210 add x16, x16, #0x20
+.*: d503219f autia1716
+.*: d61f0220 br x17
+
+[0-9]+ <.*>:
+.*: d503245f bti c
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401611 ldr x17, \[x16, #40\]
+.*: 9100a210 add x16, x16, #0x28
+.*: d503219f autia1716
+.*: d61f0220 br x17
diff --git a/ld/testsuite/ld-aarch64/protections/bti-pac-plt.s b/ld/testsuite/ld-aarch64/protections/bti-pac-plt.s
new file mode 100644
index 00000000000..413e24b2e60
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-pac-plt.s
@@ -0,0 +1,12 @@
+ .text
+ .globl _start
+ .type _start,@function
+_start:
+ bl foo
+ bl bar
+
+.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