ldd

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2021 License: BSD-3-Clause Imports: 7 Imported by: 118

Documentation

Overview

ldd returns all the library dependencies of an executable.

The way this is done on GNU-based systems is interesting. For each ELF, one finds the .interp section. If there is no interpreter there's not much to do.

If there is an interpreter, we run it with the --list option and the file as an argument. We need to parse the output.

For all lines with => as the 2nd field, we take the 3rd field as a dependency. The field may be a symlink. Rather than stat the link and do other such fooling around, we can do a readlink on it; if it fails, we just need to add that file name; if it succeeds, we need to add that file name and repeat with the next link in the chain. We can let the kernel do the work of figuring what to do if and when we hit EMLINK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInterp

func GetInterp(file string) (string, error)

func LdSo

func LdSo(bit64 bool) (string, error)

LdSo finds the loader binary.

func List

func List(names []string) ([]string, error)

List returns the dependency file paths of files in names.

Types

type FileInfo

type FileInfo struct {
	FullName string
	os.FileInfo
}

func Ldd

func Ldd(names []string) ([]*FileInfo, error)

Ldd returns a list of all library dependencies for a set of files.

If a file has no dependencies, that is not an error. The only possible error is if a file does not exist, or it says it has an interpreter but we can't read it, or we are not able to run its interpreter.

It's not an error for a file to not be an ELF.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL