[PATCH v3 25/26] gnu directives: bfd: generic tests for objcopy of gnu attributes v2

Matthieu Longo matthieu.longo@arm.com
Fri May 9 15:13:15 GMT 2025


---
 binutils/testsuite/binutils-all/objcopy.exp   |  1 +
 .../testsuite/binutils-all/object-attr-v2.d   | 53 +++++++++++++++++++
 .../testsuite/binutils-all/object-attr-v2.s   | 31 +++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 binutils/testsuite/binutils-all/object-attr-v2.d
 create mode 100644 binutils/testsuite/binutils-all/object-attr-v2.s

diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index cf94570642c..f8b5b584e72 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1247,6 +1247,7 @@ if [is_elf_format] {
 	run_dump_test "note-6-32"
     }
     run_dump_test "note-5"
+    run_dump_test "object-attr-v2"
 }
 
 run_dump_test "copy-2"
diff --git a/binutils/testsuite/binutils-all/object-attr-v2.d b/binutils/testsuite/binutils-all/object-attr-v2.d
new file mode 100644
index 00000000000..7bb951e21ba
--- /dev/null
+++ b/binutils/testsuite/binutils-all/object-attr-v2.d
@@ -0,0 +1,53 @@
+#name: Copy object attributes v2 data from an object to another.
+#PROG: objcopy
+#target: [supports_oa_v2]
+#source: object-attr-v2.s
+#readelf: -A
+
+Subsections:
+ - 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\)
+
+ - Name:	foo_2
+   Scope:	private
+   Length:	16
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+    Tag_unknown_0:	1 \(0x1\)
+    Tag_unknown_1:	1 \(0x1\)
+
+ - Name:	foo_3
+   Scope:	private
+   Length:	26
+   Optional:	True
+   Encoding:	asciz
+   Values:
+    Tag_unknown_0:	"hello"
+    Tag_unknown_1:	"world"
+
+ - Name:	gnu_bar
+   Scope:	public
+   Length:	20
+   Optional:	True
+   Encoding:	ULEB128
+   Values:
+    Tag_unknown_0:	1 \(0x1\)
+    Tag_unknown_1:	0 \(0x0\)
+    Tag_unknown_2:	1 \(0x1\)
+
+ - Name:	gnu_foo
+   Scope:	public
+   Length:	16
+   Optional:	False
+   Encoding:	ULEB128
+   Values:
+    Tag_unknown_1:	1 \(0x1\)
diff --git a/binutils/testsuite/binutils-all/object-attr-v2.s b/binutils/testsuite/binutils-all/object-attr-v2.s
new file mode 100644
index 00000000000..d5029503bbc
--- /dev/null
+++ b/binutils/testsuite/binutils-all/object-attr-v2.s
@@ -0,0 +1,31 @@
+	.gnu_subsection gnu_foo, required, uleb128
+	.gnu_attribute 1, 1
+
+	.gnu_subsection gnu_bar, optional, uleb128
+	.gnu_attribute 0, 1
+	.gnu_attribute 1, 0
+	.gnu_attribute 2, 1
+
+	.gnu_subsection foo_1, optional, uleb128
+	.gnu_attribute 1, 1
+
+	.gnu_subsection foo_2, optional, uleb128
+	.gnu_attribute 0, 1
+	.gnu_attribute 1, 1
+
+	.gnu_subsection foo_1, optional, uleb128
+	.gnu_attribute 2, 0
+
+	.gnu_subsection foo_2, optional, uleb128
+	.gnu_attribute 1, 1
+
+	.gnu_subsection foo_1, optional, uleb128
+	.gnu_attribute 2, 0
+
+	.gnu_subsection foo_1, optional, uleb128
+	.gnu_attribute 3, 0
+	.gnu_attribute 4, 0
+
+	.gnu_subsection foo_3, optional, ntbs
+	.gnu_attribute 0, "hello"
+	.gnu_attribute 1, "world"
-- 
2.49.0



More information about the Binutils mailing list