[v0,07/15] gas tests: add new tests for build attributes

Message ID 20250310175131.1217374-8-matthieu.longo@arm.com
State New
Headers
Series AArch64 AEABI build attributes (a.k.a. object attributes v2) |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Matthieu Longo March 10, 2025, 5:51 p.m. UTC
  From: Richard Ball <richard.ball@arm.com>

The added tests cover the parsing of the new assembly directives
(aeabi_subsection and aeabi_attribute), the serialization of the build
attributes data into an object file, and the deserialization of the data
via readelf.

Co-Authored-By: Matthieu Longo <matthieu.longo@arm.com>
---
 .../aarch64-build-attributes.exp              | 23 ++++++
 .../gas/aarch64/build-attributes/ba-1.d       | 51 +++++++++++++
 .../gas/aarch64/build-attributes/ba-1.s       | 30 ++++++++
 .../aarch64/build-attributes/ba-failures-1.d  | 14 ++++
 .../aarch64/build-attributes/ba-failures-1.s  | 28 +++++++
 .../ba-interleaved-subsections.d              | 35 +++++++++
 .../ba-interleaved-subsections.s              | 32 ++++++++
 .../build-attributes/ba-subsection-parsing.d  | 75 +++++++++++++++++++
 .../build-attributes/ba-subsection-parsing.s  | 21 ++++++
 9 files changed, 309 insertions(+)
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/aarch64-build-attributes.exp
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-1.d
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-1.s
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.s
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.d
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.s
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.d
 create mode 100644 gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.s
  

Comments

Jan Beulich March 11, 2025, 8:13 a.m. UTC | #1
On 10.03.2025 18:51, Matthieu Longo wrote:
> --- /dev/null
> +++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
> @@ -0,0 +1,14 @@
> +# name: EABI build attributes: error cases
> +# source: ba-failures-1.s
> +# as:
> +#error: \A[^\n]*\.s: Assembler messages:\n
> +#error: [^\n]*\.s:[0-9]+: Error: A subsection has to be declared before declaring attributes\n
> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 1 cannot be redefined\n
> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 4 cannot be redefined\n
> +#error: [^\n]*\.s:[0-9]+: Error: Invalid token for section name: \.\n
> +#error: [^\n]*\.s:[0-9]+: Error: Expected <subsection_name>, <optional>, <format>\n
> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <optional> are 0 or 1\n
> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <format> are 0 or 1
> \ No newline at end of file

Please can this be taken care of (throughout the series)?

Jan
  
Matthieu Longo March 11, 2025, 11:16 a.m. UTC | #2
On 2025-03-11 08:13, Jan Beulich wrote:
> On 10.03.2025 18:51, Matthieu Longo wrote:
>> --- /dev/null
>> +++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
>> @@ -0,0 +1,14 @@
>> +# name: EABI build attributes: error cases
>> +# source: ba-failures-1.s
>> +# as:
>> +#error: \A[^\n]*\.s: Assembler messages:\n
>> +#error: [^\n]*\.s:[0-9]+: Error: A subsection has to be declared before declaring attributes\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 1 cannot be redefined\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 4 cannot be redefined\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Invalid token for section name: \.\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Expected <subsection_name>, <optional>, <format>\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <optional> are 0 or 1\n
>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <format> are 0 or 1
>> \ No newline at end of file
> 
> Please can this be taken care of (throughout the series)?
> 
> Jan

Hi Jan,

What do you mean by "being taken care of (throughout the series)" ?

Regards,
Matthieu.
  
Jan Beulich March 11, 2025, 12:06 p.m. UTC | #3
On 11.03.2025 12:16, Matthieu Longo wrote:
> On 2025-03-11 08:13, Jan Beulich wrote:
>> On 10.03.2025 18:51, Matthieu Longo wrote:
>>> --- /dev/null
>>> +++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
>>> @@ -0,0 +1,14 @@
>>> +# name: EABI build attributes: error cases
>>> +# source: ba-failures-1.s
>>> +# as:
>>> +#error: \A[^\n]*\.s: Assembler messages:\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: A subsection has to be declared before declaring attributes\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 1 cannot be redefined\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 4 cannot be redefined\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Invalid token for section name: \.\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected <subsection_name>, <optional>, <format>\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <optional> are 0 or 1\n
>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <format> are 0 or 1
>>> \ No newline at end of file
>>
>> Please can this be taken care of (throughout the series)?
> 
> What do you mean by "being taken care of (throughout the series)" ?

Hmm, odd - I don't see what's unclear about my request, taking the
context into account. I'm asking that - throughout the series - you
make sure you don't introduce any file lacking a trailing newline.

Jan
  
Richard Earnshaw March 19, 2025, 11:19 a.m. UTC | #4
On 11/03/2025 12:06, Jan Beulich wrote:
> On 11.03.2025 12:16, Matthieu Longo wrote:
>> On 2025-03-11 08:13, Jan Beulich wrote:
>>> On 10.03.2025 18:51, Matthieu Longo wrote:
>>>> --- /dev/null
>>>> +++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
>>>> @@ -0,0 +1,14 @@
>>>> +# name: EABI build attributes: error cases
>>>> +# source: ba-failures-1.s
>>>> +# as:
>>>> +#error: \A[^\n]*\.s: Assembler messages:\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: A subsection has to be declared before declaring attributes\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 1 cannot be redefined\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 4 cannot be redefined\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Invalid token for section name: \.\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected <subsection_name>, <optional>, <format>\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <optional> are 0 or 1\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <format> are 0 or 1
>>>> \ No newline at end of file
>>>
>>> Please can this be taken care of (throughout the series)?
>>
>> What do you mean by "being taken care of (throughout the series)" ?
> 
> Hmm, odd - I don't see what's unclear about my request, taking the
> context into account. I'm asking that - throughout the series - you
> make sure you don't introduce any file lacking a trailing newline.
> 
> Jan

I must admit that I didn't immediately grasp what you were asking for 
either.  If you'd trimmed the other lines from the test, so that it read

--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
@@ -0,0 +1,14 @@<diff header>
[...]
\ No newline at end of file

Then the comment would have been unambiguous.  As it was, you could be 
commenting on almost anything in that hunk.

R
  
Matthieu Longo March 20, 2025, 3:09 p.m. UTC | #5
On 2025-03-11 12:06, Jan Beulich wrote:
> On 11.03.2025 12:16, Matthieu Longo wrote:
>> On 2025-03-11 08:13, Jan Beulich wrote:
>>> On 10.03.2025 18:51, Matthieu Longo wrote:
>>>> --- /dev/null
>>>> +++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
>>>> @@ -0,0 +1,14 @@
>>>> +# name: EABI build attributes: error cases
>>>> +# source: ba-failures-1.s
>>>> +# as:
>>>> +#error: \A[^\n]*\.s: Assembler messages:\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: A subsection has to be declared before declaring attributes\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 1 cannot be redefined\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Attribute 4 cannot be redefined\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Invalid token for section name: \.\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected <subsection_name>, <optional>, <format>\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <optional> are 0 or 1\n
>>>> +#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <format> are 0 or 1
>>>> \ No newline at end of file
>>>
>>> Please can this be taken care of (throughout the series)?
>>
>> What do you mean by "being taken care of (throughout the series)" ?
> 
> Hmm, odd - I don't see what's unclear about my request, taking the
> context into account. I'm asking that - throughout the series - you
> make sure you don't introduce any file lacking a trailing newline.
> 
> Jan

Fixed.
  

Patch

diff --git a/gas/testsuite/gas/aarch64/build-attributes/aarch64-build-attributes.exp b/gas/testsuite/gas/aarch64/build-attributes/aarch64-build-attributes.exp
new file mode 100644
index 00000000000..7d8269d6b0f
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/aarch64-build-attributes.exp
@@ -0,0 +1,23 @@ 
+# 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*-*-*]} {
+    run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+}
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-1.d b/gas/testsuite/gas/aarch64/build-attributes/ba-1.d
new file mode 100644
index 00000000000..3c1d43096e4
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-1.d
@@ -0,0 +1,51 @@ 
+# name: EABI build attributes: several subsections into .ARM.attributes
+# source: ba-1.s
+# as:
+# readelf: -A
+
+Subsections:
+ - Name:	aeabi_foo_1
+   Scope:	public
+   Length:	20
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+    Tag_unknown_3:	1 \(0x1\)
+
+ - Name:	aeabi_foo_2
+   Scope:	public
+   Length:	31
+   Optional:	False
+   Encoding:	asciz
+   Values:
+    Tag_unknown_2:	"TEST2"
+    Tag_unknown_4:	"TEST"
+
+ - Name:	aeabi_foo_3
+   Scope:	public
+   Length:	24
+   Optional:	False
+   Encoding:	asciz
+   Values:
+    Tag_unknown_4:	"TEST"
+
+ - Name:	aeabi_foo_4
+   Scope:	public
+   Length:	24
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+    Tag_unknown_0:	1 \(0x1\)
+    Tag_unknown_1:	1 \(0x1\)
+    Tag_unknown_2:	1 \(0x1\)
+
+ - Name:	foo_1
+   Scope:	private
+   Length:	20
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+    Tag_unknown_0:	1 \(0x1\)
+    Tag_unknown_1:	1 \(0x1\)
+    Tag_unknown_2:	1 \(0x1\)
+    Tag_unknown_3:	1 \(0x1\)
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-1.s b/gas/testsuite/gas/aarch64/build-attributes/ba-1.s
new file mode 100644
index 00000000000..4bc27c008f3
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-1.s
@@ -0,0 +1,30 @@ 
+.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_subsection aeabi_foo_1, 1, ATTR_TYPE_uleb128
+.aeabi_attribute  Tag_Feature_bar, 1
+
+.aeabi_subsection aeabi_foo_2, 0, ATTR_TYPE_asciz
+.aeabi_attribute  4, "TEST"
+.aeabi_attribute  2, "TEST2"
+
+.aeabi_subsection aeabi_foo_3, required, ntbs
+.aeabi_attribute  4, "TEST"
+
+.aeabi_subsection aeabi_foo_4, optional, ULEB128
+.aeabi_attribute  Tag_Feature_BTI, 1
+.aeabi_attribute  Tag_Feature_GCS, 1
+.aeabi_attribute  Tag_Feature_PAC, 1
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
new file mode 100644
index 00000000000..f732ad5a560
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.d
@@ -0,0 +1,14 @@ 
+# name: EABI build attributes: error cases
+# source: ba-failures-1.s
+# as:
+#error: \A[^\n]*\.s: Assembler messages:\n
+#error: [^\n]*\.s:[0-9]+: Error: A subsection has to be declared before declaring attributes\n
+#error: [^\n]*\.s:[0-9]+: Error: Attribute 1 cannot be redefined\n
+#error: [^\n]*\.s:[0-9]+: Error: Attribute 4 cannot be redefined\n
+#error: [^\n]*\.s:[0-9]+: Error: Invalid token for section name: \.\n
+#error: [^\n]*\.s:[0-9]+: Error: Expected <subsection_name>, <optional>, <format>\n
+#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
+#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
+#error: [^\n]*\.s:[0-9]+: Error: Recalled subsections must have the same parameters\n
+#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <optional> are 0 or 1\n
+#error: [^\n]*\.s:[0-9]+: Error: Expected subsection values for <format> are 0 or 1
\ No newline at end of file
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.s b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.s
new file mode 100644
index 00000000000..9b86d25cb74
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-failures-1.s
@@ -0,0 +1,28 @@ 
+.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
+
+.aeabi_subsection vendor_1_subsection_2, optional, ntbs
+.aeabi_attribute  4, "ABC"
+.aeabi_attribute  4, "DEF"
+
+/* Invalid subsection name should raise an error.  */
+.aeabi_subsection .vendor, optional, uleb128
+
+/* 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
+
+/* Wrong values for optional and format.  */
+.aeabi_subsection vendor_1_subsection_4, 2, 2
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.d b/gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.d
new file mode 100644
index 00000000000..32bc8f06c5c
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.d
@@ -0,0 +1,35 @@ 
+# 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
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+    Tag_Feature_BTI:	1 \(0x1\)
+    Tag_Feature_PAC:	0 \(0x0\)
+    Tag_Feature_GCS:	1 \(0x1\)
+
+ - Name:	aeabi_pauthabi
+   Scope:	public
+   Length:	25
+   Optional:	False
+   Encoding:	ULEB128
+   Values:
+    Tag_PAuth_Platform:	1 \(0x1\)
+    Tag_PAuth_Schema:	1 \(0x1\)
+
+ - Name:	foo_1
+   Scope:	private
+   Length:	20
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+    Tag_unknown_1:	1 \(0x1\)
+    Tag_unknown_2:	0 \(0x0\)
+    Tag_unknown_3:	0 \(0x0\)
+    Tag_unknown_4:	0 \(0x0\)
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.s b/gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.s
new file mode 100644
index 00000000000..bb884bb1368
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-interleaved-subsections.s
@@ -0,0 +1,32 @@ 
+.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, optional, uleb128
+
+.aeabi_subsection foo_1, optional, uleb128
+.aeabi_attribute 1, 1
+
+.aeabi_subsection aeabi_pauthabi, required, uleb128
+.aeabi_attribute Tag_PAuth_Schema, 1
+
+.aeabi_subsection aeabi_feature_and_bits, optional, uleb128
+.aeabi_attribute Tag_Feature_GCS, 1
+
+.aeabi_subsection foo_1, optional, uleb128
+.aeabi_attribute 2, 0
+
+.aeabi_subsection aeabi_pauthabi, required, uleb128
+.aeabi_attribute Tag_PAuth_Platform, 1
+
+.aeabi_subsection aeabi_pauthabi, required, uleb128
+.aeabi_subsection aeabi_feature_and_bits, optional, uleb128
+.aeabi_attribute Tag_Feature_PAC, 0
+
+.aeabi_subsection foo_1, optional, uleb128
+.aeabi_attribute 3, 0
+.aeabi_attribute 4, 0
+
+.aeabi_subsection aeabi_feature_and_bits, optional, uleb128
+.aeabi_attribute Tag_Feature_PAC, 0
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.d b/gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.d
new file mode 100644
index 00000000000..38af4d5fd12
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.d
@@ -0,0 +1,75 @@ 
+# name: EABI build attributes: parsing of subsections
+# source: ba-subsection-parsing.s
+# as:
+# readelf: -A
+
+Subsections:
+ - Name:	foo_01
+   Scope:	private
+   Length:	13
+   Optional:	False
+   Encoding:	ULEB128
+   Values:
+
+ - Name:	foo_02
+   Scope:	private
+   Length:	13
+   Optional:	False
+   Encoding:	asciz
+   Values:
+
+ - Name:	foo_03
+   Scope:	private
+   Length:	13
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+
+ - Name:	foo_04
+   Scope:	private
+   Length:	13
+   Optional:	True
+   Encoding:	asciz
+   Values:
+
+ - Name:	foo_05
+   Scope:	private
+   Length:	13
+   Optional:	False
+   Encoding:	ULEB128
+   Values:
+
+ - Name:	foo_06
+   Scope:	private
+   Length:	13
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+
+ - Name:	foo_07
+   Scope:	private
+   Length:	13
+   Optional:	True
+   Encoding:	asciz
+   Values:
+
+ - Name:	foo_08
+   Scope:	private
+   Length:	13
+   Optional:	False
+   Encoding:	asciz
+   Values:
+
+ - Name:	foo_09
+   Scope:	private
+   Length:	13
+   Optional:	False
+   Encoding:	ULEB128
+   Values:
+
+ - Name:	foo_10
+   Scope:	private
+   Length:	13
+   Optional:	True
+   Encoding:	asciz
+   Values:
diff --git a/gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.s b/gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.s
new file mode 100644
index 00000000000..5b6ed4eb1b2
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/build-attributes/ba-subsection-parsing.s
@@ -0,0 +1,21 @@ 
+.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