frida / frida-gum

Cross-platform instrumentation and introspection library written in C

Home Page:https://frida.re

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Darwin grafter does not support LC_DYLD_CHAINED_FIXUPS load command

jorgschulze73 opened this issue · comments

Starting with iOS15 Apple got rid of the LC_DYLD_INFO_ONLY load command and replaced it with LC_DYLD_CHAINED_FIXUPS and LC_DYLD_EXPORTS_TRIE commands.

It seems that the Darwin grafter utility does not support these: it's not exactly trivial to add compatibility because dyld will then compare number of segments in the binary with the information contained in the LC_DYLD_CHAINED_FIXUPS header (which is inside __LINKEDIT blob itself), and crash with errors like this in case they don't match:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Description: DYLD, dyld: Using shared cache: B01571EC-0907-3943-BB12-60E6E47E933C | dependent dylib '@rpath/UnityFramework.framework/UnityFramework' not found for '/private/var/containers/Bundle/Application/9FACA36E-E3F8-4869-94A9-5F53051FF902/UnityApp.app/UnityApp'. chained fixups, seg_count does not match number of segments
Highlighted by Thread:  0

It seems that at that point the only solution to actually insert new segments into a Macho binary would involve having to rewrite the whole __LINKEDIT segment and carefully rebasing each data command that's pointing inside of it.

Is there any plans to support this functionality?

Does LIEF have the capability to add sections while fixing up __LINKEDIT? It is Apache 2 licensed.