Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip relinking if it is not a shared library on linux #443

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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