[lld] [llvm] [dyndbg][LLD][ELF] Initial LLD support for dynamic debugging (PR #214188)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 00:03:51 PDT 2026


================
@@ -1914,6 +1918,61 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
     // called after processSymbolAssignments() because it needs to know whether
     // a linker-script-defined symbol is absolute.
     scanRelocations<ELFT>(ctx);
+
+    // Process symbols referenced by the embedded unoptimized part of dynamic
+    // debugging. Report references to undefined symbols and ensure that
+    // references to shared symbols have PLT/GOT entries as appropriate.
+    if (ctx.hasDynDbg) {
+      bool ignoreUnresolved =
+          (ctx.arg.unresolvedSymbols == UnresolvedPolicy::Ignore);
+      bool warnUnresolved =
+          (ctx.arg.unresolvedSymbols == UnresolvedPolicy::Warn);
+      for (Symbol *sym : ctx.symtab->getSymbols()) {
+        if (!sym->isDynDbgRef)
+          continue;
+
+        if (sym->isUndefined()) {
----------------
MaskRay wrote:

`RelocScan::maybeReportUndefined` is a slow path. We can make it call a new function `elf::maybeReportUndefined` and refactor code here to call `elf::maybeReportUndefined`

https://github.com/llvm/llvm-project/pull/214188


More information about the llvm-commits mailing list