From 89ca1da64cc0785fc8dcb6385904eea3d2fcb001 Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Fri, 5 Dec 2025 12:24:30 -0800 Subject: [PATCH] [SFrame-V3] readelf: testsuite: sframe: add new SFrame V2 test 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 0000000000000000000000000000000000000000..e09a6e8772c319dce74b3d177c04b40ee27daca2 GIT binary patch literal 3347 zc-jFI4eatlT4*^jL0KkKSp$DzJoa?YaV(V%y)(}EXi1`I(;{IhvYydTPHq`NQ`82gnoLQP0GR+HGK`*6O*W>~^%{D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|kSr~p-p_3q~Bi#0cl$aL~5IGV}w|O9(F2e4GR%ghnt0QwY9*LglTc)|zlYz*R!xA`SpT#mSfg6_$XOp$wtRA;^(okWirLLjs<#9Z>~`L?Q6&__$Bu zQ&1w1AVXn0q2-l&HLpxIjE+XNX-iy-H^4e!7A>Z+5dfNkfCvY)P|ag*E9=#%ck``z zdwzMV?O8Rn*!HXf9s7U;Eo)YzUsDi6c^O1c%N9Mmg2cfBr?$`~TcbFW0@M{KR%NK; z1tDbB`JdPRw~so#Ox(2d6i(F~DJYkqL?T4QyLCnYP~~{DlTsYm&3+g$M4VIs0Tk+v zenz1~AoCqW-x2pn{lNbchEw871exK%s~PUQ=*O{)T_UZ+obasje}@kNixBE1HM3j^ zCt$k@b~Nbob|;4$N0jh+`7kcUxw|i@*Ii;rE@uP~CX*SJ0ZRXzH1uhmf4|6Wss+ literal 0 Hc-jL100001 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 0000000000000000000000000000000000000000..b06a19ec80f727b05a95851ad67845d95d1e5050 GIT binary patch literal 727 zc-jHi0x11LT4*^jL0KkKSx2DAYybjA|NsC0{7%XliNd zpQ-~0GynhwKmY&$00006fCEiQkteB%qtqD#KmcgdKn(x@dVl}`00004k|+?HL7<+d z002x+N2xG0000345s1Jh00C?49&d=?9Sus3*o@R-(b!hh+`3YABtit3r+Lng2GWFl zyF_D&$AY9t;L3xckmICBbx$FQ0uWOPTTT@;f0pp^dOn#-aet`=C6(k-aHO3aJtt6G zSy0-iiUj8JQvD2!Y=)O%faC7?P9^QzV$b zL#vkrq?-Y&P|Lu8ZsizVg!Jb)>W=2{EwFBuCLqojn96$Dn4b#w?p-5(!PoQUc$le8 zeW#IpJ3-v0_0=g{0Lqs-h6&PvW%vsEm+es-mK$)mzYR+ZI`#wuU1wW+k5D?ntK! J5(xAe4S+MCJg)!% literal 0 Hc-jL100001 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.47.3