--- /dev/null
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# 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.
+
+#
+# AArch64 tests for the build attributes
+#
+
+if {[istarget aarch64*-*-*] && [is_elf_format]} {
+ run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+}
--- /dev/null
+# name: EABI build attributes: several subsections into .ARM.attributes
+# source: ba-1.s
+# as:
+# readelf: -A
+
+Subsections:
+ - Name:[ ]+aeabi_feature_and_bits
+ Scope:[ ]+public
+ Length:[ ]+35
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_Feature_BTI:[ ]+1 .*
+ +Tag_Feature_PAC:[ ]+1 .*
+ +Tag_Feature_GCS:[ ]+1 .*
+
+ - Name:[ ]+aeabi_foo_1
+ Scope:[ ]+public
+ Length:[ ]+22
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_2:[ ]+65 .*
+ +Tag_unknown_3:[ ]+1 .*
+
+ - Name:[ ]+aeabi_foo_2
+ Scope:[ ]+public
+ Length:[ ]+27
+ Comprehension:[ ]+required
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_2:[ ]+"TEST2"
+ Tag_unknown_4:[ ]+""
+
+ - Name:[ ]+aeabi_foo_3
+ Scope:[ ]+public
+ Length:[ ]+24
+ Comprehension:[ ]+required
+ Encoding:[ ]+NTBS
+ Values:
+ +Tag_unknown_4:[ ]+"TEST"
+
+ - Name:[ ]+foo_1
+ Scope:[ ]+private
+ Length:[ ]+22
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_0:[ ]+1 .*
+ +Tag_unknown_1:[ ]+1 .*
+ +Tag_unknown_2:[ ]+1 .*
+ +Tag_unknown_3:[ ]+1 .*
+ +Tag_unknown_10:[ ]+2 .*
--- /dev/null
+.set ATTR_TYPE_uleb128, 0
+.set ATTR_TYPE_asciz, 1
+
+.set SUBSEC_required, 0
+.set SUBSEC_optional, 1
+
+.aeabi_subsection foo_1, 1, ATTR_TYPE_uleb128
+
+.set Tag_Feature_foo, 2
+.set Tag_Feature_bar, 3
+
+.aeabi_attribute Tag_Feature_bar, 1
+.aeabi_attribute 0, 1
+.aeabi_attribute 1, 1
+.aeabi_attribute Tag_Feature_foo, 1
+.aeabi_attribute 0xa, (0xff + ~0xfc) // 255 - 253 = 2
+
+.aeabi_subsection aeabi_foo_1, 1, ATTR_TYPE_uleb128
+.aeabi_attribute Tag_Feature_bar, 1
+.aeabi_attribute Tag_Feature_foo, 'A'
+
+.aeabi_subsection aeabi_foo_2, 0, ATTR_TYPE_asciz
+.aeabi_attribute 4, ""
+.aeabi_attribute 2, "TEST2"
+
+.aeabi_subsection aeabi_foo_3, required, ntbs
+.aeabi_attribute 4, "TEST"
+
+.aeabi_subsection aeabi_feature_and_bits, optional, ULEB128
+.aeabi_attribute Tag_Feature_BTI, 1
+.aeabi_attribute Tag_Feature_GCS, 1
+.aeabi_attribute Tag_Feature_PAC, 1
--- /dev/null
+# name: EABI build attributes: error cases
+# source: ba-failures-1.s
+# error_output: ba-failures-1.l
--- /dev/null
+.*: Assembler messages:
+.*: Error: declaration of an attribute outside the scope of an attribute subsection
+.*: Error: attribute '1' cannot be redefined
+.*: Error: unexpected value '-1', expected `unsigned integer' instead
+.*: Error: could not parse attribute tag
+.*: Error: unknown identifier 'Tag_Unknown' in this context
+.*: Error: could not parse attribute tag
+.*: Error: unexpected value '-1', expected `unsigned integer' instead
+.*: Error: could not parse attribute value
+.*: Error: unexpected `string' "foo", expected `unsigned integer' instead
+.*: Error: could not parse attribute value
+.*: Error: unexpected integer '1', expected `string' instead
+.*: Error: could not parse attribute value
+.*: Error: attribute '4' cannot be redefined
+.*: Error: comprehension and encoding of a subsection cannot be omitted on the first declaration
+.*: Error: incompatible redeclaration of subsection vendor_1_subsection_3
+.*: Info: previous declaration had properties: comprehension=required, encoding=NTBS
+.*: Error: incompatible redeclaration of subsection vendor_1_subsection_3
+.*: Info: previous declaration had properties: comprehension=required, encoding=NTBS
+.*: Error: incompatible redeclaration of subsection vendor_1_subsection_3
+.*: Info: previous declaration had properties: comprehension=required, encoding=NTBS
+.*: Error: unknown identifier 'ntbs' in this context
+.*: Error: unknown identifier 'uleb128' in this context
+.*: Error: expression '.vendor' does not resolve to an integer
+.*: Error: fell back to integer literal extraction from expression, but expected `identifier' instead
+.*: Error: expected <subsection_name>, <comprehension>, <encoding>
+.*: Error: unknown identifier 'uleb128' in this context
+.*: Error: unknown identifier 'optial' in this context
+.*: Error: unknown identifier 'ul128' in this context
+.*: Error: invalid value '2', expected values for <comprehension> are 0 \(=`required'\) or 1 \(=`optional'\)
+.*: Error: invalid value '2', expected values for <encoding> are 0 \(=`ULEB128'\) or 1 \(=`NTBS'\)
+.*: Error: syntax error, comma not expected here
+.*: Error: junk at end of line, first unrecognized character is `,'
+.*: Error: syntax error, comma not expected here
+.*: Error: syntax error, comma missing here
+.*: Error: syntax error, comma not expected here
+.*: Error: junk at end of line, first unrecognized character is `,'
+.*: Error: syntax error, comma not expected here
+.*: Error: junk at end of line, first unrecognized character is `1'
+.*: Error: attribute '1' cannot be redefined
--- /dev/null
+.set ATTR_TYPE_uleb128, 0
+.set ATTR_TYPE_asciz, 1
+
+/* The definition of an attribute cannot appear before a subsection was
+ declared. */
+.aeabi_attribute 1, 0
+
+/* aeabi_attribute with the same key should have the same value in the same
+ compilation unit. */
+.aeabi_subsection vendor_1_subsection_1, optional, uleb128
+.aeabi_attribute 1, 0
+.aeabi_attribute 1, 1
+
+/* Only unsigned integer are allowed for attribute keys. */
+.aeabi_attribute -1, 1
+/* Unknown tag identifier. */
+.aeabi_attribute Tag_Unknown, 1
+
+/* Mismatch between the type expected from the subsection definition, and the
+ type provided to the attribute directive. */
+.aeabi_attribute 2, -1
+.aeabi_attribute 3, "foo"
+.aeabi_subsection vendor_1_subsection_2, optional, ntbs
+/* Mismatch between type of the value and the one expected by the subsection. */
+.aeabi_attribute 1, 1
+/* aeabi_attribute with the same key should have the same value in the same
+ compilation unit. */
+.aeabi_attribute 4, "ABC"
+.aeabi_attribute 4, "DEF"
+
+/* The comprehension and encoding cannot be omitted on the first declaration. */
+.aeabi_subsection vendor_1_subsection_3
+
+/* Subsections with the same name should have the same parameters. */
+.aeabi_subsection vendor_1_subsection_3, required, ntbs
+.aeabi_subsection vendor_1_subsection_3, optional, ntbs
+.aeabi_subsection vendor_1_subsection_3, required, uleb128
+.aeabi_subsection vendor_1_subsection_3, optional, uleb128
+
+/* Omitted paramaters have to be omitted in the reverse order. */
+.aeabi_subsection vendor_1_subsection_3, ntbs
+.aeabi_subsection vendor_1_subsection_3, uleb128
+
+/* Invalid subsection name should raise an error. */
+.aeabi_subsection .vendor, optional, uleb128
+
+/* Swap <optional> and <encoding>. */
+.aeabi_subsection vendor_1_subsection_4, uleb128, optional
+
+/* Unknown identifier for <optional>, and <encoding>. */
+.aeabi_subsection vendor_1_subsection_4, optial, uleb128
+.aeabi_subsection vendor_1_subsection_4, optional, ul128
+
+/* Invalid value for optional and format. */
+.aeabi_subsection vendor_1_subsection_4, 2, 1
+.aeabi_subsection vendor_1_subsection_4, 1, 2
+
+/* Wrong comma in the declaration of a subsection. */
+.aeabi_subsection vendor_1_subsection_4, , 1
+.aeabi_subsection vendor_1_subsection_4, 1, 1, 1
+.aeabi_subsection , vendor_1_subsection_4, 1
+.aeabi_subsection vendor_1_subsection_4, 1 1
+
+/* Wrong comma in the declaration of an attribute. */
+.aeabi_attribute 1, , 1
+.aeabi_attribute 1, "dead", 1, 1
+.aeabi_attribute , 1, 1
+.aeabi_attribute 1, "beef" 1
--- /dev/null
+# name: EABI build attributes: correct context switching between interleaved subsections
+# source: ba-interleaved-subsections.s
+# as:
+# readelf: -A
+
+Subsections:
+ - Name:[ ]+aeabi_feature_and_bits
+ Scope:[ ]+public
+ Length:[ ]+35
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_Feature_BTI:[ ]+1 .*
+ +Tag_Feature_PAC:[ ]+0 .*
+ +Tag_Feature_GCS:[ ]+1 .*
+
+ - Name:[ ]+aeabi_pauthabi
+ Scope:[ ]+public
+ Length:[ ]+25
+ Comprehension:[ ]+required
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_PAuth_Platform:[ ]+1 .*
+ +Tag_PAuth_Schema:[ ]+1 .*
+
+ - Name:[ ]+foo_1
+ Scope:[ ]+private
+ Length:[ ]+20
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+ +Tag_unknown_1:[ ]+1 .*
+ +Tag_unknown_2:[ ]+0 .*
+ +Tag_unknown_3:[ ]+0 .*
+ +Tag_unknown_4:[ ]+0 .*
--- /dev/null
+.aeabi_subsection aeabi_pauthabi, required, uleb128
+
+.aeabi_subsection aeabi_feature_and_bits, optional, uleb128
+.aeabi_attribute Tag_Feature_BTI, 1
+
+.aeabi_subsection aeabi_feature_and_bits
+
+.aeabi_subsection foo_1, optional, uleb128
+.aeabi_attribute 1, 1
+
+.aeabi_subsection aeabi_pauthabi
+.aeabi_attribute Tag_PAuth_Schema, 1
+
+.aeabi_subsection aeabi_feature_and_bits
+.aeabi_attribute Tag_Feature_GCS, 1
+
+.aeabi_subsection foo_1
+.aeabi_attribute 2, 0
+
+.aeabi_subsection aeabi_pauthabi
+.aeabi_attribute Tag_PAuth_Platform, 1
+
+.aeabi_subsection aeabi_pauthabi
+.aeabi_subsection aeabi_feature_and_bits
+.aeabi_attribute Tag_Feature_PAC, 0
+
+.aeabi_subsection foo_1
+.aeabi_attribute 3, 0
+.aeabi_attribute 4, 0
+
+.aeabi_subsection aeabi_feature_and_bits
+.aeabi_attribute Tag_Feature_PAC, 0
--- /dev/null
+# name: EABI build attributes: parsing of subsections
+# source: ba-subsection-parsing.s
+# as:
+# readelf: -A
+
+Subsections:
+ - Name:[ ]+foo_01
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+required
+ Encoding:[ ]+ULEB128
+ Values:
+
+ - Name:[ ]+foo_02
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+required
+ Encoding:[ ]+NTBS
+ Values:
+
+ - Name:[ ]+foo_03
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+
+ - Name:[ ]+foo_04
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+
+ - Name:[ ]+foo_05
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+required
+ Encoding:[ ]+ULEB128
+ Values:
+
+ - Name:[ ]+foo_06
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+optional
+ Encoding:[ ]+ULEB128
+ Values:
+
+ - Name:[ ]+foo_07
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
+
+ - Name:[ ]+foo_08
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+required
+ Encoding:[ ]+NTBS
+ Values:
+
+ - Name:[ ]+foo_09
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+required
+ Encoding:[ ]+ULEB128
+ Values:
+
+ - Name:[ ]+foo_10
+ Scope:[ ]+private
+ Length:[ ]+13
+ Comprehension:[ ]+optional
+ Encoding:[ ]+NTBS
+ Values:
--- /dev/null
+.set ATTR_TYPE_uleb128, 0
+.set ATTR_TYPE_asciz, 1
+
+.set SUBSEC_required, 0
+.set SUBSEC_optional, 1
+
+/* Integer literals. */
+.aeabi_subsection foo_01, 0, 0
+.aeabi_subsection foo_02, 0, 1
+.aeabi_subsection foo_03, 1, 0
+.aeabi_subsection foo_04, 1, 1
+
+/* Known identifiers. */
+.aeabi_subsection foo_05, required, uleb128
+.aeabi_subsection foo_06, optional, ULEB128
+.aeabi_subsection foo_07, optional, ntbs
+.aeabi_subsection foo_08, required, NTBS
+
+/* Symbol look-up. */
+.aeabi_subsection foo_09, SUBSEC_required, ATTR_TYPE_uleb128
+.aeabi_subsection foo_10, SUBSEC_optional, ATTR_TYPE_asciz
+
+/* Switch back to the section without specifying the comprehension and
+ encoding. */
+.aeabi_subsection foo_01
+.aeabi_subsection foo_03
+
+/* Switch back to the section without specifying the encoding. */
+.aeabi_subsection foo_01, required
+.aeabi_subsection foo_03, optional
+
+/* Switch back to the section while specifying the comprehension and
+ encoding. */
+.aeabi_subsection foo_01, 0, 0
+.aeabi_subsection foo_02, 0, 1
+.aeabi_subsection foo_01, required, uleb128
+.aeabi_subsection foo_02, required, ntbs