https://github.com/garybeihl updated 
https://github.com/llvm/llvm-project/pull/173499

>From 5993787f8b3b17ea7de204bdb7df981dad00fece Mon Sep 17 00:00:00 2001
From: Gary Beihl <[email protected]>
Date: Sun, 28 Dec 2025 18:03:36 -0500
Subject: [PATCH] [lldb][NativePDB] Handle UEFI binaries without predetermined
 load addresses

UEFI executables are relocatable PE/COFF images where GetFileAddress()
returns LLDB_INVALID_ADDRESS, causing symbol load failure from PDB files.

Use base address 0 when load address is invalid, allowing symbols to be
loaded with their RVAs. The module's actual runtime load address must be
provided using `target modules load --file <module> --slide <load_address>`.

Tested with Rust UEFI binaries, successfully loading 5,405 symbols with
full source and line information.

Fixes: #91060
---
 .../SymbolFile/NativePDB/SymbolFileNativePDB.cpp       | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 3bf113a07d28c..40d45153b730f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -422,6 +422,16 @@ void SymbolFileNativePDB::InitializeObject() {
                            ->GetObjectFile()
                            ->GetBaseAddress()
                            .GetFileAddress();
+
+  // For UEFI/PE binaries and other relocatable images lacking a predetermined
+  // load address, GetFileAddress() returns LLDB_INVALID_ADDRESS. Use base
+  // address 0 in this case to allow symbols to be loaded with RVA
+  // (Relative Virtual Address). To debug at runtime, the module's actual load
+  // address must be provided using 'target modules load --file <module> 
--slide <load_address>'.
+  if (m_obj_load_address == LLDB_INVALID_ADDRESS) {
+    m_obj_load_address = 0x0;
+  }
+
   m_index->SetLoadAddress(m_obj_load_address);
   m_index->ParseSectionContribs();
 

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to