linker

package
v0.0.0-...-e7f50b7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultQueueAllocCap = 1024

Variables

Functions

func BytesToVarBigEndian

func BytesToVarBigEndian(slice []byte) interface{}

func BytesToVarLittleEndian

func BytesToVarLittleEndian(slice []byte) interface{}

func Fsm

func Fsm(bQueue ByteQueue, fsmState FsmState) error

func ReadIntoFSM

func ReadIntoFSM(reader io.Reader, ctxt FsmState, fsm func(ByteQueue, FsmState) error) error

func VariableToFlagValues

func VariableToFlagValues[N uint8 | uint16 | uint32 | uint64](value N, onValid func(N))

Types

type BinaryFile

type BinaryFile struct {
	VersionNo         uint16
	Timestamp         uint32
	Flags             map[BinaryFileFlag]bool
	Header            BinaryFileHeader
	TargetMagicNumber BinaryFileTarget
	Sections          BinaryFileSections
	Relocations       []RelocationEntry
	Symbols           []SymbolEntry
}

type BinaryFileFlag

type BinaryFileFlag uint16
const (
	BFF_STRIPPED_RELOCATION       BinaryFileFlag = 0x0001
	BFF_IS_RELOCATABLE            BinaryFileFlag = 0x0002
	BFF_STRIPPED_LINE_NUMBERS     BinaryFileFlag = 0x0004
	BFF_STRIPPED_SYMBOLS          BinaryFileFlag = 0x0008
	BFF_AGGRESSIVE_WS_TRIM        BinaryFileFlag = 0x0010
	BFF_LARGE_ADDRESS_AWARE       BinaryFileFlag = 0x0020
	BFF_DUPLICATE_SYMBOLS_REMOVED BinaryFileFlag = 0x0040
	BFF_BYTES_REVERSED_LO         BinaryFileFlag = 0x0080
	BFF_LITTLE_ENDIAN             BinaryFileFlag = 0x0100
	BFF_BIG_ENDIAN_MARKED         BinaryFileFlag = 0x0200
	BFF_REMOVABLE_RUN_FROM_SWAP   BinaryFileFlag = 0x0400
	BFF_NET_RUN_FROM_SWAP         BinaryFileFlag = 0x0800
	BFF_SYSTEM                    BinaryFileFlag = 0x1000
	BFF_DLL                       BinaryFileFlag = 0x2000
	BFF_UP_SYSTEM_ONLY            BinaryFileFlag = 0x4000
	BFF_BYTES_REVERSED_HI         BinaryFileFlag = 0x8000
)

type BinaryFileHeader

type BinaryFileHeader struct {
	FileMagicNumber  uint16
	VersionStamp     uint16
	Entrypoint       uintptr
	ImageBase        uintptr
	ImageSize        uint64
	HeaderSize       uint64
	SectionAlignment uint32
	FileAlignment    uint32
}

type BinaryFileReader

type BinaryFileReader func(io.Reader) (BinaryFileResult, error)

func GetCOFFReader

func GetCOFFReader() BinaryFileReader

type BinaryFileResult

type BinaryFileResult interface {
	Result() *BinaryFile
}

Is this a monad?

type BinaryFileResultCOFF

type BinaryFileResultCOFF struct {
	// contains filtered or unexported fields
}

func (BinaryFileResultCOFF) Result

func (bfrPE BinaryFileResultCOFF) Result() *BinaryFile

type BinaryFileSections

type BinaryFileSections struct {
	Sections    []BinarySection
	ExecSection *BinarySection
	DataSection *BinarySection
	BssSection  *BinarySection
}

type BinaryFileTarget

type BinaryFileTarget uint16
const (
	BFT_UNKNOWN     BinaryFileTarget = 0x0
	BFT_ALPHA       BinaryFileTarget = 0x184
	BFT_ALPHA64     BinaryFileTarget = 0x284
	BFT_AM33        BinaryFileTarget = 0x1d3
	BFT_AMD64       BinaryFileTarget = 0x8664
	BFT_ARM         BinaryFileTarget = 0x1c0
	BFT_ARM64       BinaryFileTarget = 0xaa64
	BFT_ARMNT       BinaryFileTarget = 0x1c4
	BFT_EBC         BinaryFileTarget = 0xebc
	BFT_I386        BinaryFileTarget = 0x14c
	BFT_IA64        BinaryFileTarget = 0x200
	BFT_LOONGARCH32 BinaryFileTarget = 0x6232
	BFT_LOONGARCH64 BinaryFileTarget = 0x6264
	BFT_M32R        BinaryFileTarget = 0x9041
	BFT_MIPS16      BinaryFileTarget = 0x266
	BFT_MIPSFPU     BinaryFileTarget = 0x366
	BFT_MIPSFPU16   BinaryFileTarget = 0x466
	BFT_POWERPC     BinaryFileTarget = 0x1f0
	BFT_POWERPCFP   BinaryFileTarget = 0x1f1
	BFT_R4000       BinaryFileTarget = 0x166
	BFT_RISCV32     BinaryFileTarget = 0x5032
	BFT_RISCV64     BinaryFileTarget = 0x5064
	BFT_RISCV128    BinaryFileTarget = 0x5128
	BFT_SH3         BinaryFileTarget = 0x1a2
	BFT_SH3DSP      BinaryFileTarget = 0x1a3
	BFT_SH4         BinaryFileTarget = 0x1a6
	BFT_SH5         BinaryFileTarget = 0x1a8
	BFT_THUMB       BinaryFileTarget = 0x1c2
	BFT_WCEMIPSV2   BinaryFileTarget = 0x169
)

type BinarySection

type BinarySection struct {
	Name    string
	Start   uintptr
	Size    uint64
	Content []byte
	Flags   map[BinarySectionFlag]bool
}

type BinarySectionFlag

type BinarySectionFlag int
const (
	BSF_REGULAR BinarySectionFlag = iota
	BSF_DUMMY
	BSF_NO_LOAD
	BSF_GROUP
	BSF_PADDING
	BSF_COPY
	BSF_TEXT
	BSF_DATA
	BSF_BSS
	BSF_BLOCK
	BSF_PASS
	BSF_CLINK
	BSF_VECTOR
	BSF_PADDED
)

type ByteQueue

type ByteQueue interface {
	Length() int
	Append([]byte) ByteQueue
	SeekNext(int) []byte
	SeekAt(int, int) []byte
	Pop(int) []byte
	CanPop(int) bool
}

func NewByteQueue

func NewByteQueue() ByteQueue

func NewByteQueueCap

func NewByteQueueCap(alloc int) ByteQueue

type CoffFsmDefinition

type CoffFsmDefinition struct {
	// contains filtered or unexported fields
}

type CoffFsmState

type CoffFsmState struct {
	// contains filtered or unexported fields
}

func (*CoffFsmState) Consume

func (fsmState *CoffFsmState) Consume(data interface{})

func (*CoffFsmState) IsEndState

func (fsmState *CoffFsmState) IsEndState() bool

func (*CoffFsmState) NextState

func (fsmState *CoffFsmState) NextState()

func (*CoffFsmState) NumBytes

func (fsmState *CoffFsmState) NumBytes() int

func (*CoffFsmState) Transform

func (fsmState *CoffFsmState) Transform(bs []byte) (interface{}, error)

type ExternRef

type ExternRef string

type FsmState

type FsmState interface {
	NumBytes() int
	Transform([]byte) (interface{}, error)
	Consume(interface{})
	NextState()
	IsEndState() bool
}

type LibraryName

type LibraryName string

type Path

type Path string

type RelocationEntry

type RelocationEntry struct {
	VirtualAddress uintptr
	SymTableIndex  uint16
	RelocationType RelocationType
}

type RelocationType

type RelocationType uint16
const (
	RT_ADD RelocationType = iota
	RT_SUB
	RT_NEG
	RT_MPY
	RT_DIV
	RT_MOD
	RT_SR
	RT_ASR
	RT_SL
	RT_AND
	RT_OR
	RT_XOR
	RT_NOTB
	RT_ULDFLD
	RT_SLDFLD
	RT_USTFLD
	RT_SSTFLD
	RT_PUSH
	RT_PUSHSK
	RT_PUSHUK
	RT_PUSHPC
	RT_DUP
	RT_XSTFLD
	RT_PUSHSV
	RT_ABS
	RT_RELBYTE
	RT_RELWORD
	RT_REL24
	RT_RELLONG
)

type StorageClass

type StorageClass uint8
const (
	SC_NULL StorageClass = iota
	SC_AUTO
	SC_EXT
	SC_STAT
	SC_REG
	SC_EXTREF
	SC_LABEL
	SC_ULABEL
	SC_MOS
	SC_ARG
	SC_STRTAG
	SC_MOU
	SC_UNTAG
	SC_TPDEF
	SC_USTATIC
	SC_ENTAG
	SC_MOE
	SC_REGPARAM
	SC_FIELD
	SC_UEXT
	SC_STATLAB
	SC_EXTLAB

	SC_VARARG StorageClass = 27

	SC_BLOCK StorageClass = 100
	SC_FCN   StorageClass = 101
	SC_EOS   StorageClass = 102
	SC_FILE  StorageClass = 103
	SC_LINE  StorageClass = 104
)

type SymbolEntry

type SymbolEntry struct {
	Name          string
	Value         []byte
	SectionNo     int16
	StorageClass  StorageClass
	HasAuxEntries bool
	IsAbsolute    bool
	IsDefined     bool
}

Jump to

Keyboard shortcuts

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