[binutils-gdb] sframe: Use UNRESOLVED instead of FAIL

Claudiu Zissulescu claziss@sourceware.org
Wed Jan 21 09:27:18 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c427f3614e293e46b3dfed287d02b6edaf9a17b5

commit c427f3614e293e46b3dfed287d02b6edaf9a17b5
Author: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Date:   Thu Jan 15 15:26:56 2026 +0200

    sframe: Use UNRESOLVED instead of FAIL
    
    Fix for PR ld/33784.
    
    The SFrame test for PR ld/33401 is a two-step link test where the
    second link depends on the output of the first. In the first step, the
    linker process generates R_*_NONE relocs for .sframe section, while
    the second link process should pass without any issue.
    
    This patch reworks the PR ld/33401 test by removing the call to
    run_cc_link_tests, and use individual command invocation for
    compilation, assembling and linking. It introduces the UNRESOLVED
    status if the first step contains a linking or assembling error. The
    UNTESTED status is emitted if the first stage doesn't produce R_*_NONE
    relocs in .sframe section to test the original issue.
    
    ld/
    
            PR ld/33784
            * testsuite/ld-sframe/sframe.exp (check_pr33401): Rework the
            procedure for UNRESOLVED and UNTESTED cases.
            (check_dump): New procedure.
            * testsuite/ld-sframe/pr33401.rd: Add extra line at the end of the
            file.
    
    Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>

Diff:
---
 ld/testsuite/ld-sframe/pr33401.rd |   3 +-
 ld/testsuite/ld-sframe/sframe.exp | 104 ++++++++++++++++++++++++++++++--------
 2 files changed, 86 insertions(+), 21 deletions(-)

diff --git a/ld/testsuite/ld-sframe/pr33401.rd b/ld/testsuite/ld-sframe/pr33401.rd
index 00142818b34..455a9d6efcf 100644
--- a/ld/testsuite/ld-sframe/pr33401.rd
+++ b/ld/testsuite/ld-sframe/pr33401.rd
@@ -1,3 +1,4 @@
 #...
 [0-9a-f]+ +0+ +R_.*_NONE +.*
-#pass
\ No newline at end of file
+#pass
+
diff --git a/ld/testsuite/ld-sframe/sframe.exp b/ld/testsuite/ld-sframe/sframe.exp
index c0c3f1be0d5..ef946193c32 100644
--- a/ld/testsuite/ld-sframe/sframe.exp
+++ b/ld/testsuite/ld-sframe/sframe.exp
@@ -23,43 +23,107 @@
 # Sframe section contains R_*_NONE relocations intermingled with other
 # relas in the output relocatable object.
 #
+proc check_dump { binfile dumpfile } {
+    global srcdir
+    global READELF
+    global subdir
+    global env
+
+    set binary $READELF
+    set progopts "-j .rela.sframe"
+
+    set cmd "$binary $progopts $binfile > dump.out"
+    send_log "$cmd\n"
+    catch "exec $cmd" comp_output
+
+    set comp_output [prune_warnings $comp_output]
+    if ![string match "" $comp_output] then {
+	send_log "$comp_output\n"
+	return 1
+    }
+
+    if { [regexp_diff "dump.out" "$srcdir/$subdir/$dumpfile"] } then {
+	verbose -log "output is [file_contents "dump.out"]" 2
+	return 1
+    }
+    return 0
+}
+
 proc check_pr33401 { } {
     global CXX_FOR_TARGET
     global ld
     global srcdir
     global subdir
+    global as
+    global LDFLAGS
+    global env
 
-    # Check to see if C++ compiler work
-    if { [which $CXX_FOR_TARGET] == 0 } {
-	unsupported "PR ld/33401"
-	return 0
+    set objfiles {}
+    set testname "PR ld/33401"
+    set failed 0
+    set linkfile "tmpdir/pr33401.o"
+    set src_files [list "StateClient.cpp" "StatePlaying.cpp"]
+
+    # Check to see if the C and C++ compilers work
+    if { ![check_compiler_available] || [which $CXX_FOR_TARGET] == 0 } {
+	unsupported $testname
+	return
+    }
+
+    # 1. First step: Create a relocatable object (pr33401.o) from
+    #    sources.  Some R_*_NONE are expected for this input.  We
+    #    cannot use run_cc_link_tests procedure as we need to control
+    #    every aspect of the compilation, assembling and linking
+    #    process.
+    foreach src_file $src_files {
+	set fileroot "[file rootname [file tail $src_file]]"
+	set objfile "tmpdir/$fileroot.o"
+
+	if { [file extension $src_file] == ".cpp" } {
+	    set as_file "tmpdir/$fileroot.s"
+	    set cmd "$CXX_FOR_TARGET -S -g -O2 -w"
+	    if ![ld_compile $cmd $srcdir/$subdir/$src_file $as_file] {
+		set failed 1
+		break
+	    }
+	} else {
+	    set as_file "$srcdir/$subdir/$src_file"
+	}
+	if { ![ld_assemble $as "--gsframe $as_file" $objfile] } {
+	    set failed 1
+	    break
+	}
+	lappend objfiles $objfile
     }
 
-    # 1. First step: Create a relocatable object (pr33401.o) from sources.
-    #     Some R_*_NONE are expected for this input.
-    set test_list {
-	{ "PR ld/33401 (Step 1: Create relocatable object and check R_*_NONE)"
-	    "-r"
-	    "-g -O2 -finline -w -Wa,--gsframe"
-	    {StateClient.cpp StatePlaying.cpp}
-	    {{readelf "-r -W" pr33401.rd}}
-	    "pr33401.o"
-	    "c++" }
+    # Catch previous action errors.
+    if { $failed } {
+	verbose -log "Error during compiling/assembling one of the input files."
+	unresolved $testname
+	return
     }
 
-    # Run the test
-    if { [run_cc_link_tests $test_list] == 0 } {
+    # Do the first linking. If this fails, we cannot resolve the test.
+    if { ![ld_link $ld $linkfile "-L$srcdir/$subdir -r $objfiles"] } {
+	verbose -log "Error during linking assembled objects."
+	unresolved $testname
+	return
+    }
+
+    # Check the output of the first ld invocation
+    if { [check_dump $linkfile pr33401.rd] } {
 	verbose -log "No R_*_NONE in .rela.sframe"
+	untested $testname
 	return
     }
 
+    # Clear error and warning counts.
+    reset_vars
+
     # 2. Final step: Run ld -r again on the output of step 1.
     #	 The assertion failure in PR 33401 occurred when processing input BFDs
     #	 containing R_*_NONE relocations in the .sframe section.
-    set testname "PR ld/33401 (Step 2: Final link)"
-
-    # Attempt to link the object created in step 1
-    if { ![ld_link $ld /dev/null "-L$srcdir/$subdir -r tmpdir/pr33401.o"] } {
+    if { ![ld_link $ld /dev/null "-L$srcdir/$subdir -r $linkfile"] } {
 	fail $testname
     } else {
 	pass $testname


More information about the Binutils-cvs mailing list