[binutils-gdb] ld: testsuite: Add sframe test for PR 33401
Claudiu Zissulescu
claziss@sourceware.org
Fri Dec 12 15:19:44 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f712f6c74f9b0ff721d9bd5278d2e50788aaf960
commit f712f6c74f9b0ff721d9bd5278d2e50788aaf960
Author: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Date: Fri Dec 12 17:02:32 2025 +0200
ld: testsuite: Add sframe test for PR 33401
When linking for a relocable output file (-r), one or more R_*_NONE
relocations may be generated for .sframe section. Two new tcl
procedures are added to sframe.exp file. 'check-dump' is checking if
an input bin file has the same relocation as specified in the second
input argument. 'check_pr33401' is the main checking function for
PR33401 which calls twice the ld tool to produce an relocable output
file.
ld:
PR33401
* testsuite/ld-sframe/StateClient.cpp: New file.
* testsuite/ld-sframe/StatePlaying.cpp: Likewise.
* testsuite/ld-sframe/pr33401.rd: Likewise.
* testsuite/ld-sframe/sframe.exp (check_pr33401): New procedure.
Co-authored-by: Indu Bhagat <indu.bhagat@oracle.com>
Reviewed-by: Indu Bhagat <indu.bhagat@oracle.com>
Diff:
---
ld/testsuite/ld-sframe/StateClient.cpp | 26 +++++++++++++++++
ld/testsuite/ld-sframe/StatePlaying.cpp | 41 +++++++++++++++++++++++++++
ld/testsuite/ld-sframe/pr33401.rd | 3 ++
ld/testsuite/ld-sframe/sframe.exp | 50 +++++++++++++++++++++++++++++++++
4 files changed, 120 insertions(+)
diff --git a/ld/testsuite/ld-sframe/StateClient.cpp b/ld/testsuite/ld-sframe/StateClient.cpp
new file mode 100644
index 00000000000..0154469ce6c
--- /dev/null
+++ b/ld/testsuite/ld-sframe/StateClient.cpp
@@ -0,0 +1,26 @@
+void a(void *);
+class b {
+ long ag;
+ bool c();
+ void m_fn2() {
+ if (c())
+ d(ag);
+ }
+ void d(long);
+
+public:
+ ~b() { m_fn2(); }
+};
+class Player {
+ int *an;
+ b ao;
+ char be;
+
+public:
+ virtual ~Player() {
+ a(&be);
+ a(&be);
+ a(&be);
+ delete an;
+ }
+} e;
diff --git a/ld/testsuite/ld-sframe/StatePlaying.cpp b/ld/testsuite/ld-sframe/StatePlaying.cpp
new file mode 100644
index 00000000000..f61c32d54c1
--- /dev/null
+++ b/ld/testsuite/ld-sframe/StatePlaying.cpp
@@ -0,0 +1,41 @@
+void b(void *);
+class c {
+public:
+ long am;
+ bool d();
+ void e() {
+ if (d())
+ f(am);
+ }
+ void f(long);
+ ~c() { e(); }
+};
+class g {
+public:
+ virtual ~g();
+};
+class Player {
+ int *bh;
+ c bi;
+ char bj;
+
+public:
+ virtual ~Player() {
+ b(&bj);
+ b(&bj);
+ b(&bj);
+ delete bh;
+ }
+};
+class h {
+public:
+ ~h() {
+ Player *a[0];
+ delete a[0];
+ }
+};
+class i : g {
+ h bo;
+ virtual int j();
+};
+int i::j() {}
diff --git a/ld/testsuite/ld-sframe/pr33401.rd b/ld/testsuite/ld-sframe/pr33401.rd
new file mode 100644
index 00000000000..00142818b34
--- /dev/null
+++ b/ld/testsuite/ld-sframe/pr33401.rd
@@ -0,0 +1,3 @@
+#...
+[0-9a-f]+ +0+ +R_.*_NONE +.*
+#pass
\ No newline at end of file
diff --git a/ld/testsuite/ld-sframe/sframe.exp b/ld/testsuite/ld-sframe/sframe.exp
index 61dc4dafa2e..acd52a4ef18 100644
--- a/ld/testsuite/ld-sframe/sframe.exp
+++ b/ld/testsuite/ld-sframe/sframe.exp
@@ -18,6 +18,54 @@
# MA 02110-1301, USA.
#
+# Test infrastructure for bug 33401
+# https://sourceware.org/bugzilla/show_bug.cgi?id=33401
+# Sframe section contains R_*_NONE relocations intermingled with other
+# relas in the output relocatable object.
+#
+proc check_pr33401 { } {
+ global CXX_FOR_TARGET
+ global ld
+ global srcdir
+ global subdir
+
+ # Check to see if C++ compiler work
+ if { [which $CXX_FOR_TARGET] == 0 } {
+ unsupported "PR ld/33401"
+ return 0
+ }
+
+ # 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 -w -Wa,--gsframe"
+ {StateClient.cpp StatePlaying.cpp}
+ {{readelf "-r -W" pr33401.rd}}
+ "pr33401.o"
+ "c++" }
+ }
+
+ # Run the test
+ if { [run_cc_link_tests $test_list] == 0 } {
+ verbose -log "No R_*_NONE in .rela.sframe"
+ return
+ }
+
+ # 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"] } {
+ fail $testname
+ } else {
+ pass $testname
+ }
+}
+
if [skip_sframe_tests] {
unsupported "no SFrame format support in the assembler, or SFrame disabled"
return 0
@@ -40,6 +88,8 @@ foreach sframe_test $sframe_test_list {
run_dump_test [file rootname $sframe_test]
}
+check_pr33401
+
if {[info exists old_lc_all]} {
set env(LC_ALL) $old_lc_all
} else {
More information about the Binutils-cvs
mailing list