1

I have a static library objective c with some C functions that I need to modify the behavior of based on the callers. I looked at https://opensource.apple.com/source/dyld/dyld-210.2.3/include/mach-o/dyld-interposing.h and saw that it could be used to essentially "swizzle" C functions.

My question is - will dyld_interpose also interpose the C function in all libraries / frameworks that contain my interposing code?

eg.

Library1 - had C Function

void foo(int bar) {
...
}

Library2 - Has interposing code. Depends on Library1

void my_foo(int bar) {
...
}

DYLD_INTERPOSE(my_foo, foo);

Will Library3 that depends on both Library1 and Library2 be interposed as well? What if it is attached to an application? I've got some success getting it working on an framework.

gran_profaci
  • 8,087
  • 15
  • 66
  • 99
  • There's no DYLD dynamic part when a static library gets linked, it becomes part of your app executable binary itself. Any callers would have to apply the extra logic by themselves (because they are making the direct call to chunk of code, not an indirect one like dynamic dyld functions do through `dyld_stub_binder` trampoline). Perhaps a pointer to C function wrapper would be a viable option in your case for this extra layer of logic. Somewhat related topic https://stackoverflow.com/questions/56880169/replace-static-symbols-in-macos-mach-o-binary-with-external-symbols/56884261#56884261 – Kamil.S Oct 17 '20 at 07:54

0 Answers0