[Lldb-commits] [PATCH] D84083: [lldb/ObjectFileMachO] Correctly account for resolver symbols

Frederic Riss via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 17 18:00:44 PDT 2020


friss created this revision.
friss added reviewers: jasonmolenda, jingham.
Herald added a project: LLDB.

The resolver addresses stored in the dyld trie are relative to the base
of the __TEXT segment. This is usually 0 in a dylib, so this was never
noticed, but it is not 0 for most dylibs integrated in the shared cache.
As we started using the shared cache images recently as symbol source,
this causes LLDB to fail to resolve symbols which go through a runtime
resolver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84083

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/test/API/macosx/indirect_symbol/Makefile


Index: lldb/test/API/macosx/indirect_symbol/Makefile
===================================================================
--- lldb/test/API/macosx/indirect_symbol/Makefile
+++ lldb/test/API/macosx/indirect_symbol/Makefile
@@ -8,7 +8,8 @@
 
 build-libindirect: indirect.c
 	$(MAKE) -f $(MAKEFILE_RULES) \
-		DYLIB_C_SOURCES=indirect.c DYLIB_NAME=indirect DYLIB_ONLY=YES
+		DYLIB_C_SOURCES=indirect.c DYLIB_NAME=indirect DYLIB_ONLY=YES \
+		LD_EXTRAS="-Wl,-image_base,0x200000000"
 
 build-libreepxoprt: reexport.c
 	$(MAKE) -f $(MAKEFILE_RULES) \
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1990,6 +1990,8 @@
       if (e.entry.flags & EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER) {
         e.entry.other = data.GetULEB128(&offset);
         uint64_t resolver_addr = e.entry.other;
+        if (text_seg_base_addr != LLDB_INVALID_ADDRESS)
+          resolver_addr += text_seg_base_addr;
         if (is_arm)
           resolver_addr &= THUMB_ADDRESS_BIT_MASK;
         resolver_addresses.insert(resolver_addr);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84083.278950.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200718/37c53fac/attachment.bin>


More information about the lldb-commits mailing list