Author: Fred Riss
Date: 2020-07-24T09:19:17-07:00
New Revision: 22c16360dd00230987fee5f6f3c57f8071144cc1

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

LOG: [lldb/ObjectFileMachO] Correctly account for resolver symbols

Summary:
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.

Reviewers: jasonmolenda, jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ab1a6a8bb5f3..338c798e6cef 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1990,6 +1990,8 @@ static bool ParseTrieEntries(DataExtractor &data, 
lldb::offset_t offset,
       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);

diff  --git a/lldb/test/API/macosx/indirect_symbol/Makefile 
b/lldb/test/API/macosx/indirect_symbol/Makefile
index 929ed58f7575..9069302b39c4 100644
--- a/lldb/test/API/macosx/indirect_symbol/Makefile
+++ b/lldb/test/API/macosx/indirect_symbol/Makefile
@@ -8,7 +8,8 @@ include Makefile.rules
 
 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) \


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to