1 unstable release
new 0.0.1 | Mar 7, 2025 |
---|---|
0.0.0 |
|
#27 in #mach-o
95 downloads per month
565KB
2K
SLoC
Contains (ELF exe/lib, 1MB) tests/elf/linux-x64-bash, (Mach-o exe, 34KB) tests/data/hello_with_rpath, (Mach-o library, 34KB) tests/data/libmylib.dylib, (Mach-o exe, 50KB) tests/data/x32/ls, (Mach-o exe, 34KB) tools/bins/hello_with_rpath, (Mach-o exe, 36KB) tools/clang/x32/MachO-OSX-x86-ls and 6 more.
arwen: Cross-Platform Binary Patching Tool for Mach-O and ELF in Rust
Overview
arwen
is a cross-platform Rust implementation that combines functionality similar to patchelf
(Linux) and install_name_tool
(macOS) into a single, versatile tool for binary manipulation.
Installation
You can install arwen
using Cargo:
cargo install arwen
Usage
Mach-O Commands
RPath Operations
# Add an RPath
arwen macho add-rpath /usr/local/lib my_binary
# Change an existing RPath
arwen macho change-rpath /old/path /new/path my_binary
# Delete an RPath
arwen macho delete-rpath /unwanted/path my_binary
Library Install Name and library id Operations
# Change library install name
arwen macho change-install-name /old/libname.dylib /new/libname.dylib my_binary
# Change install ID of a shared library
arwen macho change-install-id /new/install/id.dylib my_library.dylib
ELF Commands
Interpreter Operations
# Set ELF interpreter
arwen elf set-interpreter /path/to/new/interpreter my_elf_binary
# Print current interpreter
arwen elf print-interpreter my_elf_binary
ELF Header Operations
# Print OS ABI
arwen elf print-os-abi my_elf_binary
# Set OS ABI
arwen elf set-os-abi solaris my_elf_binary
RPATH Operations
# Set RPATH
arwen elf set-rpath /path1:/path2 my_elf_binary
# Add RPATH
arwen elf add-rpath /additional/path my_elf_binary
# Remove RPATH
arwen elf remove-rpath my_elf_binary
# Print current RPATH
arwen elf print-rpath my_elf_binary
# Shrink RPATH with allowed prefixes
arwen elf shrink-rpath --allowed-prefixes /usr/lib:/local/lib my_elf_binary
Dependency Management
# Add a needed library
arwen elf add-needed my_elf_binary libexample.so libotherexample.so
# Remove a needed library
arwen elf remove-needed my_elf_binary libexample.so libotherexample.so
# Replace a needed library
arwen elf replace-needed my_elf_binary old_lib.so new_lib.so
# Print needed libraries
arwen elf print-needed my_elf_binary
Executable Stack Control
# Check executable stack status
arwen elf print-exec-stack my_elf_binary
# Clear executable stack
arwen elf clear-exec-stack my_elf_binary
# Set executable stack
arwen elf set-exec-stack my_elf_binary
Symbol and Soname Operations
# Print soname
arwen elf print-soname my_elf_binary
# Set soname
arwen elf set-soname new_soname my_elf_binary
# Clear symbol version
arwen elf clear-symbol-version symbol_name my_elf_binary
# Rename dynamic symbols (using a map file)
arwen elf rename-dynamic-symbols symbol_map.txt my_elf_binary
Post-Modification Considerations
Mach-O Re-signing (macOS)
After modifying a Mach-O binary, re-sign it:
codesign --force --sign - my_binary
Integration Tests
We have comprehensive integration tests to validate feature parity with install_name_tool
and patchelf
, ensuring correctness and reliability.
License
arwen
is licensed under the MIT license.
Contributions
Contributions are welcome! Feel free to open issues or submit pull requests.
Status
arwen
is currently in active development. The API
and CLI
are subject to change to improve user experience.
Funding
This project is funded through NGI0 Entrust, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program.
Learn more at the NLnet project page.
Dependencies
~4MB
~78K SLoC