Skip to content

Commit

Permalink
Add rpaths to MachO
Browse files Browse the repository at this point in the history
  • Loading branch information
keith authored and m4b committed Jan 4, 2021
1 parent 15e99d0 commit c1d6838
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit c1d6838

Please sign in to comment.