From 30099ecd4071fec9d0860424eee8d55a88d1bda0 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Tue, 26 Nov 2024 20:37:31 +0000 Subject: [PATCH] boulder: Fix handling of RPATHS to fix #366 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 --- boulder/src/package/analysis/handler/elf.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/boulder/src/package/analysis/handler/elf.rs b/boulder/src/package/analysis/handler/elf.rs index 08e1b4ee..605ba3d9 100644 --- a/boulder/src/package/analysis/handler/elf.rs +++ b/boulder/src/package/analysis/handler/elf.rs @@ -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, @@ -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); } _ => {} @@ -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 @@ -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 };