Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Copying dylib into bundle & setting dyld_insert_libraries within info.plist to load library. This works with the one issue that I won't be able to control the location of the app/bundle (or library if outside bundle) and relative paths (e.g @executable_path) can't be used in info.plist.

  • Using install_name_tool (-add_rpath, -id, etc) to add a new path to the library. This just doesn't seem to work unless theres a path in there to change. (The name/install location of the library is correct and been checked many times).

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

like image 338
avalore Avatar asked Sep 05 '26 18:09

avalore


1 Answers

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)
 ...
like image 62
Tyilo Avatar answered Sep 07 '26 09:09

Tyilo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!