]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: GCS tests for linking issues with dynamic objects
authorMatthieu Longo <matthieu.longo@arm.com>
Tue, 5 Nov 2024 12:58:51 +0000 (12:58 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Wed, 15 Jan 2025 17:15:27 +0000 (17:15 +0000)
18 files changed:
ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-a.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-b.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-i.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-ii.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iii.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iv.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-b.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-c.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-d.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-a.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-b.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-c.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-a.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-b.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-c.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-so.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/gcs-so2.s [new file with mode: 0644]

index b49428d10396fd889f9cfc014105df26a3a2bd95..cf0f03daee67742f194dc33602bf4fba5f6daa16 100644 (file)
@@ -42,6 +42,21 @@ set aarch64elflinktests {
    "-shared" ""
    "-I$srcdir/$subdir -defsym __property_bti__=1"
    {bti-plt-so.s} {} "libbti-plt-so.so"}
+
+  {"Build gcs-so for GCS tests"
+   "-shared" ""
+   "-I$srcdir/$subdir -defsym __property_gcs__=1"
+   {gcs-so.s} {} "libgcs-so.so"}
+
+  {"Build nogcs-so for GCS tests"
+   "-shared" ""
+   "-I$srcdir/$subdir"
+   {gcs-so.s} {} "libnogcs-so.so"}
+
+  {"Build gcs-so2 for GCS tests"
+   "-shared" ""
+   "-I$srcdir/$subdir -defsym __property_gcs__=1"
+   {gcs-so2.s} {} "libgcs-so2.so"}
 }
 
 if [check_shared_lib_support] {
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-a.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-a.d
new file mode 100644 (file)
index 0000000..be8a301
--- /dev/null
@@ -0,0 +1,12 @@
+#name: '-z gcs=always -z gcs-report=error' and shared library with GCS feature reports no error.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=error -L./tmpdir -lgcs-so
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-b.d
new file mode 100644 (file)
index 0000000..d53d45a
--- /dev/null
@@ -0,0 +1,12 @@
+#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=error' and shared library with GCS feature reports no error.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=error -L./tmpdir -lgcs-so
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-i.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-i.d
new file mode 100644 (file)
index 0000000..903d140
--- /dev/null
@@ -0,0 +1,15 @@
+#name: '-z gcs=always -z gcs-report=error' and shared libraries without GCS feature reports warnings.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
+#warning:   [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
+
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-ii.d
new file mode 100644 (file)
index 0000000..7adb481
--- /dev/null
@@ -0,0 +1,8 @@
+#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=error' and shared libraries without GCS feature reports errors.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#error: \A[^\n]*libnogcs-so\.so: error: GCS is required by -z gcs[^\n]*\n
+#error:   [^\n]*libbti-plt-so\.so: error: GCS is required by -z gcs[^\n]*
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iii.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iii.d
new file mode 100644 (file)
index 0000000..76a7c46
--- /dev/null
@@ -0,0 +1,15 @@
+#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=warning' and shared libraries without GCS feature reports warnings.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
+#warning:   [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
+
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iv.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iv.d
new file mode 100644 (file)
index 0000000..554ca11
--- /dev/null
@@ -0,0 +1,12 @@
+#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=none' and shared libraries without GCS feature reports nothing.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-b.d
new file mode 100644 (file)
index 0000000..36262bb
--- /dev/null
@@ -0,0 +1,14 @@
+#name: '-z gcs=always -z gcs-report=warning' and shared libraries without GCS feature reports warnings.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
+#warning:   [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-c.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-c.d
new file mode 100644 (file)
index 0000000..6c7f5da
--- /dev/null
@@ -0,0 +1,12 @@
+#name: '-z gcs=always -z gcs-report=none' and shared libraries without GCS feature reports nothing.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-d.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-d.d
new file mode 100644 (file)
index 0000000..58498e6
--- /dev/null
@@ -0,0 +1,14 @@
+#name: '-z gcs=always -z gcs-report' and shared libraries without GCS feature reports warnings.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=always -z gcs-report -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
+#warning:   [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-a.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-a.d
new file mode 100644 (file)
index 0000000..ecdaf52
--- /dev/null
@@ -0,0 +1,15 @@
+#name: '-z gcs=implicit -z gcs-report=error' and shared libraries without GCS feature reports warnings.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=implicit -z gcs-report=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
+#warning:   [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
+
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-b.d
new file mode 100644 (file)
index 0000000..4d32fb6
--- /dev/null
@@ -0,0 +1,14 @@
+#name: '-z gcs=implicit -z gcs-report=warning' and shared libraries without GCS feature reports warnings.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=implicit -z gcs-report=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
+#warning:   [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-c.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-c.d
new file mode 100644 (file)
index 0000000..c0da6c1
--- /dev/null
@@ -0,0 +1,12 @@
+#name: '-z gcs=implicit -z gcs-report=none' and shared libraries without GCS feature reports no warning.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=implicit -z gcs-report=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[      ]+Owner[        ]+Data size[    ]+Description
+  GNU                  0x00000010      NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-a.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-a.d
new file mode 100644 (file)
index 0000000..ae324bb
--- /dev/null
@@ -0,0 +1,7 @@
+#name: '-z gcs=never -z gcs-report=error' and shared libraries without GCS feature reports no warning/error.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=never -z gcs-report=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#readelf: -n
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-b.d
new file mode 100644 (file)
index 0000000..6b65898
--- /dev/null
@@ -0,0 +1,7 @@
+#name: '-z gcs=never -z gcs-report=warning' and shared libraries without GCS feature reports no warning/error.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=never -z gcs-report=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#readelf: -n
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-c.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-c.d
new file mode 100644 (file)
index 0000000..35b011f
--- /dev/null
@@ -0,0 +1,7 @@
+#name: '-z gcs=never -z gcs-report=none' and shared libraries without GCS feature reports no warning/error.
+#source: gcs.s
+#source: gcs2.s
+#alltargets: [check_shared_lib_support] *linux*
+#as: -march=armv9.4-a+gcs  -defsym __property_gcs__=1
+#ld: -z gcs=never -z gcs-report=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
+#readelf: -n
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-so.s b/ld/testsuite/ld-aarch64/protections/gcs-so.s
new file mode 100644 (file)
index 0000000..aa6485b
--- /dev/null
@@ -0,0 +1,28 @@
+       .global foo2
+       .type   foo2, %function
+foo2:
+       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   foo2, .-foo2
+       .global bar2
+       .type   bar2, %function
+bar2:
+       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   bar2, .-bar2
+
+.include "gnu-note-properties-selectable-merged.inc"
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-so2.s b/ld/testsuite/ld-aarch64/protections/gcs-so2.s
new file mode 100644 (file)
index 0000000..938ba43
--- /dev/null
@@ -0,0 +1,28 @@
+       .global foo3
+       .type   foo3, %function
+foo3:
+       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   foo3, .-foo3
+       .global bar3
+       .type   bar3, %function
+bar3:
+       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   bar3, .-bar3
+
+.include "gnu-note-properties-selectable-merged.inc"