github.com/dylandreimerink/gobpfld@v0.6.1-0.20220205171531-e79c330ad608/ebpf/ja.go (about)

     1  package ebpf
     2  
     3  import "fmt"
     4  
     5  var (
     6  	_ Instruction = (*Jump)(nil)
     7  	_ Jumper      = (*Jump)(nil)
     8  )
     9  
    10  type Jump struct {
    11  	Offset int16
    12  }
    13  
    14  func (a *Jump) Raw() ([]RawInstruction, error) {
    15  	return []RawInstruction{
    16  		{Op: BPF_JA | BPF_JMP, Off: a.Offset},
    17  	}, nil
    18  }
    19  
    20  func (a *Jump) String() string {
    21  	return fmt.Sprintf("goto %+d", a.Offset)
    22  }
    23  
    24  func (a *Jump) SetJumpTarget(relAddr int16) {
    25  	a.Offset = relAddr
    26  }