Documentation ¶
Overview ¶
Package arch provides abstractions around architecture-dependent details, such as syscall calling conventions, native types, etc.
Index ¶
- Constants
- Variables
- type Arch
- type AuxEntry
- type Auxv
- type Context64
- func (c *Context64) Arch() Arch
- func (c *Context64) FloatingPointData() *fpu.State
- func (c *Context64) Fork() *Context64
- func (c *Context64) IP() uintptr
- func (c *Context64) Native(val uintptr) marshal.Marshallable
- func (c *Context64) NewMmapLayout(min, max hostarch.Addr, r *limits.LimitSet) (MmapLayout, error)
- func (c *Context64) PIELoadAddress(l MmapLayout) hostarch.Addr
- func (c *Context64) PtracePeekUser(addr uintptr) (marshal.Marshallable, error)
- func (c *Context64) PtracePokeUser(addr, data uintptr) error
- func (c *Context64) RestartSyscall()
- func (c *Context64) RestartSyscallWithRestartBlock()
- func (c *Context64) Return() uintptr
- func (c *Context64) SetIP(value uintptr)
- func (c *Context64) SetOldRSeqInterruptedIP(value uintptr)
- func (c *Context64) SetReturn(value uintptr)
- func (c *Context64) SetStack(value uintptr)
- func (c *Context64) SetTLS(value uintptr) bool
- func (c *Context64) SignalRestore(st *Stack, rt bool, featureSet cpuid.FeatureSet) (linux.SignalSet, linux.SignalStack, error)
- func (c *Context64) SignalSetup(st *Stack, act *linux.SigAction, info *linux.SignalInfo, ...) error
- func (c *Context64) Stack() uintptr
- func (c *Context64) StateFields() []string
- func (c *Context64) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (c *Context64) StateSave(stateSinkObject state.Sink)
- func (c *Context64) StateTypeName() string
- func (c *Context64) SyscallArgs() SyscallArguments
- func (c *Context64) SyscallNo() uintptr
- func (c *Context64) SyscallSaveOrig()
- func (c *Context64) TLS() uintptr
- func (c *Context64) Value(val marshal.Marshallable) uintptr
- func (c *Context64) Width() uint
- type MmapDirection
- type MmapLayout
- type Registers
- type SignalContext64
- func (s *SignalContext64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
- func (s *SignalContext64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
- func (s *SignalContext64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
- func (s *SignalContext64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
- func (s *SignalContext64) MarshalBytes(dst []byte) []byte
- func (s *SignalContext64) MarshalUnsafe(dst []byte) []byte
- func (s *SignalContext64) Packed() bool
- func (s *SignalContext64) SizeBytes() int
- func (s *SignalContext64) UnmarshalBytes(src []byte) []byte
- func (s *SignalContext64) UnmarshalUnsafe(src []byte) []byte
- func (s *SignalContext64) WriteTo(writer io.Writer) (int64, error)
- type Stack
- func (s *Stack) Align(offset int)
- func (s *Stack) CopyInBytes(sentinel hostarch.Addr, b []byte) (int, error)
- func (s *Stack) CopyOutBytes(sentinel hostarch.Addr, b []byte) (int, error)
- func (s *Stack) CopyScratchBuffer(size int) []byte
- func (s *Stack) Load(args []string, env []string, aux Auxv) (StackLayout, error)
- func (s *Stack) PushNullTerminatedByteSlice(bs []byte) (int, error)
- type StackLayout
- type State
- func (s *State) ClearSingleStep()
- func (s *State) Fork() State
- func (s *State) FullRestore() bool
- func (s State) Proto() *rpb.Registers
- func (s *State) PtraceGetRegSet(regset uintptr, dst io.Writer, maxlen int, fs cpuid.FeatureSet) (int, error)
- func (s *State) PtraceGetRegs(dst io.Writer) (int, error)
- func (s *State) PtraceSetRegSet(regset uintptr, src io.Reader, maxlen int, fs cpuid.FeatureSet) (int, error)
- func (s *State) PtraceSetRegs(src io.Reader) (int, error)
- func (s *State) RegisterMap() (map[string]uintptr, error)
- func (s *State) SetSingleStep()
- func (s *State) SingleStep() bool
- func (s *State) StateData() *State
- func (s *State) StateFields() []string
- func (s *State) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (s *State) StateSave(stateSinkObject state.Sink)
- func (s *State) StateTypeName() string
- type SyscallArgument
- type SyscallArguments
- type UContext64
- func (u *UContext64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
- func (u *UContext64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
- func (u *UContext64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
- func (u *UContext64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
- func (u *UContext64) MarshalBytes(dst []byte) []byte
- func (u *UContext64) MarshalUnsafe(dst []byte) []byte
- func (u *UContext64) Packed() bool
- func (u *UContext64) SizeBytes() int
- func (u *UContext64) UnmarshalBytes(src []byte) []byte
- func (u *UContext64) UnmarshalUnsafe(src []byte) []byte
- func (u *UContext64) WriteTo(writer io.Writer) (int64, error)
Constants ¶
const Host = AMD64
Host specifies the host architecture.
const StackBottomMagic = ^hostarch.Addr(0) // hostarch.Addr(-1)
StackBottomMagic is the special address callers must past to all stack marshalling operations to cause the src/dst address to be computed based on the current end of the stack.
const (
// SyscallWidth is the width of syscall, sysenter, and int 80 instructions.
SyscallWidth = 2
)
System-related constants for x86.
Variables ¶
var ( // TrapInstruction is the x86 trap instruction. TrapInstruction = [1]byte{0xcc} // CPUIDInstruction is the x86 CPUID instruction. CPUIDInstruction = [2]byte{0xf, 0xa2} // X86TrapFlag is an exported const for use by other packages. X86TrapFlag uint64 = (1 << 8) )
Functions ¶
This section is empty.
Types ¶
type AuxEntry ¶
An AuxEntry represents an entry in an ELF auxiliary vector.
+stateify savable
func (*AuxEntry) StateFields ¶
func (*AuxEntry) StateTypeName ¶
type Context64 ¶
type Context64 struct {
State
}
Context64 represents an AMD64 context.
+stateify savable
func (*Context64) FloatingPointData ¶
FloatingPointData returns the state of the floating-point unit.
func (*Context64) Native ¶
func (c *Context64) Native(val uintptr) marshal.Marshallable
Native returns the native type for the given val.
func (*Context64) NewMmapLayout ¶
NewMmapLayout implements Context.NewMmapLayout consistently with Linux.
func (*Context64) PIELoadAddress ¶
func (c *Context64) PIELoadAddress(l MmapLayout) hostarch.Addr
PIELoadAddress implements Context.PIELoadAddress.
func (*Context64) PtracePeekUser ¶
func (c *Context64) PtracePeekUser(addr uintptr) (marshal.Marshallable, error)
PtracePeekUser implements Context.PtracePeekUser.
func (*Context64) PtracePokeUser ¶
PtracePokeUser implements Context.PtracePokeUser.
func (*Context64) RestartSyscall ¶
func (c *Context64) RestartSyscall()
RestartSyscall implements Context.RestartSyscall.
func (*Context64) RestartSyscallWithRestartBlock ¶
func (c *Context64) RestartSyscallWithRestartBlock()
RestartSyscallWithRestartBlock implements Context.RestartSyscallWithRestartBlock.
func (*Context64) SetOldRSeqInterruptedIP ¶
SetOldRSeqInterruptedIP implements Context.SetOldRSeqInterruptedIP.
func (*Context64) SignalRestore ¶
func (c *Context64) SignalRestore(st *Stack, rt bool, featureSet cpuid.FeatureSet) (linux.SignalSet, linux.SignalStack, error)
SignalRestore implements Context.SignalRestore. (Compare to Linux's arch/x86/kernel/signal.c:sys_rt_sigreturn().)
func (*Context64) SignalSetup ¶
func (c *Context64) SignalSetup(st *Stack, act *linux.SigAction, info *linux.SignalInfo, alt *linux.SignalStack, sigset linux.SignalSet, featureSet cpuid.FeatureSet) error
SignalSetup implements Context.SignalSetup. (Compare to Linux's arch/x86/kernel/signal.c:__setup_rt_frame().)
func (*Context64) StateFields ¶
func (*Context64) StateTypeName ¶
func (*Context64) SyscallArgs ¶
func (c *Context64) SyscallArgs() SyscallArguments
SyscallArgs provides syscall arguments according to the 64-bit convention.
Due to the way addresses are mapped for the sentry this binary *must* be built in 64-bit mode. So we can just assume the syscall numbers that come back match the expected host system call numbers.
func (*Context64) SyscallNo ¶
SyscallNo returns the syscall number according to the 64-bit convention.
func (*Context64) SyscallSaveOrig ¶
func (c *Context64) SyscallSaveOrig()
SyscallSaveOrig save the value of the register which is clobbered in syscall handler(doSyscall()).
Noop on x86.
type MmapDirection ¶
type MmapDirection int
MmapDirection is a search direction for mmaps.
const ( // MmapBottomUp instructs mmap to prefer lower addresses. MmapBottomUp MmapDirection = iota // MmapTopDown instructs mmap to prefer higher addresses. MmapTopDown )
type MmapLayout ¶
type MmapLayout struct { // MinAddr is the lowest mappable address. MinAddr hostarch.Addr // MaxAddr is the highest mappable address. MaxAddr hostarch.Addr // BottomUpBase is the lowest address that may be returned for a // MmapBottomUp mmap. BottomUpBase hostarch.Addr // TopDownBase is the highest address that may be returned for a // MmapTopDown mmap. TopDownBase hostarch.Addr // DefaultDirection is the direction for most non-fixed mmaps in this // layout. DefaultDirection MmapDirection // MaxStackRand is the maximum randomization to apply to stack // allocations to maintain a proper gap between the stack and // TopDownBase. MaxStackRand uint64 }
MmapLayout defines the layout of the user address space for a particular MemoryManager.
Note that "highest address" below is always exclusive.
+stateify savable
func (*MmapLayout) StateFields ¶
func (m *MmapLayout) StateFields() []string
func (*MmapLayout) StateLoad ¶
func (m *MmapLayout) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*MmapLayout) StateSave ¶
func (m *MmapLayout) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*MmapLayout) StateTypeName ¶
func (m *MmapLayout) StateTypeName() string
func (*MmapLayout) Valid ¶
func (m *MmapLayout) Valid() bool
Valid returns true if this layout is valid.
type Registers ¶
type Registers struct {
linux.PtraceRegs
}
Registers represents the CPU registers for this architecture.
+stateify savable
func (*Registers) StateFields ¶
func (*Registers) StateTypeName ¶
type SignalContext64 ¶
type SignalContext64 struct { R8 uint64 R9 uint64 R10 uint64 R11 uint64 R12 uint64 R13 uint64 R14 uint64 R15 uint64 Rdi uint64 Rsi uint64 Rbp uint64 Rbx uint64 Rdx uint64 Rax uint64 Rcx uint64 Rsp uint64 Rip uint64 Eflags uint64 Cs uint16 Gs uint16 // always 0 on amd64. Fs uint16 // always 0 on amd64. Ss uint16 // only restored if _UC_STRICT_RESTORE_SS (unsupported). Err uint64 Trapno uint64 Oldmask linux.SignalSet Cr2 uint64 // Pointer to a struct _fpstate. Fpstate uint64 Reserved [8]uint64 }
SignalContext64 is equivalent to struct sigcontext, the type passed as the second argument to signal handlers set by signal(2).
+marshal
func (*SignalContext64) CopyIn ¶
func (s *SignalContext64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
CopyIn implements marshal.Marshallable.CopyIn.
func (*SignalContext64) CopyInN ¶
func (s *SignalContext64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
CopyInN implements marshal.Marshallable.CopyInN.
func (*SignalContext64) CopyOut ¶
func (s *SignalContext64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
CopyOut implements marshal.Marshallable.CopyOut.
func (*SignalContext64) CopyOutN ¶
func (s *SignalContext64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
CopyOutN implements marshal.Marshallable.CopyOutN.
func (*SignalContext64) MarshalBytes ¶
func (s *SignalContext64) MarshalBytes(dst []byte) []byte
MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (*SignalContext64) MarshalUnsafe ¶
func (s *SignalContext64) MarshalUnsafe(dst []byte) []byte
MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (*SignalContext64) Packed ¶
func (s *SignalContext64) Packed() bool
Packed implements marshal.Marshallable.Packed.
func (*SignalContext64) SizeBytes ¶
func (s *SignalContext64) SizeBytes() int
SizeBytes implements marshal.Marshallable.SizeBytes.
func (*SignalContext64) UnmarshalBytes ¶
func (s *SignalContext64) UnmarshalBytes(src []byte) []byte
UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (*SignalContext64) UnmarshalUnsafe ¶
func (s *SignalContext64) UnmarshalUnsafe(src []byte) []byte
UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
type Stack ¶
type Stack struct { // Our arch info. // We use this for automatic Native conversion of hostarch.Addrs during // Push() and Pop(). Arch *Context64 // The interface used to actually copy user memory. IO usermem.IO // Our current stack bottom. Bottom hostarch.Addr // contains filtered or unexported fields }
Stack is a simple wrapper around a hostarch.IO and an address. Stack implements marshal.CopyContext, and marshallable values can be pushed or popped from the stack through the marshal.Marshallable interface.
Stack is not thread-safe.
func (*Stack) CopyInBytes ¶
CopyInBytes implements marshal.CopyContext.CopyInBytes. CopyInBytes computes an appropriate address based on the current end of the stack. Callers must use the sentinel address StackBottomMagic to marshal methods to indicate this.
func (*Stack) CopyOutBytes ¶
CopyOutBytes implements marshal.CopyContext.CopyOutBytes. CopyOutBytes computes an appropriate address based on the current end of the stack. Callers use the sentinel address StackBottomMagic to marshal methods to indicate this.
func (*Stack) CopyScratchBuffer ¶
CopyScratchBuffer implements marshal.CopyContext.CopyScratchBuffer.
type StackLayout ¶
type StackLayout struct { // ArgvStart is the beginning of the argument vector. ArgvStart hostarch.Addr // ArgvEnd is the end of the argument vector. ArgvEnd hostarch.Addr // EnvvStart is the beginning of the environment vector. EnvvStart hostarch.Addr // EnvvEnd is the end of the environment vector. EnvvEnd hostarch.Addr }
StackLayout describes the location of the arguments and environment on the stack.
type State ¶
type State struct { // The system registers. Regs Registers // contains filtered or unexported fields }
State contains the common architecture bits for X86 (the build tag of this file ensures it's only built on x86).
+stateify savable
func (*State) ClearSingleStep ¶
func (s *State) ClearSingleStep()
ClearSingleStep enables single stepping.
func (*State) FullRestore ¶
FullRestore indicates whether a full restore is required.
func (*State) PtraceGetRegSet ¶
func (s *State) PtraceGetRegSet(regset uintptr, dst io.Writer, maxlen int, fs cpuid.FeatureSet) (int, error)
PtraceGetRegSet implements Context.PtraceGetRegSet.
func (*State) PtraceGetRegs ¶
PtraceGetRegs implements Context.PtraceGetRegs.
func (*State) PtraceSetRegSet ¶
func (s *State) PtraceSetRegSet(regset uintptr, src io.Reader, maxlen int, fs cpuid.FeatureSet) (int, error)
PtraceSetRegSet implements Context.PtraceSetRegSet.
func (*State) PtraceSetRegs ¶
PtraceSetRegs implements Context.PtraceSetRegs.
func (*State) RegisterMap ¶
RegisterMap returns a map of all registers.
func (*State) SetSingleStep ¶
func (s *State) SetSingleStep()
SetSingleStep enables single stepping.
func (*State) SingleStep ¶
SingleStep implements Context.SingleStep.
func (*State) StateFields ¶
func (*State) StateTypeName ¶
type SyscallArgument ¶
type SyscallArgument struct { // Prefer to use accessor methods instead of 'Value' directly. Value uintptr }
SyscallArgument is an argument supplied to a syscall implementation. The methods used to access the arguments are named after the ***C type name*** and they convert to the closest Go type available. For example, Int() refers to a 32-bit signed integer argument represented in Go as an int32.
Using the accessor methods guarantees that the conversion between types is correct, taking into account size and signedness (i.e., zero-extension vs signed-extension).
func (SyscallArgument) Int ¶
func (a SyscallArgument) Int() int32
Int returns the int32 representation of a 32-bit signed integer argument.
func (SyscallArgument) Int64 ¶
func (a SyscallArgument) Int64() int64
Int64 returns the int64 representation of a 64-bit signed integer argument.
func (SyscallArgument) ModeT ¶
func (a SyscallArgument) ModeT() uint
ModeT returns the int representation of a mode_t argument.
func (SyscallArgument) Pointer ¶
func (a SyscallArgument) Pointer() hostarch.Addr
Pointer returns the hostarch.Addr representation of a pointer argument.
func (SyscallArgument) SizeT ¶
func (a SyscallArgument) SizeT() uint
SizeT returns the uint representation of a size_t argument.
func (SyscallArgument) Uint ¶
func (a SyscallArgument) Uint() uint32
Uint returns the uint32 representation of a 32-bit unsigned integer argument.
func (SyscallArgument) Uint64 ¶
func (a SyscallArgument) Uint64() uint64
Uint64 returns the uint64 representation of a 64-bit unsigned integer argument.
type SyscallArguments ¶
type SyscallArguments [6]SyscallArgument
SyscallArguments represents the set of arguments passed to a syscall.
type UContext64 ¶
type UContext64 struct { Flags uint64 Link uint64 Stack linux.SignalStack MContext SignalContext64 Sigset linux.SignalSet }
UContext64 is equivalent to ucontext_t on 64-bit x86.
+marshal
func (*UContext64) CopyIn ¶
func (u *UContext64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
CopyIn implements marshal.Marshallable.CopyIn.
func (*UContext64) CopyInN ¶
func (u *UContext64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
CopyInN implements marshal.Marshallable.CopyInN.
func (*UContext64) CopyOut ¶
func (u *UContext64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error)
CopyOut implements marshal.Marshallable.CopyOut.
func (*UContext64) CopyOutN ¶
func (u *UContext64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error)
CopyOutN implements marshal.Marshallable.CopyOutN.
func (*UContext64) MarshalBytes ¶
func (u *UContext64) MarshalBytes(dst []byte) []byte
MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (*UContext64) MarshalUnsafe ¶
func (u *UContext64) MarshalUnsafe(dst []byte) []byte
MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (*UContext64) Packed ¶
func (u *UContext64) Packed() bool
Packed implements marshal.Marshallable.Packed.
func (*UContext64) SizeBytes ¶
func (u *UContext64) SizeBytes() int
SizeBytes implements marshal.Marshallable.SizeBytes.
func (*UContext64) UnmarshalBytes ¶
func (u *UContext64) UnmarshalBytes(src []byte) []byte
UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (*UContext64) UnmarshalUnsafe ¶
func (u *UContext64) UnmarshalUnsafe(src []byte) []byte
UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
Source Files ¶
- aligned.go
- arch.go
- arch_abi_autogen_unsafe.go
- arch_amd64.go
- arch_amd64_abi_autogen_unsafe.go
- arch_amd64_state_autogen.go
- arch_state_autogen.go
- arch_state_x86.go
- arch_unsafe_abi_autogen_unsafe.go
- arch_unsafe_state_autogen.go
- arch_x86.go
- arch_x86_abi_autogen_unsafe.go
- arch_x86_impl.go
- arch_x86_impl_abi_autogen_unsafe.go
- arch_x86_impl_state_autogen.go
- arch_x86_state_autogen.go
- auxv.go
- signal_amd64.go
- stack.go
- stack_unsafe.go
- syscalls_amd64.go
Directories ¶
Path | Synopsis |
---|---|
Package fpu provides basic floating point helpers.
|
Package fpu provides basic floating point helpers. |