Documentation ¶
Overview ¶
Package ainur provides functions for examining ELF files
Index ¶
- Variables
- func Compiler(f *elf.File) string
- func DVer(f *elf.File) (ver string)
- func Describe(m elf.Machine) string
- func Examine(filename string) (string, error)
- func ExamineStatic(filename string) (bool, error)
- func FirstIsGreater(a, b string) bool
- func GCCVer(f *elf.File) (ver string)
- func GHCVer(f *elf.File) (ver string)
- func GoVer(f *elf.File) (ver string)
- func MustExamine(filename string) string
- func MustExamineStatic(filename string) bool
- func OCamlVer(f *elf.File) (ver string)
- func PasVer(f *elf.File) (ver string)
- func RustVerStripped(f *elf.File) (ver string)
- func RustVerUnstripped(f *elf.File) (ver string)
- func Static(f *elf.File) bool
- func Stripped(f *elf.File) bool
- func TCCVer(f *elf.File) (ver string)
- type StreamReader
Constants ¶
This section is empty.
Variables ¶
var ( // GHCVersionRegex is a regexp for matching Glasgow Haskell Compiler version strings GHCVersionRegex = regexp.MustCompile(`GHC\ (\d{1,4}\.)(\d+\.)?(\d+)`) // GoVersionRegex is a regexp for matching Go version strings GoVersionRegex = regexp.MustCompile(`go(\d+\.)(\d+\.)?(\*|\d+)`) // PasVersionRegex is a regexp for matching Free Pascal Compiler version strings PasVersionRegex = regexp.MustCompile(`FPC\ (\d+\.)?(\d+\.)?(\*|\d+)`) // OcamlVersionRegex is a regexp for matching OCaml version strings OcamlVersionRegex = regexp.MustCompile(`(\d+\.)(\d+\.)?(\*|\d+)`) // GCCVersionRegex0 is another regexp for matching GCC version strings GCCVersionRegex0 = regexp.MustCompile(`(\d+\.)(\d+\.)?(\*|\d+)\ `) // GCCVersionRegex1 is another regexp for matching GCC version strings GCCVersionRegex1 = regexp.MustCompile(`\) (\d{1,4}\.)(\d+\.)?(\*|\d+)\ `) // GCCVersionRegex2 is another regexp for matching GCC version strings GCCVersionRegex2 = regexp.MustCompile(` (\d{1,4}\.)(\d+\.)?(\*|\d+)`) // GCCVersionRegex3 is another regexp for matching GCC version strings GCCVersionRegex3 = regexp.MustCompile(`(\d{1,4}\.)(\d+\.)?(\*|\d+)`) // GCCVersionRegex4 is another regexp for matching GCC version strings GCCVersionRegex4 = regexp.MustCompile(`\) (\d{1,4}\.)(\d+\.)?(\*|\d+).(\d+)`) )
Functions ¶
func Compiler ¶
Compiler takes an *elf.File and tries to find which compiler and version it was compiled with, by probing for known locations, strings and patterns.
func Examine ¶
Examine tries to discover which compiler and compiler version the given file was compiled with.
func ExamineStatic ¶ added in v1.2.0
ExamineStatic opens the given filename and checks that it is an ELF file. It then calls Static to confirm that PT_DYNAMIC is not present in the program headers.
func FirstIsGreater ¶
FirstIsGreater checks if the first version number is greater than the second one. It uses a relatively simple algorithm, where all non-numbers counts as less than "0".
func GCCVer ¶
GCCVer returns the GCC compiler version or an empty string example output: "GCC 6.3.1" Also handles clang.
func GHCVer ¶ added in v1.1.0
GHCVer returns the GHC compiler version or an empty string example output: "GHC 8.6.2"
func MustExamine ¶
MustExamine does the same as examine, but panics instead of returning an error
func MustExamineStatic ¶ added in v1.2.0
MustExamineStatic does the same as ExamineStatic, but panics instead of returning an error
func OCamlVer ¶
OCamlVer returns the OCaml compiler version or an empty string example output: "OCaml 4.05.0"
func PasVer ¶
PasVer returns the FPC compiler version or an empty string example output: "FPC 3.0.2"
func RustVerStripped ¶
RustVerStripped returns the Rust compiler version or an empty string, from a stripped Rust executable. Does not contain the Rust version number. Example output: "Rust (GCC 8.1.0)"
func RustVerUnstripped ¶
RustVerUnstripped returns the Rust compiler version or an empty string example output: "Rust 1.27.0"
func Static ¶ added in v1.2.0
Static checks that PT_DYNAMIC is not in one of the program headers of the ELF file
Types ¶
type StreamReader ¶ added in v1.3.2
type StreamReader struct {
// contains filtered or unexported fields
}
StreamReader is intended to be used to search in a streaming manner.
func NewStreamReader ¶ added in v1.3.2
func NewStreamReader(r io.Reader, bufferSize int) (*StreamReader, error)
NewStreamReader creates a new StreamReader.
func (*StreamReader) Next ¶ added in v1.3.2
func (r *StreamReader) Next() ([]byte, error)
Next reads the next half byte buffer from the stream. The reason for reading half is so that we can build something like:
tail my-file | grep "something"
Where "something" may be between two reads.