--- /dev/null
+# Expect script for AARCH64 ELF tests related to GNU properties.
+# Copyright (C) 2025 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_file $srcdir/$subdir/../lib/aarch64-elf-lib.exp
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+
+# 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" ""
+# "-I$srcdir/$subdir -defsym __property_bti__=1"
+# {bti-plt-so.s} {} "libbti-plt-so.so"}
+# }
+
+# if [check_shared_lib_support] {
+# run_ld_link_tests $aarch64elflinktests
+# }
+
+foreach t $test_list {
+ # We need to strip the ".d", but can leave the dirname.
+ run_dump_test [file rootname $t] \
+ [list [list as "-I\$srcdir/\$subdir"]]
+}
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 0
+
+.aeabi_subsection gnu_testing_ba_2_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 0
+.aeabi_attribute 1, 1
+
+.aeabi_subsection gnu_testing_ba_3_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "hello"
+.aeabi_attribute 1, "world"
+
+.aeabi_subsection gnu_testing_ba_5_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "hello"
+.aeabi_attribute 1, "world"
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+
+.aeabi_subsection gnu_testing_ba_2_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+
+.aeabi_subsection gnu_testing_ba_4_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "foo"
+.aeabi_attribute 1, "bar"
+
+.aeabi_subsection gnu_testing_ba_5_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "foo"
+.aeabi_attribute 1, "bar"
--- /dev/null
+# name: Build attributes: mismatch subsection properties with ba-1-all-optional-1
+# source: ba-1-all-optional-1.s
+# source: ba-1-mismatch-subsec-props-with-all-optional-1.s
+# as:
+# ld: -shared
+#error: \A[^\n]*ba-1-mismatch-subsec-props-with-all-optional-1\.o: error: mismatching properties of subsection 'gnu_testing_ba_1_MERGE_AND'
+#error: \n[^\n]*ba-1-all-optional-1\.o: info: conflicting properties \(optional, .*\) live here
+#error: \ninfo: \(required, .*\) VS \(optional, .*\)
+#error: \n[^\n]*ba-1-mismatch-subsec-props-with-all-optional-1\.o: error: mismatching properties of subsection 'gnu_testing_ba_2_MERGE_AND'
+#error: \n[^\n]*ba-1-all-optional-1\.o: info: conflicting properties \(.*, ULEB128\) live here
+#error: \ninfo: \(.*, NTBS\) VS \(.*, ULEB128\)\Z
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+.aeabi_subsection gnu_testing_ba_2_MERGE_AND, optional, ntbs
--- /dev/null
+# name: Build attributes: only one input object is copied to the output object
+# source: ba-1-all-optional-1.s
+# as:
+# ld: -shared
+# readelf: --arch-specific
+
+Subsections:
+ - Name:[ ]+gnu_testing_ba_1_MERGE_AND
+ Scope:[ ]+private
+ Length:[ ]+37
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+1 .*
+ +Tag_unknown_1:[ ]+0 .*
+
+ - Name:[ ]+gnu_testing_ba_2_MERGE_AND
+ Scope:[ ]+private
+ Length:[ ]+37
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+0 .*
+ +Tag_unknown_1:[ ]+1 .*
+
+ - Name:[ ]+gnu_testing_ba_3_MERGE_ADD
+ Scope:[ ]+private
+ Length:[ ]+47
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_0:[ ]+"hello"
+ +Tag_unknown_1:[ ]+"world"
+
+ - Name:[ ]+gnu_testing_ba_5_MERGE_ADD
+ Scope:[ ]+private
+ Length:[ ]+47
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_0:[ ]+"hello"
+ +Tag_unknown_1:[ ]+"world"
--- /dev/null
+# name: Build attributes: 2 files, all optional, 1 more, 1 missing
+# source: ba-1-all-optional-1.s
+# source: ba-1-all-optional-2.s
+# as:
+# ld: -shared
+# readelf: --arch-specific
+
+Subsections:
+ - Name:[ ]+gnu_testing_ba_1_MERGE_AND
+ Scope:[ ]+private
+ Length:[ ]+37
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+1 .*
+ +Tag_unknown_1:[ ]+0 .*
+
+ - Name:[ ]+gnu_testing_ba_2_MERGE_AND
+ Scope:[ ]+private
+ Length:[ ]+37
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+0 .*
+ +Tag_unknown_1:[ ]+1 .*
+
+ - Name:[ ]+gnu_testing_ba_3_MERGE_ADD
+ Scope:[ ]+private
+ Length:[ ]+47
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_0:[ ]+"hello"
+ +Tag_unknown_1:[ ]+"world"
+
+ - Name:[ ]+gnu_testing_ba_4_MERGE_ADD
+ Scope:[ ]+private
+ Length:[ ]+43
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_0:[ ]+"foo"
+ +Tag_unknown_1:[ ]+"bar"
+
+ - Name:[ ]+gnu_testing_ba_5_MERGE_ADD
+ Scope:[ ]+private
+ Length:[ ]+55
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_0:[ ]+"hello\+foo"
+ +Tag_unknown_1:[ ]+"world\+bar"
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+.aeabi_attribute 2, 1 // Unknown tag
+.aeabi_attribute 3, 1 // Unknown tag
+
+.aeabi_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "foo"
+.aeabi_attribute 1, "bar"
+.aeabi_attribute 2, "foo2" // Unknown tag
+.aeabi_attribute 3, "foo3" // Unknown tag
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+.aeabi_attribute 2, 1 // Unknown tag
+.aeabi_attribute 4, 1 // Unknown tag
+
+.aeabi_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "foo"
+.aeabi_attribute 1, "bar"
+.aeabi_attribute 2, "foo2" // Unknown tag
+.aeabi_attribute 4, "foo4" // Unknown tag
--- /dev/null
+# name: Build attributes: unknown attribute inside known subsection should be removed from the output.
+# source: ba-2-mix-unknown-and-known-attr-known-subsection-1.s
+# source: ba-2-mix-unknown-and-known-attr-known-subsection-2.s
+# as:
+# ld: -shared
+# readelf: --arch-specific
+
+Subsections:
+ - Name:[ ]+gnu_testing_ba_1_MERGE_AND
+ Scope:[ ]+private
+ Length:[ ]+37
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+1 .*
+ +Tag_unknown_1:[ ]+1 .*
+
+ - Name:[ ]+gnu_testing_ba_2_MERGE_ADD
+ Scope:[ ]+private
+ Length:[ ]+51
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_0:[ ]+"foo\+foo"
+ +Tag_unknown_1:[ ]+"bar\+bar"
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 0
+
+.aeabi_subsection private_1, optional, uleb128
+.aeabi_attribute 0, 0
+.aeabi_attribute 1, 1
+
+.aeabi_subsection private_2, optional, ntbs
+.aeabi_attribute 0, "hello"
+.aeabi_attribute 1, "world"
+
+.aeabi_subsection private_4, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+
+.aeabi_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "hello"
+.aeabi_attribute 1, "world"
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+
+.aeabi_subsection private_1, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+
+.aeabi_subsection private_2, optional, ntbs
+.aeabi_attribute 0, "foo"
+.aeabi_attribute 1, "bar"
+
+.aeabi_subsection private_3, optional, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+
+.aeabi_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+.aeabi_attribute 0, "foo"
+.aeabi_attribute 1, "bar"
--- /dev/null
+# name: Build attributes: unknown subsections are removed from the output.
+# source: ba-2-mix-unknown-and-known-subsections-1.s
+# source: ba-2-mix-unknown-and-known-subsections-2.s
+# as:
+# ld: -shared
+# readelf: --arch-specific
+
+Subsections:
+ - Name:[ ]+gnu_testing_ba_1_MERGE_AND
+ Scope:[ ]+private
+ Length:[ ]+37
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+1 .*
+ +Tag_unknown_1:[ ]+0 .*
+
+ - Name:[ ]+gnu_testing_ba_2_MERGE_ADD
+ Scope:[ ]+private
+ Length:[ ]+55
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_0:[ ]+"hello\+foo"
+ +Tag_unknown_1:[ ]+"world\+bar"
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 0
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 0
--- /dev/null
+.aeabi_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
--- /dev/null
+# name: Build attributes: combine non-matching required subsections
+# source: ba-2-required-subsec-A-1.s
+# source: ba-2-required-subsec-B.s
+# source: ba-2-required-subsec-A-2.s
+# as:
+# ld: -shared
+#error: \A[^\n]*ba-2-required-subsec-B\.o: error: mismatching value for required object attribute 'GNUTestTag_1' in subsection 'gnu_testing_ba_1_MERGE_AND': 0x1
+#error: \n[^\n]*ba-2-required-subsec-A-1\.o: info: conflicting value '0' lives here\Z
--- /dev/null
+# name: Build attributes: combine matching required subsections
+# source: ba-2-required-subsec-A-1.s
+# source: ba-2-required-subsec-A-2.s
+# as:
+# ld: -shared
+# readelf: --arch-specific
+
+Subsections:
+ - Name:[ ]+gnu_testing_ba_1_MERGE_AND
+ Scope:[ ]+private
+ Length:[ ]+37
+ Comprehension:[ ]+required
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+1 .*
+ +Tag_unknown_1:[ ]+0 .*
run_dump_test $testname \
[list [list as "-mabi=lp64 -I\$srcdir/\$subdir"] \
[list ld [concat "-m " [aarch64_choose_lp64_emul]]]]
-}
\ No newline at end of file
+}