testsuite: ada-valprint-error relocation issue

Message ID 20260401144007.4026084-1-bfilipov@amd.com
State New
Headers
Series testsuite: ada-valprint-error relocation issue |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Bratislav Filipovic April 1, 2026, 2:10 p.m. UTC
  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.
---
 .../gdb.dwarf2/ada-valprint-error.exp         | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
  

Comments

Tom de Vries April 1, 2026, 6:12 p.m. UTC | #1
On 4/1/26 4:10 PM, Bratislav Filipovic wrote:
> 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.

Hi,

the patch LGTM, but I'm wondering, do you have a copyright assignment, 
or are you covered by an AMD blanket assignment perhaps?

Thanks,
- Tom

> ---
>   .../gdb.dwarf2/ada-valprint-error.exp         | 21 +++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
> index f3d61e91..00e737bc 100644
> --- a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
> +++ b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
> @@ -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" \
  
Filipovic, Bratislav April 2, 2026, 1:12 p.m. UTC | #2
[AMD Official Use Only - AMD Internal Distribution Only]

Hi Tom,

Yes, blanket assignment. About pushing, I was told to ask you to push it since I've only recently started contributing and
I don't have write-after-approval access.

Regards Bratislav


-----Original Message-----
From: Tom de Vries <tdevries@suse.de>
Sent: Wednesday, April 1, 2026 8:12 PM
To: Filipovic, Bratislav <Bratislav.Filipovic@amd.com>
Cc: gdb-patches@sourceware.org; simon.marchi@efficios.com
Subject: Re: [PATCH] testsuite: ada-valprint-error relocation issue

[You don't often get email from tdevries@suse.de. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


On 4/1/26 4:10 PM, Bratislav Filipovic wrote:
> 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.

Hi,

the patch LGTM, but I'm wondering, do you have a copyright assignment, or are you covered by an AMD blanket assignment perhaps?

Thanks,
- Tom

> ---
>   .../gdb.dwarf2/ada-valprint-error.exp         | 21 +++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
> b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
> index f3d61e91..00e737bc 100644
> --- a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
> +++ b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
> @@ -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" \
  
Tom de Vries April 3, 2026, 6:18 a.m. UTC | #3
On 4/2/26 3:12 PM, Filipovic, Bratislav wrote:
> Yes, blanket assignment. About pushing, I was told to ask you to push it since I've only recently started contributing and
> I don't have write-after-approval access.

Hi,

I've pushed this, with the tag below.

Thanks,
- Tom

Approved-By: Tom de Vries <tdevries@suse.de>
  

Patch

diff --git a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
index f3d61e91..00e737bc 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
@@ -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" \