I have a similar issue, but I think the __dso_handle trick is not fixing it for me.
I have a framework that needs to find a section in the main app binary.
Until now I could use this (simplified) code to achieve this:
uint8_t* get_slided_section_data(const char* seg, const char* sect, size_t* size) {
uint8_t* data = nullptr;
for (unsigned i = 0, n = _dyld_image_count(); i < n && !data; i++) {
const mach_header* header = _dyld_get_image_header(i);
if (header->filetype == MH_EXECUTE) {
data = getsectiondata((mach_header_64*)header, seg, sect, size);
}
}
return data;
}
However, this seems to not work anymore (I assume the same reason as the original issue).
From my understanding, __dso_handle points only to the defining image image start. Since I need to find a section from a framework in the main app binary, this seems not to work.
Is there some way to make this work/achieve the same thing with ENABLE_DEBUG_DYLIB enabled?