Skip to content

Commit

Permalink
boulder: Fix handling of RPATHS to fix #366
Browse files Browse the repository at this point in the history
Previously we made some incorrect allowances, which basically meant
checking libdir multiple times when we shouldn't. We also previously
forbid libraries in libdir from linking via RPATH, which is actually
required for mutter to function.

Lastly fix an awkward typo when we meant to use DT_RPATH but somehow
used DT_RUNPATH. >_>

Signed-off-by: Ikey Doherty <ikey@serpentos.com>
  • Loading branch information
ikeycode committed Nov 26, 2024
1 parent f9601d6 commit 30099ec
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 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_RUNPATH, DT_SONAME},
abi::{DT_NEEDED, DT_RPATH, DT_SONAME},
endian::AnyEndian,
file::Class,
note::Note,
Expand Down Expand Up @@ -114,7 +114,7 @@ fn parse_dynamic_section(
DT_SONAME => {
soname_offset = Some(entry.d_val() as usize);
}
DT_RUNPATH => {
DT_RPATH => {
rpath_offset.push(entry.d_val() as usize);
}
_ => {}
Expand All @@ -134,14 +134,8 @@ fn parse_dynamic_section(
// Resolve offsets against string table and add the applicable
// depends and provides
if let Ok(Some((_, strtab))) = elf.dynamic_symbol_table() {
let libdir = if matches!(bit_size, Class::ELF64) {
"/usr/lib"
} else {
"/usr/lib32"
};

let origin = info.target_path.parent().unwrap().to_string_lossy().to_string();
let mut rpaths = vec![libdir.into(), origin.clone()];
let mut rpaths = vec![];

let root_dir = info
.path
Expand Down Expand Up @@ -181,13 +175,8 @@ fn parse_dynamic_section(
}
});

// ignore RPATH if in root tree
let picked = if let Some(rpath_name) = rpath_name.as_ref() {
if in_root_tree {
name
} else {
&rpath_name.to_string_lossy().to_string()
}
&rpath_name.to_string_lossy().to_string()
} else {
name
};
Expand Down

0 comments on commit 30099ec

Please sign in to comment.