From c3ced3ba991b938710c91c51631f52e5fa1838db Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 5 Dec 2021 20:29:22 +0800 Subject: [PATCH] Update docs --- src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index efb21ce..5fe3bf0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,7 @@ +//! Read the ELF dependency tree. +//! +//! This does not work like `ldd` in that we do not execute/load code (only read +//! files on disk). use std::collections::HashMap; use std::env; use std::path::{Path, PathBuf}; @@ -16,21 +20,31 @@ pub mod ld_so_conf; pub use errors::Error; use ld_so_conf::parse_ldsoconf; +/// A library dependency #[derive(Debug, Clone)] pub struct Library { + /// The path to the library. pub path: PathBuf, + /// The dependencies of this library. pub needed: Vec, } +/// Library dependency tree #[derive(Debug, Clone)] pub struct DependencyTree { + /// The binary’s program interpreter (e.g., dynamic linker). pub interpreter: Option, + /// A list of this binary’s dynamic libraries it depends on directly. pub needed: Vec, + /// All of this binary’s dynamic libraries it uses in detail. pub libraries: HashMap, + /// Runtime library search paths. (deprecated) pub rpath: Vec, + /// Runtime library search paths. pub runpath: Vec, } +/// Library dependency analyzer #[derive(Debug, Clone)] pub struct DependencyAnalyzer { env_ld_paths: Vec, @@ -39,6 +53,7 @@ pub struct DependencyAnalyzer { } impl DependencyAnalyzer { + /// Create a new dependency analyzer. pub fn new() -> DependencyAnalyzer { DependencyAnalyzer { env_ld_paths: Vec::new(), @@ -47,6 +62,7 @@ impl DependencyAnalyzer { } } + /// Analyze the given binary. pub fn analyze(&mut self, path: impl AsRef) -> Result { let path = path.as_ref(); self.load_ld_paths(path)?;