Skip to content

Commit

Permalink
boulder: Also handle DT_RUNPATH in conjunction with DT_RPATH...
Browse files Browse the repository at this point in the history
Signed-off-by: Ikey Doherty <ikey@serpentos.com>
  • Loading branch information
ikeycode committed Nov 27, 2024
1 parent f721100 commit 83f1084
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions boulder/src/package/analysis/handler/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use elf::{
abi::{DT_NEEDED, DT_RPATH, DT_SONAME},
abi::{DT_NEEDED, DT_RPATH, DT_RUNPATH, DT_SONAME},
endian::AnyEndian,
file::Class,
note::Note,
Expand Down Expand Up @@ -100,6 +100,7 @@ fn parse_dynamic_section(
let mut needed_offsets = vec![];
let mut soname_offset = None;
let mut rpath_offset = vec![];
let mut runpath_offset = vec![];

// i.e `/` `usr` `lib` `libfoo.so.1.2.3`
let in_root_tree = info.target_path.ancestors().skip(1).count() == 3;
Expand All @@ -117,6 +118,9 @@ fn parse_dynamic_section(
DT_RPATH => {
rpath_offset.push(entry.d_val() as usize);
}
DT_RUNPATH => {
runpath_offset.push(entry.d_val() as usize);
}
_ => {}
}
}
Expand Down Expand Up @@ -145,13 +149,14 @@ fn parse_dynamic_section(
.and_then(|p| p.to_str())
.unwrap_or("/mason/install");

// rpath list
for offset in rpath_offset {
if let Ok(val) = strtab.get(offset) {
for path in val.split(':') {
let path = path.replace("$ORIGIN", &origin);
rpaths.push(path);
}
for rpath in runpath_offset
.iter()
.chain(rpath_offset.iter())
.filter_map(|v| strtab.get(*v).ok())
{
for path in rpath.split(':') {
let path = path.replace("$ORIGIN", &origin);
rpaths.push(path);
}
}

Expand Down

0 comments on commit 83f1084

Please sign in to comment.