These tests are a copy-paste of the generic tests for AArch64.
Test cases:
- only one input object is copied to the output object
- merge two inputs with optional subsections of both types
ULEB128 and NTBS, which contains same, additional, and
missing attributes.
- mismatch subsection properties.
- combine matching required subsections.
- combine non-matching required subsections.
- prune unknown attributes in known subsections.
- prune unknown subsections.
--- /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.
+
+#
+# Generic tests for GNU attributes v2
+#
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+
+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
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 0
+
+ .gnu_subsection gnu_testing_ba_2_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 0
+ .gnu_attribute 1, 1
+
+ .gnu_subsection gnu_testing_ba_3_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "hello"
+ .gnu_attribute 1, "world"
+
+ .gnu_subsection gnu_testing_ba_5_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "hello"
+ .gnu_attribute 1, "world"
--- /dev/null
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+
+ .gnu_subsection gnu_testing_ba_2_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+
+ .gnu_subsection gnu_testing_ba_4_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "foo"
+ .gnu_attribute 1, "bar"
+
+ .gnu_subsection gnu_testing_ba_5_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "foo"
+ .gnu_attribute 1, "bar"
--- /dev/null
+# name: Object Attributes v2: mismatch subsection properties with oav2-1-all-optional-1
+# target: [supports_oa_v2]
+# source: oav2-1-all-optional-1.s
+# source: oav2-1-mismatch-subsec-props-with-all-optional-1.s
+# ld: -shared
+#error: \A[^\n]*oav2-1-mismatch-subsec-props-with-all-optional-1\.o: error: mismatching properties of subsection 'gnu_testing_ba_1_MERGE_AND'
+#error: \n[^\n]*oav2-1-all-optional-1\.o: info: conflicting properties \(optional, .*\) live here
+#error: \ninfo: \(required, .*\) VS \(optional, .*\)
+#error: \n[^\n]*oav2-1-mismatch-subsec-props-with-all-optional-1\.o: error: mismatching properties of subsection 'gnu_testing_ba_2_MERGE_AND'
+#error: \n[^\n]*oav2-1-all-optional-1\.o: info: conflicting properties \(.*, ULEB128\) live here
+#error: \ninfo: \(.*, NTBS\) VS \(.*, ULEB128\)\Z
--- /dev/null
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+ .gnu_subsection gnu_testing_ba_2_MERGE_AND, optional, ntbs
--- /dev/null
+# name: Object Attributes v2: only one input object is copied to the output object
+# target: [supports_oa_v2]
+# source: oav2-1-all-optional-1.s
+# 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: Object Attributes v2: 2 files, all optional, 1 more, 1 missing
+# target: [supports_oa_v2]
+# source: oav2-1-all-optional-1.s
+# source: oav2-1-all-optional-2.s
+# 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
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+ .gnu_attribute 2, 1 // Unknown tag
+ .gnu_attribute 3, 1 // Unknown tag
+
+ .gnu_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "foo"
+ .gnu_attribute 1, "bar"
+ .gnu_attribute 2, "foo2" // Unknown tag
+ .gnu_attribute 3, "foo3" // Unknown tag
--- /dev/null
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+ .gnu_attribute 2, 1 // Unknown tag
+ .gnu_attribute 4, 1 // Unknown tag
+
+ .gnu_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "foo"
+ .gnu_attribute 1, "bar"
+ .gnu_attribute 2, "foo2" // Unknown tag
+ .gnu_attribute 4, "foo4" // Unknown tag
--- /dev/null
+# name: Object Attributes v2: unknown attribute inside known subsection should be removed from the output.
+# target: [supports_oa_v2]
+# source: oav2-2-mix-unknown-and-known-attr-known-subsection-1.s
+# source: oav2-2-mix-unknown-and-known-attr-known-subsection-2.s
+# 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
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 0
+
+ .gnu_subsection private_1, optional, uleb128
+ .gnu_attribute 0, 0
+ .gnu_attribute 1, 1
+
+ .gnu_subsection private_2, optional, ntbs
+ .gnu_attribute 0, "hello"
+ .gnu_attribute 1, "world"
+
+ .gnu_subsection private_4, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+
+ .gnu_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "hello"
+ .gnu_attribute 1, "world"
--- /dev/null
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+
+ .gnu_subsection private_1, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+
+ .gnu_subsection private_2, optional, ntbs
+ .gnu_attribute 0, "foo"
+ .gnu_attribute 1, "bar"
+
+ .gnu_subsection private_3, optional, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
+
+ .gnu_subsection gnu_testing_ba_2_MERGE_ADD, optional, ntbs
+ .gnu_attribute 0, "foo"
+ .gnu_attribute 1, "bar"
--- /dev/null
+# name: Object Attributes v2: unknown subsections are removed from the output.
+# target: [supports_oa_v2]
+# source: oav2-2-mix-unknown-and-known-subsections-1.s
+# source: oav2-2-mix-unknown-and-known-subsections-2.s
+# 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
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 0
--- /dev/null
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 0
--- /dev/null
+ .gnu_subsection gnu_testing_ba_1_MERGE_AND, required, uleb128
+ .gnu_attribute 0, 1
+ .gnu_attribute 1, 1
--- /dev/null
+# name: Object Attributes v2: combine non-matching required subsections
+# target: [supports_oa_v2]
+# source: oav2-2-required-subsec-A-1.s
+# source: oav2-2-required-subsec-B.s
+# source: oav2-2-required-subsec-A-2.s
+# ld: -shared
+#error: \A[^\n]*oav2-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]*oav2-2-required-subsec-A-1\.o: info: conflicting value '0' lives here\Z
--- /dev/null
+# name: Object Attributes v2: combine matching required subsections
+# target: [supports_oa_v2]
+# source: oav2-2-required-subsec-A-1.s
+# source: oav2-2-required-subsec-A-2.s
+# 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 .*