fn so_dependencies<S: AsRef<OsStr>>(binary: S) -> Result<Vec<PathBuf>> {
    let binary = Path::new(binary.as_ref());
    let buf =
        std::fs::read(&binary).with_context(|| format!("while reading {}", binary.display()))?;
    let elf =
        Elf::parse(&buf).with_context(|| format!("while parsing ELF {}", binary.display()))?;
    let interpreter = elf.interpreter.unwrap_or("/usr/lib64/ld-linux-x86-64.so.2");

    let output = std::process::Command::new(&interpreter)
        .arg("--list")
        .arg(binary)
        .output()
        .with_context(|| format!("failed to list libraries for {:?}", binary))?;
    let ld_output_str = std::str::from_utf8(&output.stdout).context("ld.so output not utf-8")?;

    Ok(LDSO_RE
        .captures_iter(ld_output_str)
        .map(|cap| {
            let path = Path::new(cap.name("path").unwrap().as_str());
            path.into()
        })
        .collect())
}
/// Look up absolute paths to all (recursive) deps of this binary
Look up absolute paths to all (recursive) deps of this binary
Look up absolute paths to all ( recursive ) deps of this binary
fn so_dependencies<S: AsRef<OsStr>>(binary: S) -> Result<Vec<PathBuf>> {
    let binary = Path::new(binary.as_ref());
    let buf =
        std::fs::read(&binary).with_context(|| format!("while reading {}", binary.display()))?;
    let elf =
        Elf::parse(&buf).with_context(|| format!("while parsing ELF {}", binary.display()))?;
    let interpreter = elf.interpreter.unwrap_or("/usr/lib64/ld-linux-x86-64.so.2");
    let output = std::process::Command::new(&interpreter)
        .arg("--list")
        .arg(binary)
        .output()
        .with_context(|| format!("failed to list libraries for {:?}", binary))?;
    let ld_output_str = std::str::from_utf8(&output.stdout).context("ld.so output not utf-8")?;
    Ok(LDSO_RE
        .captures_iter(ld_output_str)
        .map(|cap| {
            let path = Path::new(cap.name("path").unwrap().as_str());
            path.into()
        })
        .collect())
}
fn so_dependencies < S : AsRef < OsStr > > ( binary : S ) -> Result < Vec < PathBuf > > { let binary = Path :: new ( binary . as_ref ( ) ) ; let buf = std :: fs :: read ( & binary ) . with_context ( | | format ! ( " " binary display ( ) ) ) ? ; let elf = Elf :: parse ( & buf ) . with_context ( | | format ! ( " " binary display ( ) ) ) ? ; let interpreter = elf . interpreter . unwrap_or ( " " ) ; let output = std :: process :: Command :: new ( & interpreter ) . arg ( " " ) . arg ( binary ) . output ( ) . with_context ( | | format ! ( " " binary ) ) ? ; let ld_output_str = std :: str :: from_utf8 ( & output . stdout ) . context ( " " ) ? ; Ok ( LDSO_RE . captures_iter ( ld_output_str ) . map ( | cap | { let path = Path :: new ( cap . name ( " " ) . unwrap ( ) . as_str ( ) ) ; path . into ( ) } ) . collect ( ) ) }
Look up absolute paths to all (recursive) deps of this binary
Look up absolute paths to all ( recursive ) deps of this binary
binary
S
binary
S