@@ -25,7 +25,8 @@ void KernelCacheViewType::Register()
2525}
2626
2727Ref<BinaryView> KernelCacheViewType::Create (BinaryView* data)
28- {uint32_t magic;
28+ {
29+ uint32_t magic;
2930 data->Read (&magic, data->GetStart (), 4 );
3031 if (magic != MH_CIGAM_64 && magic != MH_MAGIC_64) // FIXME 32 bit
3132 {
@@ -133,7 +134,7 @@ Ref<Settings> KernelCacheViewType::GetLoadSettingsForData(BinaryView* data)
133134 R"( {
134135 "title" : "Image Auto-Load Regex Pattern",
135136 "type" : "string",
136- "default" : ".*libsystem_c.dylib ",
137+ "default" : "",
137138 "description" : "A regex pattern to auto load matching images at the end of view init, defaults to the system_c image only."
138139 })" );
139140
@@ -318,9 +319,16 @@ bool KernelCacheView::Init()
318319 }
319320 if (!foundBuildVersion)
320321 {
321- LogError (" Failed to find LC_BUILD_VERSION in subheader" );
322- SetDefaultArchitecture (Architecture::GetByName (" aarch64" ));
323- SetDefaultPlatform (Platform::GetByName (" macos-kernel-aarch64" ));
322+ // FIXME: Is it in-spec to have LC_BUILD_VERSION only in the super header?
323+ // This is sufficient as a fallback but source should be referenced here.
324+ LogWarn (" Failed to find LC_BUILD_VERSION in subheader. Assuming macOS platform." );
325+ std::map<std::string, Ref<Metadata>> metadataMap = {
326+ {" machoplatform" , new Metadata ((uint64_t ) MACHO_PLATFORM_MACOS)},
327+ };
328+ Ref<Metadata> metadata = new Metadata (metadataMap);
329+ Ref<Platform> plat = g_kcViewType->RecognizePlatform (cpuType, GetDefaultEndianness (), this , metadata);
330+ SetDefaultArchitecture (plat->GetArchitecture ());
331+ SetDefaultPlatform (plat);
324332 }
325333 }
326334 else
@@ -329,13 +337,6 @@ bool KernelCacheView::Init()
329337 return false ;
330338 }
331339
332- if (textSegOffset == 0 )
333- {
334- LogError (" Failed to find __TEXT segment" );
335- return false ;
336- }
337-
338-
339340 // Add Mach-O file header type info
340341 EnumerationBuilder cpuTypeBuilder;
341342 cpuTypeBuilder.AddMemberWithValue (" CPU_TYPE_ANY" , MACHO_CPU_TYPE_ANY);
0 commit comments