]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
testsuite: ada-valprint-error relocation issue
authorBratislav Filipovic <bfilipov@amd.com>
Fri, 3 Apr 2026 06:11:02 +0000 (08:11 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 3 Apr 2026 06:11:02 +0000 (08:11 +0200)
The ada-valprint-error.exp test links a nodebug .o file with a separate
DWARF .o file generated by lib/dwarf.exp. This requires the linker to
apply relocations for initialized pointers in the .data section.

Some clang + linker combinations fail to apply these relocations,
leaving fd__global as NULL instead of pointing to buffer. This causes
the test to print null instead of the expected error message.

Binary evidence from .comment section confirms which compiler and
linker were used. Testing shows:
- GCC 13 + GNU ld 2.42: PASS
- clang 20 + GNU ld 2.42: FAIL
- clang 22 + ld.lld 22: FAIL
- clang 17/19 + GNU ld 2.45.0: PASS

The failure is a linker limitation when handling this specific
relocation pattern, not a GDB bug. Document this in the test file
to help users understand why the test may fail with certain toolchains.

Approved-By: Tom de Vries <tdevries@suse.de>
gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp

index f3d61e91199242ba462df727616d3b84ffd10280..00e737bcef2baba1305ee83aa95d9c3ec88cb200 100644 (file)
@@ -107,6 +107,27 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} \
     return -1
 }
 
+# Note: This test may fail with certain clang + linker combinations
+# Specifically, clang + ld.lld can fail to apply relocations when linking
+# nodebug .o with separate DWARF .o, leaving fd__global as NULL instead
+# of pointing to buffer. The failure is a linker limitation, not a GDB bug.
+#
+# Known to fail: clang 20/22 + GNU ld 2.42, clang 22 + ld.lld 22
+# Known to pass: GCC + GNU ld, clang 17/19 + GNU ld 2.45.0
+set unsupported 0
+gdb_test_multiple "print /x fd__global" "check fd__global value" {
+    -re -wrap "@0x0: 0x0" {
+       set unsupported 1
+    }
+    -re -wrap "" {
+       pass $gdb_test_name
+    }
+}
+if {$unsupported} {
+    unsupported "linker failed to apply relocation for fd__global"
+    return
+}
+
 gdb_test_no_output "set language ada"
 
 gdb_test "print fd.global" \