Extended Berkeley Packet Filter (eBPF) assembler and virtual machine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

48 lines
771 B

package ebpf
import "fmt"
// Register is the source or destination Register.
type Register uint8
const (
// Exit value Register.
R0 Register = iota
// Function argument registers.
R1
R2
R3
R4
R5
// Callee saved registers.
R6
R7
R8
R9
// Read-only frame pointer to access Stack.
R10
// Named registers.
RAX = R0
RFP = R10
)
// Pseudo registers used by 64bit loads and jumps
const (
PseudoMapFD = R1 // BPF_PSEUDO_MAP_FD
PseudoMapValue = R2 // BPF_PSEUDO_MAP_VALUE
PseudoCall = R1 // BPF_PSEUDO_CALL
)
func (r Register) String() string {
if r == RFP {
return "RFP"
}
return fmt.Sprintf("R%d", uint8(r))
}
func (r Register) CString() string {
if r == RFP {
return "register[RFP]"
}
return fmt.Sprintf("register[R%d]", uint8(r))
}