[V2 01/36] [SFrame-V3] readelf: testsuite: sframe: add new SFrame V2 test

Jan Beulich jbeulich@suse.com
Fri Jan 9 14:45:44 GMT 2026


On 07.01.2026 09:41, Indu Bhagat via Binutils wrote:
> --- /dev/null
> +++ b/binutils/testsuite/binutils-all/x86-64/README-sframe-tests
> @@ -0,0 +1,53 @@
> +The tests in sframe.exp use binary data files:
> +  - test-v2-ET_EXEC.sframe.bz2
> +  - test-v2-ET_REL.sframe.bz2
> +These files are generated using a as/ld supporting SFrame V2 sections (Binutils
> +<= 2.45).  The purpose of those tests is to make sure readelf/objdump support
> +works for SFrame V2.
> +
> +The binary files are generated using the following steps.
> +
> +$ cat fake_sort.c
> +/* Keep noinline to ensure a separate FDE is generated */
> +void __attribute__ ((noinline))
> +swapit (int *a, int *b)
> +{
> +  *a = *b;
> +}
> +
> +void fake_sort (int *a, int n)
> +{
> +  if (n > 0)
> +    swapit (&a[0], &a[n-1]);
> +}
> +
> +$ cat sort.c
> +#include <stdio.h>
> +
> +#define ARRAY_LEN 128
> +
> +void fake_sort (int *a, int n);
> +
> +void sort_array (void)
> +{
> +  volatile int data[ARRAY_LEN];
> +  fake_sort ((int *)data, ARRAY_LEN);
> +}
> +
> +int main (void)
> +{
> +  sort_array ();
> +  /* for plt.  */
> +  printf ("done");
> +  return 0;
> +}
> +
> +$ gcc -c sort.c -O2 -Wa,--gsframe 
> +$ gcc -c fake_sort.c -O2 -Wa,--gsframe 
> +$ gcc sort.o fake_sort.o -o sort -O2 -Wa,--gsframe 
> +
> +$ objcopy --dump-section .sframe=test-v2-ET_EXEC.sframe sort
> +$ bzip2 test-v2-ET_EXEC.sframe
> +
> +$ objcopy --dump-section .sframe=test-v2-ET_REL.sframe sort.o
> +$ bzip2 test-v2-ET_REL.sframe

Apparently I'm missing something as to how this is intended to work: You
extract and compress raw .sframe section contents here. No ELF header or
anything. Then ...

> --- /dev/null
> +++ b/binutils/testsuite/binutils-all/x86-64/sframe.exp
> @@ -0,0 +1,63 @@
> +# 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
> +    }

... you extract the data here, and ...

> +    # Check readelf output of SFrame V2 sections.
> +    set got [remote_exec host "$READELF --sframe $tempfile" "" "/dev/null" "${tempfile}.out"]

... pass it to readelf. That wants an ELF header though, I suppose?

> +    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
> +	fail "readelf SFrame V2 ($testname)"
> +	continue
> +    }
> +
> +    if { [regexp_diff "${tempfile}.out" "${dumpfile}.dump"] } then {
> +	fail "readelf SFrame V2 ($testname)"
> +    }
> +    pass "readelf SFrame V2 ($testname)"
> +
> +    # Check objdump output of SFrame V2 sections as well.
> +    set got [remote_exec host "$OBJDUMP --sframe $tempfile" "" "/dev/null" "${tempfile}.out"]

Same for the objdump here. What am I missing?

Jan


More information about the Binutils mailing list