Closed 0cyn closed 2 years ago
Okay, I believe this was introduced in iOS 15 beta. The Dyld Shared Cache (DSC) seems to be split into separate files, i.e.
Looking at the header of each of these, we can find out a few things.
Basically different elements are separated, for example, all the local symbols are stored in the ".symbols" file. Also by examining the dyld source code, it's likely that the mapping info (located with mappingOffset) is placed directly after the header. Currently, the size of the header is 320 bytes, but the mappingOffset is set to 456, which means that we are missing some fields in the new header.
Unfortunately, until Apple open sources their new format, It would be hard to add support for this.
Got 3 new header fields so far - https://github.com/blacktop/ipsw/blob/master/hack/extras/Dyld.bt (14 more to go)
Interesting! Did you disassemble dyld to get the size of the new fields? Until the actual release of the code, I guess I can look further into it.
I was going to do that eventually, I am mostly using 010 Editor to jump around and make guesses at what the fields are, if they fields made sense as uint64 or uint32 etc is a try and guess procedure right now, but it got me 3 fields so far ;) There are so MANY new fields, this seems like a pretty big change, but it is very strange that they would move imagesOffset
and imagesCount
to the bottom and still keep the old field around?? An associate on twitter took the linkers WWDC 2021 lab and they said the in-memory cache will always look the same, but the on-disk might change (meaning that this new format is in flux??) 🤷
As for keeping the old field around, I think it's for some cross-compatibility so that older dyld loaders could still make sense of newer caches. Like it would be better for an older loader to read the imageOffset
as 0 instead of a new value meant for a different field. But given apple's method of bundling both the loader and the cache together in the IPSW file, it wouldn't make too much of a difference.
Also, it doesn't make sense that they would just move the dyld_cache_image_info
structure without some reason. Maybe they did something similar to dyld_cache_mapping_info
and dyld_cache_mapping_and_slide_info
, where this new image info structure contains more fields.
If possible can you link the Twitter conversation or elaborate more on it?
got another field: (and correct name for "numSplits"
<SNIP>
uint32 numSubCaches; // number of dyld_shared_cache .1,.2,.3 files
Uuid symbolSubCacheUUID; // unique value for .symbols sub-cache
<SNIP>
Nice! how are you getting these field names?
RE of dsc_extractor.bundle
There is also a comparison of subcache UUIDs at the uint32 right above the numSubCaches
field, but I am confused if it is a "partial UUID?" or just an ID? but there are all the same for the dsc and the dsc.1, dsc.2 etc. but it refers to it as a UUID which needs 16bytes ??
Got a few more fields, but they are kinda strange, this format feels un-finalized 🤷
It might be a beta thing. They might not adopt this format for early iOS 15 releases.
I've been meaning to blog about my findings for a while, but I've realized I write english like a complete moron. In the mean time I hope this makes sense to people?
https://github.com/NationalSecurityAgency/ghidra/pull/3666#issuecomment-976151215
This is really helpful, I’ll see what I can do with DyldExtractor when I get the chance.
I uploaded a beta branch here. It contains all the fixes for the new format, I'm just doing a lot of bug fixes now.
iOS 15 caches are now supported with version 2.0.0!
latest revision has completely changed the format of the shared cache which may end up requiring a rewrite or seperate project to tackle. Here's a spot to compile info on the topic.