Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rpaths to MachO #248

Merged
merged 1 commit into from Jan 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/mach/mod.rs
Expand Up @@ -64,6 +64,8 @@ pub struct MachO<'a> {
pub symbols: Option<symbols::Symbols<'a>>,
/// The dylibs this library depends on
pub libs: Vec<&'a str>,
/// The runtime search paths for dylibs this library depends on
pub rpaths: Vec<&'a str>,
/// The entry point (as a virtual memory address), 0 if none
pub entry: u64,
/// Whether `entry` refers to an older `LC_UNIXTHREAD` instead of the newer `LC_MAIN` entrypoint
Expand Down Expand Up @@ -163,6 +165,7 @@ impl<'a> MachO<'a> {
let mut cmds: Vec<load_command::LoadCommand> = Vec::with_capacity(ncmds);
let mut symbols = None;
let mut libs = vec!["self"];
let mut rpaths = vec![];
let mut export_trie = None;
let mut bind_interpreter = None;
let mut unixthread_entry_address = None;
Expand Down Expand Up @@ -191,6 +194,10 @@ impl<'a> MachO<'a> {
let lib = bytes.pread::<&str>(cmd.offset + command.dylib.name as usize)?;
libs.push(lib);
}
load_command::CommandVariant::Rpath(command) => {
let rpath = bytes.pread::<&str>(cmd.offset + command.path as usize)?;
rpaths.push(rpath);
}
load_command::CommandVariant::DyldInfo(command)
| load_command::CommandVariant::DyldInfoOnly(command) => {
export_trie = Some(exports::ExportTrie::new(bytes, &command));
Expand Down Expand Up @@ -248,6 +255,7 @@ impl<'a> MachO<'a> {
segments,
symbols,
libs,
rpaths,
export_trie,
bind_interpreter,
entry,
Expand Down