Skip to content
/ arwen Public

cross-platform patching of the shared libraries in rust ( patchelf && install_name_tool )

License

Notifications You must be signed in to change notification settings

nichmor/arwen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b0bb68c · Mar 21, 2025

History

79 Commits
Mar 21, 2025
Mar 21, 2025
Mar 21, 2025
Mar 21, 2025
Feb 9, 2025
Jan 18, 2025
Mar 4, 2025
Mar 4, 2025
Mar 21, 2025
Mar 21, 2025
Mar 4, 2025
Jan 18, 2025
Mar 4, 2025
Mar 21, 2025
Mar 21, 2025
Mar 21, 2025

Repository files navigation

Pixi Badge

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.

NLnet foundation logo

NGI Zero Logo

About

cross-platform patching of the shared libraries in rust ( patchelf && install_name_tool )

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages