Skip to content

Commit 5a5426d

Browse files
committed
[SharedCache] Vision Pro, tvOS, iOS Simulator support
1 parent ac0fe22 commit 5a5426d

File tree

3 files changed

+69
-31
lines changed

3 files changed

+69
-31
lines changed

view/sharedcache/core/DSCView.cpp

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ DSCView::~DSCView()
3535
enum DSCPlatform {
3636
DSCPlatformMacOS = 1,
3737
DSCPlatformiOS = 2,
38+
DSCPlatformTVOS = 3,
39+
DSCPlatformWatchOS = 4,
40+
DSCPlatformBridgeOS = 5, // T1/T2 APL1023/T8012, this is your touchbar/touchid in intel macs. Similar to watchOS.
41+
// DSCPlatformMacCatalyst = 6,
42+
DSCPlatformiOSSimulator = 7,
43+
DSCPlatformTVOSSimulator = 8,
44+
DSCPlatformWatchOSSimulator = 9,
45+
DSCPlatformVisionOS = 11, // Apple Vision Pro
46+
DSCPlatformVisionOSSimulator = 12 // Apple Vision Pro Simulator
3847
};
3948

4049
bool DSCView::Init()
@@ -47,21 +56,29 @@ bool DSCView::Init()
4756
char magic[17];
4857
GetParentView()->Read(&magic, 0, 16);
4958
magic[16] = 0;
50-
if (platform == DSCPlatformMacOS)
59+
switch (platform)
5160
{
52-
os = "mac";
53-
}
54-
else if (platform == DSCPlatformiOS)
55-
{
56-
os = "ios";
57-
}
58-
else
59-
{
60-
LogError("Unknown platform: %d", platform);
61-
return false;
61+
case DSCPlatformMacOS:
62+
case DSCPlatformTVOS:
63+
case DSCPlatformTVOSSimulator:
64+
os = "mac";
65+
break;
66+
case DSCPlatformiOS:
67+
case DSCPlatformiOSSimulator:
68+
case DSCPlatformVisionOS:
69+
case DSCPlatformVisionOSSimulator:
70+
os = "ios";
71+
break;
72+
// armv7 or slide info v1 (unsupported)
73+
case DSCPlatformWatchOS:
74+
case DSCPlatformWatchOSSimulator:
75+
case DSCPlatformBridgeOS:
76+
default:
77+
LogError("Unknown platform: %d", platform);
78+
return false;
6279
}
6380

64-
if (std::string(magic) == "dyld_v1 arm64" || std::string(magic) == "dyld_v1 arm64e")
81+
if (std::string(magic) == "dyld_v1 arm64" || std::string(magic) == "dyld_v1 arm64e" || std::string(magic) == "dyld_v1arm64_32")
6582
{
6683
arch = "aarch64";
6784
}

view/sharedcache/core/SharedCache.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -576,31 +576,36 @@ void SharedCache::PerformInitialLoad()
576576
}
577577

578578
// Load .symbols subcache
579+
try {
580+
auto subCachePath = path + ".symbols";
581+
auto subCacheFile = MMappedFileAccessor::Open(m_dscView, m_dscView->GetFile()->GetSessionId(), subCachePath)->lock();
579582

580-
auto subCachePath = path + ".symbols";
581-
auto subCacheFile = MMappedFileAccessor::Open(m_dscView, m_dscView->GetFile()->GetSessionId(), subCachePath)->lock();
583+
dyld_cache_header subCacheHeader {};
584+
uint64_t headerSize = subCacheFile->ReadUInt32(16);
585+
if (headerSize > sizeof(dyld_cache_header))
586+
{
587+
m_logger->LogDebug("Header size is larger than expected (0x%llx), using default size (0x%llx)", headerSize,
588+
sizeof(dyld_cache_header));
589+
headerSize = sizeof(dyld_cache_header);
590+
}
591+
subCacheFile->Read(&subCacheHeader, 0, headerSize);
582592

583-
dyld_cache_header subCacheHeader {};
584-
uint64_t headerSize = subCacheFile->ReadUInt32(16);
585-
if (headerSize > sizeof(dyld_cache_header))
586-
{
587-
m_logger->LogDebug("Header size is larger than expected (0x%llx), using default size (0x%llx)", headerSize,
588-
sizeof(dyld_cache_header));
589-
headerSize = sizeof(dyld_cache_header);
590-
}
591-
subCacheFile->Read(&subCacheHeader, 0, headerSize);
593+
dyld_cache_mapping_info subCacheMapping {};
594+
BackingCache subCache;
592595

593-
dyld_cache_mapping_info subCacheMapping {};
594-
BackingCache subCache;
596+
for (size_t j = 0; j < subCacheHeader.mappingCount; j++)
597+
{
598+
subCacheFile->Read(&subCacheMapping, subCacheHeader.mappingOffset + (j * sizeof(subCacheMapping)),
599+
sizeof(subCacheMapping));
600+
subCache.mappings.push_back(subCacheMapping);
601+
}
595602

596-
for (size_t j = 0; j < subCacheHeader.mappingCount; j++)
603+
MutableState().backingCaches.push_back(std::move(subCache));
604+
}
605+
catch (...)
597606
{
598-
subCacheFile->Read(&subCacheMapping, subCacheHeader.mappingOffset + (j * sizeof(subCacheMapping)),
599-
sizeof(subCacheMapping));
600-
subCache.mappings.push_back(subCacheMapping);
607+
m_logger->LogWarn("Failed to locate .symbols subcache. Non-exported symbol information may be missing.");
601608
}
602-
603-
MutableState().backingCaches.push_back(std::move(subCache));
604609
break;
605610
}
606611
case iOS16CacheFormat:

view/sharedcache/core/SharedCache.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ namespace SharedCacheCore {
127127
dyld_cache_mapping_info mappingInfo;
128128
};
129129

130+
struct dyld_cache_slide_info
131+
{
132+
uint32_t version;
133+
uint32_t toc_offset;
134+
uint32_t toc_count;
135+
uint32_t entries_offset;
136+
uint32_t entries_count;
137+
uint32_t entries_size;
138+
// uint16_t toc[toc_count];
139+
// entrybitmap entries[entries_count];
140+
};
141+
142+
struct dyld_cache_slide_info_entry {
143+
uint8_t bits[4096/(8*4)]; // 128-byte bitmap
144+
};
145+
130146
struct PACKED_STRUCT dyld_cache_mapping_and_slide_info
131147
{
132148
uint64_t address;

0 commit comments

Comments
 (0)