gdb/testsuite: skip ada-valprint-error with clang

Message ID 20260331142934.3978473-1-bfilipov@amd.com
State New
Headers
Series gdb/testsuite: skip ada-valprint-error with clang |

Checks

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

Commit Message

Bratislav Filipovic March 31, 2026, 2:29 p.m. UTC
  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(+)
  

Comments

Tom de Vries March 31, 2026, 2:49 p.m. UTC | #1
On 3/31/26 4:29 PM, Bratislav Filipovic wrote:
> 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
> +}

Hi,

I think it would be useful if you'd document what version of clang 
you're having this problem with.

And since it's not clear to me from your explanation whether it's a 
compiler or linker bug, perhaps linker version as well?

Also, this test-case passes for me with clang (17.0.6, 19.1.7, with ld 
2.45.0), so disabling it entirely for clang seems too intrusive.

How about printing the value of fd__global, and declaring the test-case 
unsupported if the value is nullptr?

Thanks,
- Tom

> +
>   # This test can only be run on targets which support DWARF-2 and use gas.
>   require dwarf2_support
>
  

Patch

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