[Lldb-commits] [lldb] r169806 - /lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
Greg Clayton
gclayton at apple.com
Mon Dec 10 17:20:51 PST 2012
Author: gclayton
Date: Mon Dec 10 19:20:51 2012
New Revision: 169806
URL: http://llvm.org/viewvc/llvm-project?rev=169806&view=rev
Log:
<rdar://problem/12842032>
Don't load __LINKEDIT segments when dynamically loading kexts.
Modified:
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=169806&r1=169805&r2=169806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Mon Dec 10 19:20:51 2012
@@ -338,14 +338,21 @@
}
+ 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 @@
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)
{
More information about the lldb-commits
mailing list