Closed simba909 closed 2 years ago
@bogo @simba909 I've just arrived at this exact conclusion independently - this looks like a correct change! 💪🏻
This is a great find, thank you so much for contributing @simba909 and @igor-makarov!
@bogo I discovered that sections of types S_GB_ZEROFILL
and S_THREAD_LOCAL_ZEROFILL
should also be excluded from offset patching.
Только что собрал на CodeMagic для Flutter: cocoapods (1.11.2) Xcode 13.0 yandex_mapkit 2.0.6 --> YandexMapMobile 4.0.0.-full
First off, the work done here is absolutely fantastic! 👏🏻 Never got it to fully work for my use-case in the past but with the recent release of Xcode 13.3 beta 1 I could finally get a hint as to what was wrong with my initial attempt:
After a few minutes of thinking I brought out
otool
and had a look. Here's the__DATA
section:It indeed has a non-zero offset and judging by that above error (which I might be reading too much into..) it shouldn't have. Now I just needed to figure out how the tool would be able to know that 🤔
After some sleuthing I realised that the
flags 0x00000001
is the key - if it's set to 1 then it matches theS_ZEROFILL
constant from MachO.loader. Using this info the offset-manipulating code can be changed to avoid setting the offset if theS_ZEROFILL
flag is set:Much to my surprise the above seems to work and the error in Xcode is gone! This also makes the resulting library work for my use-case 🎉
I do realise that the solution might be a bit naïve; it should probably do some bitmask checking on the flags to see if the
S_ZEROFILL
flag is set but that didn't seem to be necessary at least for my use-case 🤔