lddx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectDeps

func CollectDeps(graph *DependencyGraph, opts *CollectorOptions) error

func DepsPrettyPrint

func DepsPrettyPrint(dep *Dependency)

DepsPrettyPrint prints a dependency graph in a format similar to the output from ldd.

func FindFatMachOFiles

func FindFatMachOFiles(folder string) ([]string, error)

FindFatMachOFiles will recursively search the specified folder for Fat files or Mach-O files. Symlinked folders are ignored.

func FixupToplevels

func FixupToplevels(graph *DependencyGraph, opts *CollectorOptions) error

func IsFatMachO

func IsFatMachO(file string) (bool, error)

IsFatMachO reads the first four bytes of the given file to determine if it is either a Mach-O or Universal (fat) file. On error, the result is false, and the error value is also returned.

func IsSpecialPath

func IsSpecialPath(path string) bool

func LogError

func LogError(format string, args ...interface{})

LogError logs an error message

func LogInfo

func LogInfo(format string, args ...interface{})

LogInfo logs an info message

func LogInit

func LogInit(noColor, quiet bool)

LogInit initialises the logger

func LogNote

func LogNote(format string, args ...interface{})

LogNote logs a note message

func LogWarn

func LogWarn(format string, args ...interface{})

LogWarn logs a warning message

func ResolveAbsPath

func ResolveAbsPath(path string) (string, error)

ResolveAbsPath resolves a given filepath to an absolute path, following symlinks if necessary.

Types

type ArchType

type ArchType struct {
	Cpu    macho.Cpu // Architecture type (e.g. PPC, i386, amd64, arm)
	SubCpu uint32    // ???
}

type ByPath

type ByPath []*Dependency

ByPath sorts a Dependency slice by the Path field

func (ByPath) Len

func (v ByPath) Len() int

Len returns the length of the slice

func (ByPath) Less

func (v ByPath) Less(i, j int) bool

Less compares the Path fields of two entries in the slice

func (ByPath) Swap

func (v ByPath) Swap(i, j int)

Swap swaps two values in the slice

type CollectorOptions

type CollectorOptions struct {
	Folder             string   // The folder to dump libraries into
	PreferredOrder     []string // If there are library conflicts, this specifies an order to choose from
	Overwrite          bool     // Whether or not to overwrite existing deps
	ModifySpecialPaths bool     // Whether or not to modify paths beginnig with @, e.g. @executable_path
	CollectFrameworks  bool     // Whether or not to also collect frameworks
	Jobs               int      // Number of concurrent jobs
}

CollectorOptions specifies the options for the collector

type Dependency

type Dependency struct {
	Name             string         // The name of the library
	Path             string         // The path to the library, as specified by the load command
	RealPath         string         // The real path to the library, if available (or same as Path)
	Info             string         // Compatibility and current version info
	Pruned           bool           // Indicates if checking the dependencies of this library were skipped
	PrunedByFlatDeps bool           // Indicates if the libs were removed because they were listed in another subtree (for JSON serialisation only)
	NotResolved      bool           // Indicates if the dependencies could not be resolved (could not determine dependencies)
	IsWeakDep        bool           // Indicates if this dependency is from a weak load command
	Deps             *[]*Dependency // List of dependencies that this dependency depends on. Ugh we need these pointers because multiple Dependencies can share this.
	RPaths           []string       // The rpaths associated with this file
}

Dependency contains information about a file and any dependencies that it has.

type DependencyGraph

type DependencyGraph struct {
	TopDeps  []*Dependency          // Slice of top level dependencies
	FlatDeps map[string]*Dependency // Contains all unique, non-pruned referenced dependencies
	// contains filtered or unexported fields
}

DependencyGraph contains information about the dependencies for a collection of files.

func DepsGetJSONSerialisableVersion

func DepsGetJSONSerialisableVersion(graph *DependencyGraph) *DependencyGraph

DepsGetJSONSerialisableVersion returns a dependency graph that's amenable to serialisation. The graph emitted from DepsRead reuses pointers for subtrees to save on computation time. However, on JSON serialisation, this causes subtrees to potentially be repeated over and over again. This method ensures that in a dependency graph, dependencies are only emitted once.

func DepsRead

func DepsRead(opts DependencyOptions, files ...string) (*DependencyGraph, error)

DepsRead calculates the dependency graph for the list of files provided.

type DependencyOptions

type DependencyOptions struct {
	ExecutablePath  string
	IgnoredPrefixes []string
	IgnoredFiles    []string
	Recursive       bool
	SkipWeakLibs    bool
	Jobs            int
}

DependencyOptions specifies the options to be used while calculating the dependency graph.

type Dylib

type Dylib struct {
	Path           string    // The path to the library
	Time           uint32    // Time of library
	CurrentVersion uint32    // Library version
	CompatVersion  uint32    // Compatibility version
	Weak           bool      // Whether this is a weakly loaded library
	Arch           *ArchType // Architecture type
}

func GetDylibInfo added in v0.1.0

func GetDylibInfo(file string) ([]Dylib, error)

GetDylibInfo gets information about the file itself, if available. For example, if the file is a dylib, it returns information about the Dylib itself.

func ReadDylibs

func ReadDylibs(file string, limiter chan int) ([]Dylib, []string, error)

ReadDylibs returns the list of dynamic libraries referenced by a file. The file may either be a fat file or a normal Mach-O file. This method will search for both normal libs and weakly loaded libs.

func TryParseLoadCmd added in v0.1.0

func TryParseLoadCmd(loadCmd macho.LoadCmd, data []byte, byteOrder binary.ByteOrder) (*Dylib, error)

TryParseLoadCmd attempts to read information about a given load command. This code is based on the LoadCmdDylib loader code in debug/macho.

Jump to

Keyboard shortcuts

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