[Lldb-commits] [lldb] c9881c7 - Support looking up absolute symbols

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 9 09:45:36 PST 2021


Author: Adrian Prantl
Date: 2021-11-09T09:44:37-08:00
New Revision: c9881c7d99c6e4073ed8de11cd3450ef23bd66fc

URL: https://github.com/llvm/llvm-project/commit/c9881c7d99c6e4073ed8de11cd3450ef23bd66fc
DIFF: https://github.com/llvm/llvm-project/commit/c9881c7d99c6e4073ed8de11cd3450ef23bd66fc.diff

LOG: Support looking up absolute symbols

The Swift stdlib uses absolute symbols in the dylib to communicate
feature flags to the process. LLDB's expression evaluator needs to be
able to find them. This wires up absolute symbols so they show up in
the symtab lookup command, which is also all that's needed for them to
be visible to the expression evaluator JIT.

rdar://85093828

Differential Revision: https://reviews.llvm.org/D113445

Added: 
    lldb/test/Shell/SymbolFile/absolute-symbol.s

Modified: 
    lldb/source/Symbol/Symbol.cpp
    lldb/source/Symbol/Symtab.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 251f9104ad54d..a8c81ee3082f2 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -115,7 +115,8 @@ void Symbol::Clear() {
 }
 
 bool Symbol::ValueIsAddress() const {
-  return m_addr_range.GetBaseAddress().GetSection().get() != nullptr;
+  return m_addr_range.GetBaseAddress().GetSection().get() != nullptr ||
+         m_type == eSymbolTypeAbsolute;
 }
 
 ConstString Symbol::GetDisplayName() const {

diff  --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 61003981f18ef..69887034a9fb0 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -1100,6 +1100,7 @@ void Symtab::FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
           case eSymbolTypeCode:
           case eSymbolTypeResolver:
           case eSymbolTypeReExported:
+          case eSymbolTypeAbsolute:
             symbol_indexes.push_back(temp_symbol_indexes[i]);
             break;
           default:

diff  --git a/lldb/test/Shell/SymbolFile/absolute-symbol.s b/lldb/test/Shell/SymbolFile/absolute-symbol.s
new file mode 100644
index 0000000000000..912703fd38283
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/absolute-symbol.s
@@ -0,0 +1,7 @@
+# RUN: %clang %s -g -c -o %t.o
+# RUN: %lldb -b -o 'target modules lookup -s absolute_symbol' %t.o | FileCheck %s
+# CHECK: 1 symbols match 'absolute_symbol'
+# CHECK:   Address: 0x0000000012345678 (0x0000000012345678)
+# CHECK:   Summary: 0x0000000012345678
+.globl absolute_symbol
+absolute_symbol = 0x12345678


        


More information about the lldb-commits mailing list