Skip to content

Commit

Permalink
Add name to Library
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 12, 2021
1 parent 21e3355 commit cfb3954
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use ld_so_conf::parse_ldsoconf;
/// A library dependency
#[derive(Debug, Clone)]
pub struct Library {
/// Library name
pub name: String,
/// The path to the library.
pub path: PathBuf,
/// The normalized real path to the library.
Expand Down Expand Up @@ -140,10 +142,17 @@ impl DependencyAnalyzer {
let interpreter = elf.interpreter.map(|interp| interp.to_string());
if let Some(ref interp) = interpreter {
if !libraries.contains_key(interp) {
let interp_path = PathBuf::from(interp);
let interp_name = interp_path
.file_name()
.expect("missing filename")
.to_str()
.expect("Filename isn't valid Unicode");
libraries.insert(
interp.to_string(),
Library {
path: PathBuf::from(interp),
name: interp_name.to_string(),
path: interp_path,
realpath: PathBuf::from(interp).canonicalize().ok(),
needed: Vec::new(),
rpath: Vec::new(),
Expand Down Expand Up @@ -206,7 +215,7 @@ impl DependencyAnalyzer {
Ok(())
}

/// Try to locate a `lib` taht is compatible to `elf`
/// Try to locate a `lib` that is compatible to `elf`
fn find_library(&self, elf: &Elf, lib: &str) -> Result<Option<Library>, Error> {
for ld_path in self
.runpaths
Expand All @@ -223,6 +232,7 @@ impl DependencyAnalyzer {
let needed = lib_elf.libraries.iter().map(ToString::to_string).collect();
let (rpath, runpath) = self.read_rpath_runpath(&lib_elf, &lib_path, &bytes)?;
return Ok(Some(Library {
name: lib.to_string(),
path: lib_path.to_path_buf(),
realpath: lib_path.canonicalize().ok(),
needed,
Expand All @@ -233,6 +243,7 @@ impl DependencyAnalyzer {
}
}
Ok(Some(Library {
name: lib.to_string(),
path: PathBuf::from(lib),
realpath: None,
needed: Vec::new(),
Expand Down

0 comments on commit cfb3954

Please sign in to comment.