]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: move tests for AArch64 protections (BTI, PAC) into a subfolder
authorMatthieu Longo <matthieu.longo@arm.com>
Mon, 28 Oct 2024 13:59:55 +0000 (13:59 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Mon, 2 Dec 2024 15:18:40 +0000 (15:18 +0000)
- moved all the BTI and PAC tests into a new subfolder: "protections".
    bti-far-*
    bti-plt-*
    bti-pac-plt-*
- move several procedures used only for AArch64 linker tests to a new exp
  library file aarch64-elf-lib.exp in ld/testsuite/ld-aarch64/lib.
- use aarch64-elf-lib.exp in aarch64-ld.exp and aarch64-protections.exp.

38 files changed:
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/lib/aarch64-elf-lib.exp [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/aarch64-protections.exp [new file with mode: 0644]
ld/testsuite/ld-aarch64/protections/bti-far-1.d [moved from ld/testsuite/ld-aarch64/bti-far-1.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-2.d [moved from ld/testsuite/ld-aarch64/bti-far-2.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-3.d [moved from ld/testsuite/ld-aarch64/bti-far-3.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-3.ld [moved from ld/testsuite/ld-aarch64/bti-far-3.ld with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-3a.s [moved from ld/testsuite/ld-aarch64/bti-far-3a.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-3b.s [moved from ld/testsuite/ld-aarch64/bti-far-3b.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-3c.s [moved from ld/testsuite/ld-aarch64/bti-far-3c.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-opt.d [moved from ld/testsuite/ld-aarch64/bti-far-opt.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far-opt.s [moved from ld/testsuite/ld-aarch64/bti-far-opt.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far.ld [moved from ld/testsuite/ld-aarch64/bti-far.ld with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-far.s [moved from ld/testsuite/ld-aarch64/bti-far.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-pac-plt-1.d [moved from ld/testsuite/ld-aarch64/bti-pac-plt-1.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-pac-plt-2.d [moved from ld/testsuite/ld-aarch64/bti-pac-plt-2.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-1.d [moved from ld/testsuite/ld-aarch64/bti-plt-1.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-1.s [moved from ld/testsuite/ld-aarch64/bti-plt-1.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-2.d [moved from ld/testsuite/ld-aarch64/bti-plt-2.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-2.s [moved from ld/testsuite/ld-aarch64/bti-plt-2.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-3.d [moved from ld/testsuite/ld-aarch64/bti-plt-3.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-4.d [moved from ld/testsuite/ld-aarch64/bti-plt-4.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-5.d [moved from ld/testsuite/ld-aarch64/bti-plt-5.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-6.d [moved from ld/testsuite/ld-aarch64/bti-plt-6.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-7.d [moved from ld/testsuite/ld-aarch64/bti-plt-7.d with 94% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt-so.s [moved from ld/testsuite/ld-aarch64/bti-plt-so.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-plt.ld [moved from ld/testsuite/ld-aarch64/bti-plt.ld with 100% similarity]
ld/testsuite/ld-aarch64/protections/bti-warn.d [moved from ld/testsuite/ld-aarch64/bti-warn.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/pac-plt-1.d [moved from ld/testsuite/ld-aarch64/pac-plt-1.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/pac-plt-2.d [moved from ld/testsuite/ld-aarch64/pac-plt-2.d with 95% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac1.d [moved from ld/testsuite/ld-aarch64/property-bti-pac1.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac1.s [moved from ld/testsuite/ld-aarch64/property-bti-pac1.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac2.d [moved from ld/testsuite/ld-aarch64/property-bti-pac2.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac2.s [moved from ld/testsuite/ld-aarch64/property-bti-pac2.s with 100% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac3.d [moved from ld/testsuite/ld-aarch64/property-bti-pac3.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac4-a.d [moved from ld/testsuite/ld-aarch64/property-bti-pac4-a.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac4-b.d [moved from ld/testsuite/ld-aarch64/property-bti-pac4-b.d with 100% similarity]
ld/testsuite/ld-aarch64/protections/property-bti-pac4.s [moved from ld/testsuite/ld-aarch64/property-bti-pac4.s with 100% similarity]

index c7d97f3ced99cc5b8da8182e31a78bb77778499c..e65d4ce5a3d19d674ebb75bd0c5f06fda54c7e25 100644 (file)
@@ -23,6 +23,8 @@ if { ![is_elf_format] || ![istarget "aarch64*-*-*"] } {
     return
 }
 
+load_lib $srcdir/$subdir/lib/aarch64-elf-lib.exp
+
 # List contains test-items with 3 items followed by 2 lists:
 # 0:name 1:ld early options 2:ld late options 3:assembler options
 # 4:filenames of assembler files 5: action and options. 6: name of output file
@@ -46,41 +48,6 @@ set tmp {
 }
 if [check_shared_lib_support] { append aarch64elftests $tmp }
 
-proc aarch64_choose_ilp32_emul {} {
-    if [istarget *linux*] then {
-       if [istarget aarch64_be-*] {
-           return "aarch64linux32b"
-       }
-       return "aarch64linux32"
-    }
-    if [istarget aarch64_be-*] {
-        return "aarch64elf32b"
-    }
-    return "aarch64elf32"
-}
-
-proc aarch64_choose_lp64_emul {} {
-    if [istarget *linux*] then {
-       if [istarget aarch64_be-*] {
-           return "aarch64linuxb"
-       }
-       return "aarch64linux"
-    }
-    if [istarget *nto*] then {
-       return "aarch64nto"
-    }
-    if [istarget aarch64_be-*] {
-        return "aarch64elfb"
-    }
-    return "aarch64elf"
-}
-
-proc run_dump_test_lp64 { testname } {
-  run_dump_test $testname \
-               [list [list as "-mabi=lp64"] \
-                     [list ld [concat "-m " [aarch64_choose_lp64_emul]]]]
-}
-
 set eh-frame-merge-lp64 [list [list "EH Frame merge" \
                              [concat "-m " [aarch64_choose_lp64_emul] \
                                      " -Ttext 0x8000"] \
@@ -405,14 +372,6 @@ run_dump_test_lp64 "rela-idempotent"
 
 run_dump_test_lp64 "pie-bind-locally"
 
-run_dump_test "property-bti-pac1"
-run_dump_test "property-bti-pac2"
-run_dump_test "property-bti-pac3"
-run_dump_test "property-bti-pac4-a"
-run_dump_test "property-bti-pac4-b"
-run_dump_test "bti-plt-1"
-run_dump_test "bti-plt-2"
-
 run_dump_test_lp64 "variant_pcs-r"
 run_dump_test_lp64 "variant_pcs-shared"
 run_dump_test_lp64 "variant_pcs-now"
@@ -433,8 +392,6 @@ set aarch64elflinktests {
   {"ld-aarch64/func sym hash opt for exe"
    "-e0 --hash-style=gnu tmpdir/func-in-so.so" "" ""
     {func-sym-hash-opt.s} {{readelf --dyn-sym func-sym-hash-opt.d}} "hash-opt"}
-  {"Build bti-plt-so for PLT tests" "-shared" "" "" {bti-plt-so.s}
-    {} "libbti-plt-so.so"}
 }
 
 set aarch64elfcclinktests [list \
@@ -448,26 +405,9 @@ if [check_shared_lib_support] {
     run_cc_link_tests $aarch64elfcclinktests
 }
 
-run_dump_test "bti-plt-3"
-run_dump_test "bti-plt-4"
-run_dump_test "bti-plt-5"
-run_dump_test "bti-plt-6"
-run_dump_test "bti-plt-7"
-
-run_dump_test "pac-plt-1"
-run_dump_test "pac-plt-2"
-run_dump_test "bti-pac-plt-1"
-run_dump_test "bti-pac-plt-2"
-
-run_dump_test "bti-warn"
 run_dump_test "weak-tls"
 run_dump_test "undef-tls"
 
-run_dump_test_lp64 "bti-far-1"
-run_dump_test_lp64 "bti-far-2"
-run_dump_test_lp64 "bti-far-opt"
-run_dump_test_lp64 "bti-far-3"
-
 if { [supports_dt_relr] } {
   run_dump_test_lp64 "relr-align"
   run_dump_test_lp64 "relr-data-pie"
diff --git a/ld/testsuite/ld-aarch64/lib/aarch64-elf-lib.exp b/ld/testsuite/ld-aarch64/lib/aarch64-elf-lib.exp
new file mode 100644 (file)
index 0000000..4023da3
--- /dev/null
@@ -0,0 +1,59 @@
+# Expect library used by AArch64 ELF test scripts.
+# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# Exclude non-aarch64-ELF targets.
+if { ![is_elf_format] || ![istarget "aarch64*-*-*"] } {
+  return
+}
+
+proc aarch64_choose_ilp32_emul {} {
+  if [istarget *linux*] then {
+    if [istarget aarch64_be-*] {
+      return "aarch64linux32b"
+    }
+    return "aarch64linux32"
+  }
+  if [istarget aarch64_be-*] {
+    return "aarch64elf32b"
+  }
+  return "aarch64elf32"
+}
+
+proc aarch64_choose_lp64_emul {} {
+  if [istarget *linux*] then {
+    if [istarget aarch64_be-*] {
+      return "aarch64linuxb"
+    }
+    return "aarch64linux"
+  }
+  if [istarget *nto*] then {
+    return "aarch64nto"
+  }
+  if [istarget aarch64_be-*] {
+    return "aarch64elfb"
+  }
+  return "aarch64elf"
+}
+
+proc run_dump_test_lp64 { testname } {
+  run_dump_test $testname \
+    [list [list as "-mabi=lp64"] \
+         [list ld [concat "-m " [aarch64_choose_lp64_emul]]]]
+}
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp b/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
new file mode 100644 (file)
index 0000000..803405e
--- /dev/null
@@ -0,0 +1,59 @@
+# Expect script for AARCH64 ELF tests related to GNU properties.
+# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# Exclude non-aarch64-ELF targets.
+if { ![is_elf_format] || ![istarget "aarch64*-*-*"] } {
+  return
+}
+
+load_lib $srcdir/$subdir/../lib/aarch64-elf-lib.exp
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+set test_lp64_list [lsort [glob -nocomplain $srcdir/$subdir/bti-far-*.d]]
+
+# Remove lp64 tests from test_list to avoid executing them twice.
+foreach test_lp64 $test_lp64_list {
+  set idx [lsearch $test_list $test_lp64]
+  set test_list [lreplace $test_list $idx $idx]
+  unset idx
+}
+
+# See definition of run_ld_link_tests in testsuite/lib/ld-lib.exp for more
+# details.
+set aarch64elflinktests {
+  {"Build bti-plt-so for PLT tests"
+   "-shared" ""
+   ""
+   {bti-plt-so.s} {} "libbti-plt-so.so"}
+}
+
+if [check_shared_lib_support] {
+  run_ld_link_tests $aarch64elflinktests
+}
+
+foreach t $test_lp64_list {
+  # We need to strip the ".d", but can leave the dirname.
+  run_dump_test_lp64 [file rootname $t]
+}
+
+foreach t $test_list {
+  # We need to strip the ".d", but can leave the dirname.
+  run_dump_test [file rootname $t]
+}
\ No newline at end of file
similarity index 94%
rename from ld/testsuite/ld-aarch64/bti-plt-7.d
rename to ld/testsuite/ld-aarch64/protections/bti-plt-7.d
index 4d232902437b53526ceea04fe4dd6e2b37a021f5..6384b861e71dcbbed6cf5bf17d101b42bbea65b7 100644 (file)
@@ -1,6 +1,6 @@
 #name: Warn when neither inputs has GNU NOTE BTI
 #source: property-bti-pac2.s
-#source: plt_mapping_symbol.s
+#source: ../plt_mapping_symbol.s
 #target: [check_shared_lib_support]
 #as: -mabi=lp64
 #ld: -shared -z force-bti
similarity index 95%
rename from ld/testsuite/ld-aarch64/pac-plt-2.d
rename to ld/testsuite/ld-aarch64/protections/pac-plt-2.d
index 611bf8bd506f359c243a5bacbafb1e16f153b6f6..f0d2710e82b99cee74441d36a3ebb398b6f849ea 100644 (file)
@@ -1,4 +1,4 @@
-#source: tls-desc-ie.s
+#source: ../tls-desc-ie.s
 #target: [check_shared_lib_support]
 #ld: -shared -z pac-plt -T bti-plt.ld
 #objdump: -dr -j .plt