Improved detection of object file types, moving
detection of kernels into the object file and
adding a new category for raw binary images.
Fixed all clients who previously searched for
sections manually, making them use the object
file's facilities instead.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@150272 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 67fe1e4..5656823 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2180,12 +2180,24 @@
         case HeaderFileTypeExecutable:                                     // 0x2u MH_EXECUTE
             // Check for the MH_DYLDLINK bit in the flags
             if (m_header.flags & HeaderFlagBitIsDynamicLinkObject)
+            {
                 return eStrataUser;
-            return eStrataKernel;
+            }
+            else 
+            {
+                SectionList *section_list = GetSectionList();
+                if (section_list)
+                {
+                    static ConstString g_kld_section_name ("__KLD");
+                    if (section_list->FindSectionByName(g_kld_section_name))
+                        return eStrataKernel;
+                }
+            }
+            return eStrataRawImage;
 
         case HeaderFileTypeFixedVMShlib:        return eStrataUser;         // 0x3u MH_FVMLIB
         case HeaderFileTypeCore:                return eStrataUnknown;      // 0x4u MH_CORE
-        case HeaderFileTypePreloadedExecutable: return eStrataUser;         // 0x5u MH_PRELOAD
+        case HeaderFileTypePreloadedExecutable: return eStrataRawImage;     // 0x5u MH_PRELOAD
         case HeaderFileTypeDynamicShlib:        return eStrataUser;         // 0x6u MH_DYLIB
         case HeaderFileTypeDynamicLinkEditor:   return eStrataUser;         // 0x7u MH_DYLINKER
         case HeaderFileTypeBundle:              return eStrataUser;         // 0x8u MH_BUNDLE