avalore
avalore

Reputation: 103

Inserting dylib into existing bundle/executable

I have an existing bundle/executable, which I need to add a new dylib into.

Methods I've already tried:

Are there any further solutions to this problem or even modifications on the solutions (above) that I've already tried?

Upvotes: 3

Views: 2014

Answers (2)

Tyilo
Tyilo

Reputation: 30102

I've made a tool that can do that called insert_dylib: https://github.com/Tyilo/insert_dylib

Here's the usage info:

Usage: insert_dylib [--inplace] [--weak] dylib_path binary_path [new_path]

And how to use it:

 $ insert_dylib /usr/lib/libfoo.dylib test
 The provided dylib path doesn't exist. Continue anyway? [y/n] y
 Added LC_LOAD_DYLIB command to test_patched
 $ diff -u <(otool -hl test) <(otool -hl test_patched)
 ...

Upvotes: 3

Magnus Reftel
Magnus Reftel

Reputation: 1009

You can also set the environment variable DYLD_INSERT_LIBRARIES to point the library you want to inject when executing the binary. See https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man1/dyld.1.html for details.

Upvotes: 0

Related Questions