Skip to content

Commit e3a4cf9

Browse files
authored
Merge pull request #4124 from jasonmolenda/r89717101-do-expensive-searches-for-dyld-in-userland-corefile
Load dyld manually with 'main bin spec' userland corefiles
2 parents 34f1578 + 11f2a4d commit e3a4cf9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ static bool load_standalone_binary(UUID uuid, addr_t value,
224224
target.SetArchitecture(module_sp->GetObjectFile()->GetArchitecture());
225225
target.GetImages().AppendIfNeeded(module_sp, false);
226226

227+
// TODO: Instead of using the load address as a value, if we create a
228+
// memory module from that address, we could get the correct segment
229+
// offset values from the in-memory load commands and set them correctly.
230+
// In case the load address we were given is not correct for all segments,
231+
// e.g. something in the shared cache. DynamicLoaderDarwinKernel does
232+
// something similar for kexts. In the context of a corefile, this would
233+
// be an inexpensive operation. Not all binaries in a corefile will have
234+
// a Mach-O header/load commands in memory, so this will not work in all
235+
// cases.
236+
227237
bool changed = false;
228238
if (module_sp->GetObjectFile()) {
229239
if (value != LLDB_INVALID_ADDRESS) {
@@ -355,6 +365,8 @@ Status ProcessMachCore::DoLoadCore() {
355365
if (objfile_binary_value != LLDB_INVALID_ADDRESS &&
356366
!objfile_binary_value_is_offset) {
357367
if (type == ObjectFile::eBinaryTypeUser) {
368+
load_standalone_binary(objfile_binary_uuid, objfile_binary_value,
369+
objfile_binary_value_is_offset, GetTarget());
358370
m_dyld_addr = objfile_binary_value;
359371
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
360372
found_main_binary_definitively = true;

0 commit comments

Comments
 (0)