[Lldb-commits] [lldb] [LLDB] Skip test under gold (PR #224113)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 16 11:48:25 PDT 2026


https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/224113

The way gold emits symbols created by linker scripts is not implemented in LLDB.

For the record, I asked Claude to write a patch to implement the functionality but it came up with a linear search through all sections which I was afraid might be quite expensive. I'm happy to purse that as an alternative if people think it is worth it, with the caveat that I am not an ELF expert.

>From 17c45927295e4f05cdc55d94b9f8cb57cd939e24 Mon Sep 17 00:00:00 2001
From: Adrian Prantl <aprantl at apple.com>
Date: Wed, 16 Sep 2026 11:44:55 -0700
Subject: [PATCH] [LLDB] Skip test under gold

The way gold emits symbols created by linker scripts is not implemented in LLDB.
---
 .../linux/linker-symbols/TestLinkerSymbols.py | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lldb/test/API/linux/linker-symbols/TestLinkerSymbols.py b/lldb/test/API/linux/linker-symbols/TestLinkerSymbols.py
index d1fe3de462674..0ecb691831d30 100644
--- a/lldb/test/API/linux/linker-symbols/TestLinkerSymbols.py
+++ b/lldb/test/API/linux/linker-symbols/TestLinkerSymbols.py
@@ -2,12 +2,36 @@
 Test that LLDB can find symbols added by a linker script.
 """
 
+import os
+import shlex
+import subprocess
+
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
 from lldbsuite.test import lldbutil
 
 
+def _linker_is_gold(self):
+    """Ask the linker the test suite builds with to identify itself."""
+    cmd = [self.getCompiler()]
+    for var in ["CFLAGS_EXTRAS", "LD_EXTRAS"]:
+        cmd += shlex.split(os.environ.get(var, ""))
+    cmd += ["-Wl,--version", "-x", "c", "-", "-o", os.devnull]
+    try:
+        version = subprocess.run(
+            cmd, input="int main() {}", capture_output=True, text=True
+        ).stdout
+    except OSError:
+        return None
+    if version.startswith("GNU gold"):
+        # gold emits a symbol that a linker script defines inside an output
+        # section as SHN_ABS instead of binding it to that section, so the
+        # symbol reaches LLDB with neither a section nor a type.
+        return "GNU gold does not bind linker script symbols to a section"
+    return None
+
+
 class TestLinkerSymbols(TestBase):
     # If your test case doesn't stress debug info, then
     # set this to true.  That way it won't be run once for
@@ -16,6 +40,7 @@ class TestLinkerSymbols(TestBase):
     SHARED_BUILD_TESTCASE = False
 
     @requireLinux
+    @skipTestIfFn(_linker_is_gold)
     def test_linker_symbols(self):
         build_dict = dict(LD_EXTRAS="-Wl,-T," + self.getSourcePath("linker.script"))
         self.build(dictionary=build_dict)



More information about the lldb-commits mailing list