[RFC 01/28] [SFrame-V3] readelf: testsuite: sframe: add new SFrame V2 test
Indu Bhagat
indu.bhagat@oracle.com
Tue Dec 9 09:07:26 GMT 2025
In subsequent commits, we will add support for SFrame V3. GNU as and ld
will only generate SFrame V3; SFrame V2 will not be supported for
generation.
For readelf/objdump, however, continue to support textual dump of SFrame
V2 sections. Add a binary file (with no debug data) with SFrame V2
section to keep the dumping tested.
TBD:
- The cmp file should ideally be a set of regexp checks.
binutils/testsuite/
* binutils-all/x86-64/sframe.exp: New test.
* binutils-all/x86-64/test-v2.sframe.bz2: New test.
* binutils-all/x86-64/test-v2-ET_EXEC.sframe.bz2: New test.
* binutils-all/x86-64/test-v2-ET_EXEC.sframe.dump: New test.
* binutils-all/x86-64/test-v2-ET_REL.sframe.bz2: New test.
* binutils-all/x86-64/test-v2-ET_REL.sframe.dump: New test.
---
.../testsuite/binutils-all/x86-64/sframe.exp | 51 +++++++++++++++
.../x86-64/test-v2-ET_EXEC.sframe.bz2 | Bin 0 -> 3347 bytes
.../x86-64/test-v2-ET_EXEC.sframe.dump | 60 ++++++++++++++++++
.../x86-64/test-v2-ET_REL.sframe.bz2 | Bin 0 -> 727 bytes
.../x86-64/test-v2-ET_REL.sframe.dump | 24 +++++++
5 files changed, 135 insertions(+)
create mode 100644 binutils/testsuite/binutils-all/x86-64/sframe.exp
create mode 100644 binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.bz2
create mode 100644 binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.dump
create mode 100644 binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.bz2
create mode 100644 binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.dump
diff --git a/binutils/testsuite/binutils-all/x86-64/sframe.exp b/binutils/testsuite/binutils-all/x86-64/sframe.exp
new file mode 100644
index 00000000000..72c6dab21c4
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/sframe.exp
@@ -0,0 +1,51 @@
+# Expect script for x86-64 object tests for SFrame.
+# 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.
+
+if {![istarget "x86_64-*-linux*"] || [is_remote host]} {
+ return
+}
+
+set tempfile tmpdir/sframe-testbin
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.sframe.bz2]]
+foreach t $test_list {
+ # We need to strip the ".bz2", but can leave the dirname.
+ set test $subdir/[file tail $t]
+ set testname [file rootname $test]
+ verbose $testname
+
+ # We will check against the expected output in file named ${dumpfile}.dump
+ set dumpfile [file rootname $t]
+
+ if {[catch "system \"bzip2 -dc $t > $tempfile\""] != 0} {
+ untested "bzip2 -dc ($tempfile)"
+ continue
+ }
+ set got [remote_exec host "$READELF --sframe $tempfile" "" "/dev/null" "${tempfile}.out"]
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "readelf SFrame V2 ($testname)"
+ continue
+ }
+
+ set got [binutils_run cmp "${tempfile}.out ${dumpfile}.dump"]
+ if ![string equal "" $got] then {
+ fail "readelf SFrame V2 ($testname)"
+ continue
+ }
+ pass "readelf SFrame V2 ($testname)"
+}
diff --git a/binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.bz2 b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.bz2
new file mode 100644
index 00000000000..e09a6e8772c
Binary files /dev/null and b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.bz2 differ
diff --git a/binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.dump b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.dump
new file mode 100644
index 00000000000..efa4feaeed5
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_EXEC.sframe.dump
@@ -0,0 +1,60 @@
+Contents of the SFrame section .sframe:
+ Header :
+
+ Version: SFRAME_VERSION_2
+ Flags: SFRAME_F_FDE_SORTED,
+ SFRAME_F_FDE_FUNC_START_PCREL
+ CFA fixed RA offset: -8
+ Num FDEs: 9
+ Num FREs: 22
+
+ Function Index :
+
+ func idx [0]: pc = 0x401020, size = 16 bytes
+ STARTPC CFA FP RA
+ 0000000000401020 sp+16 u f
+ 0000000000401026 sp+24 u f
+
+ func idx [1]: pc = 0x401030, size = 64 bytes
+ STARTPC[m] CFA FP RA
+ 0000000000000000 sp+8 u f
+ 000000000000000b sp+16 u f
+
+ func idx [2]: pc = 0x401070, size = 109 bytes
+ STARTPC CFA FP RA
+ 0000000000401070 sp+8 u f
+ 0000000000401074 sp+32 u f
+ 00000000004010dc sp+8 u f
+
+ func idx [3]: pc = 0x4011d0, size = 10 bytes
+ STARTPC CFA FP RA
+ 00000000004011d0 sp+8 u f
+
+ func idx [4]: pc = 0x4011e0, size = 1 bytes
+ STARTPC CFA FP RA
+ 00000000004011e0 sp+8 u f
+
+ func idx [5]: pc = 0x4011f0, size = 64 bytes
+ STARTPC CFA FP RA
+ 00000000004011f0 sp+8 u f
+ 00000000004011f1 sp+16 c-16 f
+ 00000000004011f2 sp+24 c-16 f
+ 00000000004011f9 sp+544 c-16 f
+ 000000000040122d sp+24 c-16 f
+ 000000000040122e sp+16 c-16 f
+ 000000000040122f sp+8 c-16 f
+
+ func idx [6]: pc = 0x401230, size = 48 bytes
+ STARTPC CFA FP RA
+ 0000000000401230 sp+8 u f
+ 0000000000401231 sp+16 c-16 f
+ 0000000000401234 fp+16 c-16 f
+ 000000000040125f sp+8 c-16 f
+
+ func idx [7]: pc = 0x401260, size = 9 bytes
+ STARTPC CFA FP RA
+ 0000000000401260 sp+8 u f
+
+ func idx [8]: pc = 0x401270, size = 74 bytes
+ STARTPC CFA FP RA
+ 0000000000401270 sp+8 u f
diff --git a/binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.bz2 b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.bz2
new file mode 100644
index 00000000000..b06a19ec80f
Binary files /dev/null and b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.bz2 differ
diff --git a/binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.dump b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.dump
new file mode 100644
index 00000000000..2caf02c8fd8
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/test-v2-ET_REL.sframe.dump
@@ -0,0 +1,24 @@
+Contents of the SFrame section .sframe:
+ Header :
+
+ Version: SFRAME_VERSION_2
+ Flags: SFRAME_F_FDE_FUNC_START_PCREL
+ CFA fixed RA offset: -8
+ Num FDEs: 2
+ Num FREs: 8
+
+ Function Index :
+
+ func idx [0]: pc = 0x0, size = 1 bytes
+ STARTPC CFA FP RA
+ 0000000000000000 sp+8 u f
+
+ func idx [1]: pc = 0x10, size = 64 bytes
+ STARTPC CFA FP RA
+ 0000000000000010 sp+8 u f
+ 0000000000000011 sp+16 c-16 f
+ 0000000000000012 sp+24 c-16 f
+ 0000000000000019 sp+544 c-16 f
+ 000000000000004d sp+24 c-16 f
+ 000000000000004e sp+16 c-16 f
+ 000000000000004f sp+8 c-16 f
--
2.43.0
More information about the Binutils
mailing list