aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2025-02-18 12:40:54 -0800
committerGitHub <noreply@github.com>2025-02-18 12:40:54 -0800
commit1f5edb17b23f5ac0576f83a6c122ce38bd5ec18e (patch)
treee6d6380733afae1661dd553228ca59e26df770f0 /lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
parent0049adfe122502444ca9cac6d059570e91e9b923 (diff)
downloadllvm-1f5edb17b23f5ac0576f83a6c122ce38bd5ec18e.zip
llvm-1f5edb17b23f5ac0576f83a6c122ce38bd5ec18e.tar.gz
llvm-1f5edb17b23f5ac0576f83a6c122ce38bd5ec18e.tar.bz2
[lldb][Mach-O] Read dyld_all_image_infos addr from `main bin spec` LC_NOTE (#127156)
Mach-O corefiles have LC_NOTE metadata, one LC_NOTE that lldb recognizes is `main bin spec` which can specify that this is a kernel corefile, userland corefile, or firmware/standalone corefile. With a userland corefile, the LC_NOTE would specify the virtual address of the dyld binary's Mach-O header. lldb would create a Module from that in-memory binary, find the `dyld_all_image_infos` object in dyld's DATA segment, and use that object to find all of the binaries present in the corefile. ProcessMachCore takes the metadata from this LC_NOTE and passes the address to the DynamicLoader plugin via its `GetImageInfoAddress()` method, so the DynamicLoader can find all of the binaries and load them in the Target at their correct virtual addresses. We have a corefile creator who would prefer to specify the address of `dyld_all_image_infos` directly, instead of specifying the address of dyld and parsing that to find the object. DynamicLoaderMacOSX, the DynamicLoader plugin being used here, will accept either a dyld virtual address or a `dyld_all_image_infos` virtual address from ProcessMachCore, and do the correct thing with either value. lldb's process save-core mach-o corefile reader will continue to specify the virtual address of the dyld binary. rdar://144322688
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 4e356a7..a19322f 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5599,9 +5599,13 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
// struct main_bin_spec
// {
// uint32_t version; // currently 2
- // uint32_t type; // 0 == unspecified, 1 == kernel,
+ // uint32_t type; // 0 == unspecified,
+ // // 1 == kernel
// // 2 == user process,
+ // dyld mach-o binary addr
// // 3 == standalone binary
+ // // 4 == user process,
+ // // dyld_all_image_infos addr
// uint64_t address; // UINT64_MAX if address not specified
// uint64_t slide; // slide, UINT64_MAX if unspecified
// // 0 if no slide needs to be applied to
@@ -5652,6 +5656,7 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
// convert the "main bin spec" type into our
// ObjectFile::BinaryType enum
const char *typestr = "unrecognized type";
+ type = eBinaryTypeInvalid;
switch (binspec_type) {
case 0:
type = eBinaryTypeUnknown;
@@ -5669,6 +5674,10 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
type = eBinaryTypeStandalone;
typestr = "standalone";
break;
+ case 4:
+ type = eBinaryTypeUserAllImageInfos;
+ typestr = "userland dyld_all_image_infos";
+ break;
}
LLDB_LOGF(log,
"LC_NOTE 'main bin spec' found, version %d type %d "