]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
arm testsuite: add two corner cases for EABI string attributes
authorMatthieu Longo <matthieu.longo@arm.com>
Fri, 20 Jun 2025 11:24:58 +0000 (12:24 +0100)
committerMatthieu Longo <matthieu.longo@arm.com>
Wed, 25 Jun 2025 08:41:04 +0000 (09:41 +0100)
The current testsuite for gas/readelf lacked two tests for EABI build
attributes:
- one when the final attribute is an empty string.
- one when the final attribute is a string missing the NULL terminator.

Those two issues cannot occur with Object Attributes v1 (OAv1) sections
created by the GNU binutils. Indeed a value of '\0' (empty string) for a
tag with a string value is considered as the default value for the
attribute, and consequently is eliminated by Gas from the output object
file during the serialization.
However, readelf should be able to process correctly files of an unknown
origin that could contain those two use cases.

This patch adds the two tests mentioned above. The first one is marked
as XFAIL because the empty string is not processed correctly by readelf
when it is in the last position. The second one passes, but simply print
out "[...]" without mentioning that the NTBS is corrupted.

A following patch will fix the bug in readelf, and will amend the newly
introduced tests.

gas/testsuite/gas/arm/attr-empty-string.d [new file with mode: 0644]
gas/testsuite/gas/arm/attr-empty-string.s [new file with mode: 0644]
gas/testsuite/gas/arm/attr-non-null-terminated-string.d [new file with mode: 0644]
gas/testsuite/gas/arm/attr-non-null-terminated-string.s [new file with mode: 0644]

diff --git a/gas/testsuite/gas/arm/attr-empty-string.d b/gas/testsuite/gas/arm/attr-empty-string.d
new file mode 100644 (file)
index 0000000..3c6560c
--- /dev/null
@@ -0,0 +1,11 @@
+# name: EABI attribute - empy string
+# source: attr-empty-string.s
+# as:
+# readelf: -T -A
+# This test is only valid on EABI based ports.
+# target: *-*-*eabi* *-*-nacl*
+# xfail: *
+
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_raw_name: ""
diff --git a/gas/testsuite/gas/arm/attr-empty-string.s b/gas/testsuite/gas/arm/attr-empty-string.s
new file mode 100644 (file)
index 0000000..f8ed373
--- /dev/null
@@ -0,0 +1,14 @@
+       .section .XXX.attributes, "", %0x70000003
+       # Format version
+       .byte 'A'
+       # Size
+       .4byte (.Lend_attrs - .)
+       # "Vendor"
+       .asciz "aeabi"
+       # File scope
+       .byte 1
+       # Size
+       .4byte (.Lend_attrs - . + 1)
+       .uleb128 4
+       .asciz ""
+.Lend_attrs:
diff --git a/gas/testsuite/gas/arm/attr-non-null-terminated-string.d b/gas/testsuite/gas/arm/attr-non-null-terminated-string.d
new file mode 100644 (file)
index 0000000..d079d14
--- /dev/null
@@ -0,0 +1,9 @@
+# name: EABI attribute - non-null terminated string
+# source: attr-non-null-terminated-string.s
+# This test is only valid on EABI based ports.
+# target: *-*-*eabi* *-*-nacl*
+# as:
+# readelf: --silent-truncation -A
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_raw_name: "ab"
diff --git a/gas/testsuite/gas/arm/attr-non-null-terminated-string.s b/gas/testsuite/gas/arm/attr-non-null-terminated-string.s
new file mode 100644 (file)
index 0000000..f886f39
--- /dev/null
@@ -0,0 +1,14 @@
+       .section .XXX.attributes, "", %0x70000003
+       # Format version
+       .byte 'A'
+       # Size
+       .4byte (.Lend_attrs - .)
+       # "Vendor"
+       .asciz "aeabi"
+       # File scope
+       .byte 1
+       # Size
+       .4byte (.Lend_attrs - . + 1)
+       .uleb128 4
+       .byte 'a', 'b', 'c'
+.Lend_attrs: