[PATCH 1/2] sframe: Use UNRESOLVED instead of FAIL

Indu Bhagat indu.bhagat@oracle.com
Wed Jan 21 06:39:27 GMT 2026


On 1/20/26 6:53 AM, claudiu.zissulescu-ianculescu@oracle.com wrote:
> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
> 
> 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>
> ---
>   ld/testsuite/ld-sframe/pr33401.rd |   3 +-
>   ld/testsuite/ld-sframe/sframe.exp | 114 ++++++++++++++++++++++++------
>   2 files changed, 96 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 ab386d7ca65..9059955a923 100644
> --- a/ld/testsuite/ld-sframe/sframe.exp
> +++ b/ld/testsuite/ld-sframe/sframe.exp
> @@ -23,43 +23,117 @@
>   # 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
> +    global runtests
> +

runtests unused?

> +    set binary $READELF
> +    set progopts "-j .rela.sframe"
> +
> +    # Ensure consistent sorting of symbols
> +    if {[info exists env(LC_ALL)]} {
> +	set old_lc_all $env(LC_ALL)
> +    }
> +    set env(LC_ALL) "C"

Is this environment var LC_ALL setting and unsetting needed here?

The sframe.exp file already does it, before running any test, and resets 
after.

> +    set cmd "$binary $progopts $binfile > dump.out"
> +    send_log "$cmd\n"
> +    catch "exec $cmd" comp_output
> +    if {[info exists old_lc_all]} {
> +	set env(LC_ALL) $old_lc_all
> +    } else {
> +	unset env(LC_ALL)
> +    }

Same for this.

> +    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
> +
> +    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
> +    }
> +

Sorry I am just noticing this.  Now that we dont invoke 
run_cc_link_tests, is check_compiler_available still needed ?

LGTM, otherwise.

> +    # 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"
>   
> -    # Check to see if C++ compiler work
> -    if { [which $CXX_FOR_TARGET] == 0 } {
> -	unsupported "PR ld/33401"
> -	return 0
> +	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
> +    }
> +
> +    # 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
>       }
>   
> -    # Run the test
> -    if { [run_cc_link_tests $test_list] == 0 } {
> +    # 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 mailing list