Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Bratislav Filipovic <bfilipov@amd.com>
To: <gdb-patches@sourceware.org>
Cc: <simon.marchi@efficios.com>, Bratislav Filipovic <bfilipov@amd.com>
Subject: [PATCH] gdb/testsuite: skip ada-valprint-error with clang
Date: Tue, 31 Mar 2026 19:59:31 +0530	[thread overview]
Message-ID: <20260331142934.3978473-1-bfilipov@amd.com> (raw)

The ada-valprint-error.exp test fails when compiled with clang due
to a linker relocation issue in the test infrastructure, not a GDB
bug.

The test compiles ada-valprint-error.c with nodebug flags, then
links it with a separate DWARF .o file generated by lib/dwarf.exp.
The C source defines:

    int buffer[] = {0, 0};
    void *fd__global = &buffer;

This requires the linker to apply an R_X86_64_64 relocation to
store buffer's address into fd__global.  With GCC, the linker
correctly applies this relocation.  With clang, the linker fails
to apply it, leaving fd__global as NULL.

Binary evidence:
- GCC binary: fd__global = 0x4020 (correct address of buffer)
- Clang binary: fd__global = 0x0 (NULL)

Both .o files contain the R_X86_64_64 relocation entry, but the
final linked binary differs:
- GCC emits fd__global in .data.rel.local section -> relocation works
- Clang emits fd__global in .data section -> relocation fails

This appears to be a toolchain/testsuite compatibility issue when
linking nodebug object files with separate DWARF objects.  Skip
the test for clang to avoid false failures.

Tested on x86_64-linux-gnu with both GCC and clang.

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

diff --git a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
index f3d61e91..c23d58a8 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
@@ -14,6 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 load_lib dwarf.exp
 
+# Clang's linker fails to apply relocations when linking nodebug .o
+# with separate DWARF .o, resulting in fd__global being NULL instead
+# of pointing to buffer.
+if {[test_compiler_info "clang-*"]} {
+    unsupported "clang linker relocation issue with nodebug+DWARF linking"
+    return
+}
+
 # This test can only be run on targets which support DWARF-2 and use gas.
 require dwarf2_support
 
-- 
2.43.0


             reply	other threads:[~2026-03-31 14:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 14:29 Bratislav Filipovic [this message]
2026-03-31 14:49 ` Tom de Vries
2026-04-01 10:33   ` [PATCH] testsuite: ada-valprint-error relocation issue Bratislav Filipovic
2026-04-01 11:12     ` 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

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=20260331142934.3978473-1-bfilipov@amd.com \
    --to=bfilipov@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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