Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Bratislav Filipovic <bfilipov@amd.com>
To: <gdb-patches@sourceware.org>, <tdevries@suse.de>
Cc: <simon.marchi@efficios.com>, Bratislav Filipovic <bfilipov@amd.com>
Subject: [PATCH] testsuite: ada-valprint-error relocation issue
Date: Wed, 1 Apr 2026 16:03:10 +0530	[thread overview]
Message-ID: <20260401103340.4011522-1-bfilipov@amd.com> (raw)
In-Reply-To: <662d00dd-c026-4af1-a293-b0247f22fae5@suse.de>

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.
---
Thanks for review Tom. I changed it per your suggestions. It seems to 
fail only for some combinations of clang + linker.

 gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
index f3d61e91..b72682f7 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
@@ -107,6 +107,23 @@ 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
+gdb_test_multiple "print /x fd__global" "check fd__global value" {
+    -re -wrap "@0x0: 0x0" {
+        unsupported "linker failed to apply relocation for fd__global"
+        return
+    }
+    -re -wrap "= $hex" {
+        pass $gdb_test_name
+    }
+}
+
 gdb_test_no_output "set language ada"
 
 gdb_test "print fd.global" \
-- 
2.43.0


  reply	other threads:[~2026-04-01 10:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 14:29 [PATCH] gdb/testsuite: skip ada-valprint-error with clang Bratislav Filipovic
2026-03-31 14:49 ` Tom de Vries
2026-04-01 10:33   ` Bratislav Filipovic [this message]
2026-04-01 11:12     ` [PATCH] testsuite: ada-valprint-error relocation issue Tom de Vries
2026-04-01 14:10       ` Bratislav Filipovic
2026-04-01 18:12         ` Tom de Vries
2026-04-02 13:12           ` Filipovic, Bratislav
2026-04-03  6:18             ` Tom de Vries
  -- strict thread matches above, loose matches on Subject: below --
2026-03-18 13:35 [PATCH] dwarf2: avoid decoding .debug_line for type units Bratislav Filipovic
2026-04-16 14:10 ` [PATCH] testsuite: ada-valprint-error relocation issue Bratislav Filipovic
2026-04-16 15:14   ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260401103340.4011522-1-bfilipov@amd.com \
    --to=bfilipov@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=tdevries@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox