linutil

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 9 Imported by: 4

Documentation

Overview

Package linutil contains functions and data structures used by both the linux implementation of the native backend and the core backend to deal with structures used by the linux kernel.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyLibraries = errors.New("number of loaded libraries exceeds maximum")

Functions

func ElfUpdateSharedObjects added in v1.3.0

func ElfUpdateSharedObjects(p proc.Process) error

ElfUpdateSharedObjects reads the list of dynamic libraries loaded by the dynamic linker from the .dynamic section and uses it to update p.BinInfo(). See the SysV ABI for a description of how the .dynamic section works: https://www.sco.com/developers/gabi/latest/contents.html

func EntryPointFromAuxv added in v1.4.1

func EntryPointFromAuxv(auxv []byte, ptrSize int) uint64

EntryPointFromAuxv searches the elf auxiliary vector for the entry point address. For a description of the auxiliary vector (auxv) format see: System V Application Binary Interface, AMD64 Architecture Processor Supplement, section 3.4.3. System V Application Binary Interface, Intel386 Architecture Processor Supplement (fourth edition), section 3-28.

Types

type AMD64PtraceRegs

type AMD64PtraceRegs struct {
	R15      uint64
	R14      uint64
	R13      uint64
	R12      uint64
	Rbp      uint64
	Rbx      uint64
	R11      uint64
	R10      uint64
	R9       uint64
	R8       uint64
	Rax      uint64
	Rcx      uint64
	Rdx      uint64
	Rsi      uint64
	Rdi      uint64
	Orig_rax uint64
	Rip      uint64
	Cs       uint64
	Eflags   uint64
	Rsp      uint64
	Ss       uint64
	Fs_base  uint64
	Gs_base  uint64
	Ds       uint64
	Es       uint64
	Fs       uint64
	Gs       uint64
}

AMD64PtraceRegs is the struct used by the linux kernel to return the general purpose registers for AMD64 CPUs.

type AMD64Registers

type AMD64Registers struct {
	Regs     *AMD64PtraceRegs
	Fpregs   []proc.Register
	Fpregset *amd64util.AMD64Xstate
	// contains filtered or unexported fields
}

AMD64Registers implements the proc.Registers interface for the native/linux backend and core/linux backends, on AMD64.

func NewAMD64Registers added in v1.4.1

func NewAMD64Registers(regs *AMD64PtraceRegs, loadFpRegs func(*AMD64Registers) error) *AMD64Registers

func (*AMD64Registers) BP

func (r *AMD64Registers) BP() uint64

func (*AMD64Registers) Copy

func (r *AMD64Registers) Copy() (proc.Registers, error)

Copy returns a copy of these registers that is guaranteed not to change.

func (*AMD64Registers) GAddr

func (r *AMD64Registers) GAddr() (uint64, bool)

GAddr returns the address of the G variable if it is known, 0 and false otherwise.

func (*AMD64Registers) LR added in v1.9.0

func (r *AMD64Registers) LR() uint64

LR returns the link register.

func (*AMD64Registers) PC

func (r *AMD64Registers) PC() uint64

PC returns the value of RIP register.

func (*AMD64Registers) SP

func (r *AMD64Registers) SP() uint64

SP returns the value of RSP register.

func (*AMD64Registers) SetReg added in v1.6.1

func (r *AMD64Registers) SetReg(regNum uint64, reg *op.DwarfRegister) (bool, error)

func (*AMD64Registers) Slice

func (r *AMD64Registers) Slice(floatingPoint bool) ([]proc.Register, error)

Slice returns the registers as a list of (name, value) pairs.

func (*AMD64Registers) TLS

func (r *AMD64Registers) TLS() uint64

TLS returns the address of the thread local storage memory segment.

type ARM64PtraceFpRegs added in v1.4.1

type ARM64PtraceFpRegs struct {
	Vregs []byte
	Fpsr  uint32
	Fpcr  uint32
}

func (*ARM64PtraceFpRegs) Byte added in v1.4.1

func (fpregs *ARM64PtraceFpRegs) Byte() []byte

func (*ARM64PtraceFpRegs) Decode added in v1.4.1

func (fpregs *ARM64PtraceFpRegs) Decode() (regs []proc.Register)

type ARM64PtraceRegs added in v1.4.0

type ARM64PtraceRegs struct {
	Regs   [31]uint64
	Sp     uint64
	Pc     uint64
	Pstate uint64
}

ARM64PtraceRegs is the struct used by the linux kernel to return the general purpose registers for ARM64 CPUs. copy from sys/unix/ztypes_linux_arm64.go:735

type ARM64Registers added in v1.4.0

type ARM64Registers struct {
	Regs *ARM64PtraceRegs // general-purpose registers

	Fpregs   []proc.Register // Formatted floating point registers
	Fpregset []byte          // holding all floating point register values
	// contains filtered or unexported fields
}

ARM64Registers is a wrapper for sys.PtraceRegs.

func NewARM64Registers added in v1.4.1

func NewARM64Registers(regs *ARM64PtraceRegs, iscgo bool, tpidr_el0 uint64, loadFpRegs func(*ARM64Registers) error) *ARM64Registers

func (*ARM64Registers) BP added in v1.4.0

func (r *ARM64Registers) BP() uint64

func (*ARM64Registers) Copy added in v1.4.0

func (r *ARM64Registers) Copy() (proc.Registers, error)

Copy returns a copy of these registers that is guaranteed not to change.

func (*ARM64Registers) GAddr added in v1.4.0

func (r *ARM64Registers) GAddr() (uint64, bool)

GAddr returns the address of the G variable if it is known, 0 and false otherwise.

func (*ARM64Registers) LR added in v1.9.0

func (r *ARM64Registers) LR() uint64

LR returns the link register.

func (*ARM64Registers) PC added in v1.4.0

func (r *ARM64Registers) PC() uint64

PC returns the value of RIP register.

func (*ARM64Registers) SP added in v1.4.0

func (r *ARM64Registers) SP() uint64

SP returns the value of RSP register.

func (*ARM64Registers) SetReg added in v1.9.0

func (r *ARM64Registers) SetReg(regNum uint64, reg *op.DwarfRegister) (fpchanged bool, err error)

func (*ARM64Registers) Slice added in v1.4.0

func (r *ARM64Registers) Slice(floatingPoint bool) ([]proc.Register, error)

Slice returns the registers as a list of (name, value) pairs.

func (*ARM64Registers) TLS added in v1.4.0

func (r *ARM64Registers) TLS() uint64

TLS returns the address of the thread local storage memory segment.

type I386PtraceRegs added in v1.4.1

type I386PtraceRegs struct {
	Ebx      int32
	Ecx      int32
	Edx      int32
	Esi      int32
	Edi      int32
	Ebp      int32
	Eax      int32
	Xds      int32
	Xes      int32
	Xfs      int32
	Xgs      int32
	Orig_eax int32
	Eip      int32
	Xcs      int32
	Eflags   int32
	Esp      int32
	Xss      int32
}

I386PtraceRegs is the struct used by the linux kernel to return the general purpose registers for I386 CPUs.

type I386Registers added in v1.4.1

type I386Registers struct {
	Regs     *I386PtraceRegs
	Fpregs   []proc.Register
	Fpregset *amd64util.AMD64Xstate
	Tls      uint64
	// contains filtered or unexported fields
}

I386Registers implements the proc.Registers interface for the native/linux backend and core/linux backends, on I386.

func NewI386Registers added in v1.4.1

func NewI386Registers(regs *I386PtraceRegs, loadFpRegs func(*I386Registers) error) *I386Registers

func (*I386Registers) BP added in v1.4.1

func (r *I386Registers) BP() uint64

func (*I386Registers) CX added in v1.4.1

func (r *I386Registers) CX() uint64

CX returns the value of ECX register.

func (*I386Registers) Copy added in v1.4.1

func (r *I386Registers) Copy() (proc.Registers, error)

Copy returns a copy of these registers that is guaranteed not to change.

func (*I386Registers) GAddr added in v1.4.1

func (r *I386Registers) GAddr() (uint64, bool)

GAddr returns the address of the G variable if it is known, 0 and false otherwise.

func (*I386Registers) LR added in v1.9.0

func (r *I386Registers) LR() uint64

LR returns the link register.

func (*I386Registers) PC added in v1.4.1

func (r *I386Registers) PC() uint64

PC returns the value of EIP register.

func (*I386Registers) SP added in v1.4.1

func (r *I386Registers) SP() uint64

SP returns the value of ESP register.

func (*I386Registers) Slice added in v1.4.1

func (r *I386Registers) Slice(floatingPoint bool) ([]proc.Register, error)

Slice returns the registers as a list of (name, value) pairs.

func (*I386Registers) TLS added in v1.4.1

func (r *I386Registers) TLS() uint64

TLS returns the address of the thread local storage memory segment.

type PPC64LEPtraceFpRegs added in v1.21.1

type PPC64LEPtraceFpRegs struct {
	Fp []byte
}

func (*PPC64LEPtraceFpRegs) Decode added in v1.21.1

func (fpregs *PPC64LEPtraceFpRegs) Decode() (regs []proc.Register)

type PPC64LEPtraceRegs added in v1.21.1

type PPC64LEPtraceRegs struct {
	Gpr       [32]uint64 // 32 general-purpose registers, each 64 bits wide
	Nip       uint64
	Msr       uint64
	Orig_gpr3 uint64
	Ctr       uint64
	Link      uint64 // Link register -- LLDB dwarf_lr_ppc64le = 65
	Xer       uint64 // Fixed point exception register -- LLDB dwarf_xer_ppc64le = 76
	Ccr       uint64
	Softe     uint64
	Trap      uint64
	Dar       uint64
	Dsisr     uint64
	Result    uint64
}

PPC64LEPtraceRegs is the struct used by the linux kernel to return the general purpose registers for PPC64LE CPUs. Copied from src/syscall/ztypes_linux_ppc64le.go#L518-L532

type PPC64LERegisters added in v1.21.1

type PPC64LERegisters struct {
	Regs     *PPC64LEPtraceRegs
	Fpregs   []proc.Register //Formatted floating point registers
	Fpregset []byte          //holding all floating point register values
	// contains filtered or unexported fields
}

PPC64LERegisters implements the proc.Registers interface for the native/linux backend and core/linux backends, on PPC64LE.

func NewPPC64LERegisters added in v1.21.1

func NewPPC64LERegisters(regs *PPC64LEPtraceRegs, loadFpRegs func(*PPC64LERegisters) error) *PPC64LERegisters

func (*PPC64LERegisters) BP added in v1.21.1

func (r *PPC64LERegisters) BP() uint64

func (*PPC64LERegisters) Copy added in v1.21.1

func (r *PPC64LERegisters) Copy() (proc.Registers, error)

Copy returns a copy of these registers that is guaranteed not to change.

func (*PPC64LERegisters) GAddr added in v1.21.1

func (r *PPC64LERegisters) GAddr() (uint64, bool)

GAddr returns the address of the G variable

func (*PPC64LERegisters) LR added in v1.21.1

func (r *PPC64LERegisters) LR() uint64

LR The Link Register is a 64-bit register. It can be used to provide the branch target address for the Branch Conditional to Link Register instruction, and it holds the return address after Branch instructions for which LK=1 and after System Call Vectored instructions. Extracted from the 2.3.2 section of the PowerISA Book 3.1

func (*PPC64LERegisters) PC added in v1.21.1

func (r *PPC64LERegisters) PC() uint64

PC returns the value of the NIP register Also called the IAR/Instruction Address Register or NIP/Next Instruction Pointer

func (*PPC64LERegisters) SP added in v1.21.1

func (r *PPC64LERegisters) SP() uint64

SP returns the value of Stack frame pointer stored in Gpr[1].

func (*PPC64LERegisters) SetReg added in v1.21.1

func (r *PPC64LERegisters) SetReg(regNum uint64, reg *op.DwarfRegister) (fpchanged bool, err error)

func (*PPC64LERegisters) Slice added in v1.21.1

func (r *PPC64LERegisters) Slice(floatingPoint bool) ([]proc.Register, error)

Slice returns the registers as a list of (name, value) pairs.

func (*PPC64LERegisters) TLS added in v1.21.1

func (r *PPC64LERegisters) TLS() uint64

TLS returns the value of the thread pointer stored in Gpr[13]

Jump to

Keyboard shortcuts

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