aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Longo <matthieu.longo@arm.com>2025-06-20 12:24:58 +0100
committerMatthieu Longo <matthieu.longo@arm.com>2025-06-25 09:41:04 +0100
commitc35217309a9753e1a5666626f779bfd71668de9d (patch)
tree300e4f45aeb2256be259cff71f3d20ffb1508137
parent5d721846dc366dff149b83776a5584a2b7f1243f (diff)
downloadbinutils-c35217309a9753e1a5666626f779bfd71668de9d.zip
binutils-c35217309a9753e1a5666626f779bfd71668de9d.tar.gz
binutils-c35217309a9753e1a5666626f779bfd71668de9d.tar.bz2
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.
-rw-r--r--gas/testsuite/gas/arm/attr-empty-string.d11
-rw-r--r--gas/testsuite/gas/arm/attr-empty-string.s14
-rw-r--r--gas/testsuite/gas/arm/attr-non-null-terminated-string.d9
-rw-r--r--gas/testsuite/gas/arm/attr-non-null-terminated-string.s14
4 files changed, 48 insertions, 0 deletions
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 0000000..3c6560c
--- /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 0000000..f8ed373
--- /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 0000000..d079d14
--- /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 0000000..f886f39
--- /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: