[binutils-gdb] arm testsuite: add two corner cases for EABI string attributes
Matthieu Longo
mlongo@sourceware.org
Wed Jun 25 08:41:53 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c35217309a9753e1a5666626f779bfd71668de9d
commit c35217309a9753e1a5666626f779bfd71668de9d
Author: Matthieu Longo <matthieu.longo@arm.com>
Date: Fri Jun 20 12:24:58 2025 +0100
arm testsuite: add two corner cases for EABI string attributes
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.
Diff:
---
gas/testsuite/gas/arm/attr-empty-string.d | 11 +++++++++++
gas/testsuite/gas/arm/attr-empty-string.s | 14 ++++++++++++++
gas/testsuite/gas/arm/attr-non-null-terminated-string.d | 9 +++++++++
gas/testsuite/gas/arm/attr-non-null-terminated-string.s | 14 ++++++++++++++
4 files changed, 48 insertions(+)
diff --git a/gas/testsuite/gas/arm/attr-empty-string.d b/gas/testsuite/gas/arm/attr-empty-string.d
new file mode 100644
index 00000000000..3c6560c80a8
--- /dev/null
+++ b/gas/testsuite/gas/arm/attr-empty-string.d
@@ -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
index 00000000000..f8ed373733b
--- /dev/null
+++ b/gas/testsuite/gas/arm/attr-empty-string.s
@@ -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
index 00000000000..d079d14903e
--- /dev/null
+++ b/gas/testsuite/gas/arm/attr-non-null-terminated-string.d
@@ -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
index 00000000000..f886f390a86
--- /dev/null
+++ b/gas/testsuite/gas/arm/attr-non-null-terminated-string.s
@@ -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:
More information about the Binutils-cvs
mailing list