dyld-shared-cache-big-sur
dyld-shared-cache-big-sur copied to clipboard
Fix data rebasing
Per discussion in #2 here are the changes I've made. I don't know if its useful or not, but feel free to disregard if it isn't. I think it should fix up the objective-c things you were already doing, but should more generically fix up pointers found in __DATA as well as symbols.
Here are some notes:
- My c++ is terrible; I'm really sorry
- This is an adaptation of the work done in https://github.com/zhuowei/dsc_extractor_badly
- The important, but not obvious parts are changes made to structures in
launch-cache/dyld_cache_format.h, especially location of undocumented mapping structs that point to slide info structs - There is a bunch of stuff that this doesn't do correctly, including:
- There are broken references from
__TEXTto__DATA - Some libraries, such as
libswiftSceneKitare almost complete nonsense
- There are broken references from
- It would be worth looking at the objective-c stuff in
dsc_extractor_badly, as I didn't integrate that. The specific library I cared about wasn't obj-c
Let me know if I can help or if there are things here I can help explain
Thank you! Excited to finally take a look at this.
This will segfault while parsing libraries with no __DATA section, of which there are a few.
A fix:
//dsc_extractor.cpp
-- auto ret = slideOneSegment(dataSeg, 1, saved_vmaddrs[1], section_adjustments);
++ const macho_segment_command<P> *dataSeg = mh->getSegment("__DATA");
++ if(!dataSeg) {
++ return static_cast<std::vector<uint8_t>>(NULL);
++ }
++ auto ret = slideOneSegment(dataSeg, 1, saved_vmaddrs[1], section_adjustments);