shared

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//ELFSectionName is the name of our ELF section of "bitcode paths".
	ELFSectionName = ".llvm_bc"

	//DarwinSegmentName is the name of our MACH-O segment of "bitcode paths".
	DarwinSegmentName = "__WLLVM"

	//DarwinSectionName is the name of our MACH-O section of "bitcode paths".
	DarwinSectionName = "__llvm_bc"
)

Variables

View Source
var LLVMARName string

LLVMARName is the user configured name of the llvm-ar.

View Source
var LLVMBitcodeStorePath string

LLVMBitcodeStorePath is the user configured location of the bitcode archive.

View Source
var LLVMCCName string

LLVMCCName is the user configured name of the clang compiler.

View Source
var LLVMCXXName string

LLVMCXXName is the user configured name of the clang++ compiler.

View Source
var LLVMConfigureOnly string

LLVMConfigureOnly is the user configured flag indicating a single pass mode is required.

View Source
var LLVMLINKName string

LLVMLINKName is the user configured name of the llvm-link.

View Source
var LLVMLd string

LLVMLd is the path to the ld executable used to attach the bitcode on OSX.

View Source
var LLVMLoggingFile string

LLVMLoggingFile is the path to the optional logfile (useful when configuring)

View Source
var LLVMLoggingLevel string

LLVMLoggingLevel is the user configured logging level: ERROR, WARNING, INFO, DEBUG.

View Source
var LLVMLtoLDFLAGS []string

LLVMLtoLDFLAGS is the list of extra flags to pass to the linking steps, when under -flto

View Source
var LLVMObjcopy string

LLVMObjcopy is the path to the objcopy executable used to attach the bitcode on *nix.

View Source
var LLVMToolChainBinDir string

LLVMToolChainBinDir is the user configured directory holding the LLVM binary tools.

View Source
var LLVMbcGen []string

LLVMbcGen is the list of args to pass to clang during the bitcode generation step.

View Source
var LogDebug = makeLogger(debugV)

LogDebug logs to the configured stream if the logging level is DEBUG.

View Source
var LogError = makeLogger(errorV)

LogError logs to the configured stream if the logging level is ERROR or lower.

View Source
var LogInfo = makeLogger(infoV)

LogInfo logs to the configured stream if the logging level is INFO or lower.

View Source
var LogWarning = makeLogger(warningV)

LogWarning logs to the configured stream if the logging level is WARNING or lower.

View Source
var LogWrite = makeLogger(-1)

LogWrite writes to the logging stream, irregardless of levels.

Functions

func CheckDefer

func CheckDefer(f func() error)

CheckDefer is used to check the return values of defers

func Compile

func Compile(args []string, compiler string) (exitCode int)

Compile wraps a call to the compiler with the given args.

func Extract

func Extract(args []string) (exitCode int)

Extract extracts the LLVM bitcode according to the arguments it is passed.

func FetchEnvironment added in v1.2.6

func FetchEnvironment()

FetchEnvironment is used in initializing our globals, it is also used in testing

func GetCompilerExecName

func GetCompilerExecName(compiler string) string

GetCompilerExecName returns the full path of the executable

func IsObjectFileForOS added in v1.2.9

func IsObjectFileForOS(objectFile string, operatingSys string) (ok bool, err error)

IsObjectFileForOS returns true if the given file is an object file for the given OS, using the debug/elf and debug/macho packages.

func IsPlainFile added in v1.3.0

func IsPlainFile(objectFile string) (ok bool)

IsPlainFile returns true if the file is stat-able (i.e. exists etc), and is not a directory, else it returns false.

func PrintEnvironment added in v1.2.6

func PrintEnvironment()

PrintEnvironment is used for printing the aspects of the environment that concern us

func ResetEnvironment added in v1.2.6

func ResetEnvironment()

ResetEnvironment resets the globals, it is only used in testing

func SanityCheck

func SanityCheck()

SanityCheck performs the environmental sanity check.

Performs the following checks in order:
0. Check the logging
1. Check that the OS is supported.
2. Checks that the compiler settings make sense.
3. Checks that the needed LLVM utilities exists.
4. Check that the store, if set, exists.

Types

type BinaryType added in v1.2.9

type BinaryType uint32

BinaryType is the 'intersection' of elf.Type and macho.Type and partitions the binary world into categories we are most interested in. Missing is ARCHIVE but that is because it is not an elf format, so we cannot entirely eliminate the use of the 'file' utility (cf getFileType below).

const (
	//BinaryUnknown signals that the file does not fit into our three simple minded categories
	BinaryUnknown BinaryType = 0
	//BinaryObject is the type of an object file, the output unit of compilation
	BinaryObject BinaryType = 1
	//BinaryExecutable is the type of an executable file
	BinaryExecutable BinaryType = 2
	//BinaryShared is the type of a shared or dynamic library
	BinaryShared BinaryType = 3
)

func ElfFileType added in v1.2.9

func ElfFileType(objectFile string) (code BinaryType, err error)

ElfFileType returns the elf.Type of the given file name

func GetBinaryType added in v1.3.0

func GetBinaryType(path string) (bt BinaryType)

GetBinaryType gets the binary type of the given path

func MachoFileType added in v1.2.9

func MachoFileType(objectFile string) (code BinaryType, err error)

MachoFileType returns the macho.Type of the given file name

func (BinaryType) String added in v1.3.0

func (bt BinaryType) String() string

type ExtractionArgs added in v1.2.6

type ExtractionArgs struct {
	Failure             bool // indicates failure in parsing the cmd line args
	Verbose             bool // inform the user of what is going on
	WriteManifest       bool // write a manifest of bitcode files used
	SortBitcodeFiles    bool // sort the arguments to linking and archiving (debugging too)
	BuildBitcodeModule  bool // buld an archive rather than a module
	KeepTemp            bool // keep temporary linking folder
	StrictExtract       bool // turn extraction failures into errors
	LinkArgSize         int  // maximum size of a llvm-link command line
	InputType           int
	ObjectTypeInArchive int // Type of file that can be put into an archive
	InputFile           string
	OutputFile          string
	LlvmLinkerName      string
	LlvmArchiverName    string
	ArchiverName        string
	ArArgs              []string
	Extractor           func(string) ([]string, bool)
}

ExtractionArgs encapsulate the results of parsing the commandline options

func ParseSwitches added in v1.2.6

func ParseSwitches(args []string) (ea ExtractionArgs)

ParseSwitches parses the command line into an ExtractionArgs object.

func (ExtractionArgs) String added in v1.2.6

func (ea ExtractionArgs) String() string

for printing out the parsed arguments, some have been skipped.

type ParserResult added in v1.2.8

type ParserResult struct {
	InputList        []string
	InputFiles       []string
	ObjectFiles      []string
	OutputFilename   string
	CompileArgs      []string
	LinkArgs         []string
	ForbiddenFlags   []string
	IsVerbose        bool
	IsDependencyOnly bool
	IsPreprocessOnly bool
	IsAssembleOnly   bool
	IsAssembly       bool
	IsCompileOnly    bool
	IsEmitLLVM       bool
	IsLTO            bool
	IsPrintOnly      bool
}

ParserResult is the result of parsing and partioning the command line arguments.

func Parse added in v1.2.8

func Parse(argList []string) ParserResult

Parse analyzes the command line aruguments and returns the result of that analysis.

func (*ParserResult) SkipBitcodeGeneration added in v1.2.8

func (pr *ParserResult) SkipBitcodeGeneration() bool

SkipBitcodeGeneration indicates whether or not we should generate bitcode for these command line options.

func (*ParserResult) String added in v1.2.8

func (pr *ParserResult) String() string

Jump to

Keyboard shortcuts

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