[Lldb-commits] [PATCH] D140066: Add a final fallback technique to the old Darwin dynamic loader plugin to find the dyld_all_image_infos structure

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 14 16:04:22 PST 2022


jasonmolenda created this revision.
jasonmolenda added a reviewer: JDevlieghere.
jasonmolenda added a project: LLDB.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

When lldb is running on a userland corefile (the only case where DynamicLoaderMacOSX is still used today), lldb finds dyld in the corefile by exhaustive search, then reads the symbol table in the corefile to find the "dyld_all_image_infos" symbol.  Using this object in the corefile, we can find the filepaths & load addresses of all other binaries.

This patch adds an additional fallback if we can't find the symbol name "dyld_all_image_infos" - by looking for the named section in dyld that is used specifically to identify this object.  It is only used after the two function names we try have failed, at the point where we have no other possible ways to find the dyld_all_image_infos object in the corefile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140066

Files:
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp


Index: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
===================================================================
--- lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -277,6 +277,16 @@
           m_dyld_all_image_infos_addr = symbol->GetLoadAddress(&target);
       }
 
+      if (m_dyld_all_image_infos_addr == LLDB_INVALID_ADDRESS) {
+        ConstString g_sect_name("__all_image_info");
+        SectionSP dyld_aii_section_sp =
+            dyld_module_sp->GetSectionList()->FindSectionByName(g_sect_name);
+        if (dyld_aii_section_sp) {
+          Address dyld_aii_addr(dyld_aii_section_sp, 0);
+          m_dyld_all_image_infos_addr = dyld_aii_addr.GetLoadAddress(&target);
+        }
+      }
+
       // Update all image infos
       InitializeFromAllImageInfos();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140066.483022.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221215/6fc44d90/attachment.bin>


More information about the lldb-commits mailing list