diff options
author | Greg Clayton <gclayton@apple.com> | 2012-12-11 01:20:51 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-12-11 01:20:51 +0000 |
commit | 67408537847323eca86d373916986c0f7d309d7a (patch) | |
tree | fc4ccb9fa23692b9c9dcaf7b41bb9b846aca3095 /lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp | |
parent | bd3051272ce123eb34b2253739404c93bec52d1e (diff) | |
download | bcm5719-llvm-67408537847323eca86d373916986c0f7d309d7a.tar.gz bcm5719-llvm-67408537847323eca86d373916986c0f7d309d7a.zip |
<rdar://problem/12842032>
Don't load __LINKEDIT segments when dynamically loading kexts.
llvm-svn: 169806
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp')
-rw-r--r-- | lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 3ba2126bd2c..0cb04468fbb 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -338,14 +338,21 @@ DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::LoadImageUsingMemoryModule ( } + static ConstString g_section_name_LINKEDIT ("__LINKEDIT"); + if (memory_module_sp && module_sp) { if (module_sp->GetUUID() == memory_module_sp->GetUUID()) { ObjectFile *ondisk_object_file = module_sp->GetObjectFile(); ObjectFile *memory_object_file = memory_module_sp->GetObjectFile(); + if (memory_object_file && ondisk_object_file) { + // Kexts are classified with a type of ObjectFile::eTypeSharedLibrary and + // a strata of ObjectFile::eStrataKernel. Ignore __LINKEDIT for kexts + const bool ignore_linkedit = ondisk_object_file->GetType() == ObjectFile::eTypeSharedLibrary; + SectionList *ondisk_section_list = ondisk_object_file->GetSectionList (); SectionList *memory_section_list = memory_object_file->GetSectionList (); if (memory_section_list && ondisk_section_list) @@ -367,6 +374,14 @@ DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::LoadImageUsingMemoryModule ( SectionSP ondisk_section_sp(ondisk_section_list->GetSectionAtIndex(sect_idx)); if (ondisk_section_sp) { + // Don't ever load __LINKEDIT as it may or may not be actually + // mapped into memory and there is no current way to tell. + // I filed rdar://problem/12851706 to track being able to tell + // if the __LINKEDIT is actually mapped, but until then, we need + // to not load the __LINKEDIT + if (ignore_linkedit && ondisk_section_sp->GetName() == g_section_name_LINKEDIT) + continue; + const Section *memory_section = memory_section_list->FindSectionByName(ondisk_section_sp->GetName()).get(); if (memory_section) { |