[PATCH 24/27] gdb.base/solib-weak.exp: Skip on all PE/COFF targets
Pedro Alves <[email protected]> Thu, 23 Jul 2026 14:01:15 +0100
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
The gdb.base/solib-weak.exp testcase sets a breakpoint on a function
that two shared libraries both provide, where one library defines it
as a weak symbol and the other as a strong symbol, and checks that GDB
picks the right copy. This relies on a weak symbol in one shared
library being overridden by a strong symbol of the same name in
another, resolved at load time, which is an ELF dynamic-linking
behavior.
The test was already skipped on mingw, cygwin and pe, since that
override does not happen on Windows: PE/COFF resolves symbols at link
time, per module, so a weak symbol in one DLL is not overridden by a
strong one in another DLL. GCC on mingw does accept
__attribute__((weak)) and binutils does emit PE weak externals, but
those are a link-time, single-module alias-with-fallback mechanism,
not the cross-DLL runtime override the test exercises, so the test
fails there.
The existing early return open-codes mingw/cygwin/pe and so did not
cover windows-msvc, whose triplet is
{x86_64,aarch64,i686}-pc-windows-msvc. Use is_pecoff_target instead,
which covers windows-msvc too, and reword the comment to say why the
test does not apply rather than just that "weak symbols are not
meaningful".
Confirmed the test still fails on windows-msvc before this change.
Tested on:
x86_64-pc-linux-gnu
x86_64-pc-cygwin
x86_64-w64-mingw32
x86_64-pc-windows-msvc
Change-Id: I5b12784d32ecd6b0595d721e28bd10a61a9f1901
---
gdb/testsuite/gdb.base/solib-weak.exp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp
index 319100e4a55..21449061e14 100644
--- a/gdb/testsuite/gdb.base/solib-weak.exp
+++ b/gdb/testsuite/gdb.base/solib-weak.exp
@@ -19,12 +19,13 @@
require allow_shlib_tests
-# These targets have shared libraries, but weak symbols are not meaningful.
-if {([istarget *-*-mingw*]
- || [istarget *-*-cygwin*]
- || [istarget *-*-pe*])} {
- return
-}
+# This test relies on a weak symbol in one shared library being
+# overridden by a strong symbol of the same name in another, resolved
+# at load time. That is an ELF dynamic-linking behavior. PE/COFF
+# resolves symbols at link time, per module, so a weak symbol in one
+# DLL is not overridden by a strong one in another DLL -- the scenario
+# this test exercises does not exist there.
+require !is_pecoff_target
# This test uses GCC-specific syntax.
if {![test_compiler_info "gcc-*"]} {
--
2.54.0