Skip to content

Commit 5eb7248

Browse files
committed
Clean up conditional, don't set load binaries twice
Follow Alex Langford's feedback to my patch from https://reviews.llvm.org/D145547 , and fix a side issue I noticed while testing this, where binaries loaded via LC_NOTE metadata were loaded in the Target twice unnecessarily. (cherry picked from commit 8db8a4e)
1 parent 761429b commit 5eb7248

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,10 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
812812
}
813813
}
814814

815-
if (m_module_sp && m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid) {
816-
ObjectFileMachO *ondisk_objfile_macho =
817-
llvm::dyn_cast_or_null<ObjectFileMachO>(
818-
m_module_sp ? m_module_sp->GetObjectFile() : nullptr);
819-
if (ondisk_objfile_macho) {
815+
if (m_module_sp && m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid &&
816+
m_module_sp->GetObjectFile()) {
817+
if (ObjectFileMachO *ondisk_objfile_macho =
818+
llvm::dyn_cast<ObjectFileMachO>(m_module_sp->GetObjectFile())) {
820819
if (!IsKernel() && !ondisk_objfile_macho->IsKext()) {
821820
// We have a non-kext, non-kernel binary. If we already have this
822821
// loaded in the Target with load addresses, don't re-load it again.

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7074,6 +7074,8 @@ bool ObjectFileMachO::LoadCoreFileImages(lldb_private::Process &process) {
70747074
&process, image.filename, image.uuid, image.load_address,
70757075
false /* value_is_offset */, image.currently_executing,
70767076
false /* notify */);
7077+
if (module_sp)
7078+
continue;
70777079
}
70787080

70797081
// If we have a slide, we need to find the original binary
@@ -7084,6 +7086,8 @@ bool ObjectFileMachO::LoadCoreFileImages(lldb_private::Process &process) {
70847086
&process, image.filename, image.uuid, image.slide,
70857087
true /* value_is_offset */, image.currently_executing,
70867088
false /* notify */);
7089+
if (module_sp)
7090+
continue;
70877091
}
70887092

70897093
// Try to find the binary by UUID or filename on the local

0 commit comments

Comments
 (0)