Skip to content

Commit

Permalink
skip relinking if it is not a shared library on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 23, 2023
1 parent b6313f8 commit 99f909b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/linux/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub struct SharedObject {
pub rpaths: Vec<String>,
/// RUNPATH entries
pub runpaths: Vec<String>,
/// Whether the shared object is dynamically linked
pub has_dynamic: bool,
}

#[derive(thiserror::Error, Debug)]
Expand Down Expand Up @@ -65,13 +67,19 @@ impl SharedObject {
libraries: elf.libraries.iter().map(|s| s.to_string()).collect(),
rpaths: elf.rpaths.iter().map(|s| s.to_string()).collect(),
runpaths: elf.runpaths.iter().map(|s| s.to_string()).collect(),
has_dynamic: elf.dynamic.is_some(),
})
}

/// find all RPATH and RUNPATH entries
/// replace them with the encoded prefix
/// if the prefix is not found, add it to the end of the list
pub fn relink(&self, prefix: &Path, encoded_prefix: &Path) -> Result<(), RelinkError> {
if !self.has_dynamic {
tracing::debug!("{} is not dynamically linked", self.path.display());
return Ok(());
}

let rpaths = self
.rpaths
.iter()
Expand Down

0 comments on commit 99f909b

Please sign in to comment.