github.com/Rookout/GoSDK@v0.1.48/pkg/services/assembler/common/g_amd64_1.15.go (about) 1 //go:build go1.15 && !go1.17 && amd64 2 // +build go1.15,!go1.17,amd64 3 4 package common 5 6 import ( 7 "reflect" 8 9 "github.com/Rookout/GoSDK/pkg/rookoutErrors" 10 "github.com/Rookout/GoSDK/pkg/services/assembler" 11 "github.com/Rookout/GoSDK/pkg/services/disassembler" 12 "github.com/Rookout/GoSDK/pkg/utils" 13 "golang.org/x/arch/x86/x86asm" 14 ) 15 16 func movGToR12() 17 18 var InitError error 19 var movGToR12Bytes []byte 20 21 22 func init() { 23 24 entry := reflect.ValueOf(movGToR12).Pointer() 25 movGInst, err := disassembler.DecodeOne(entry) 26 if err != nil { 27 InitError = err 28 return 29 } 30 31 retInst, err := disassembler.DecodeOne(entry + uintptr(movGInst.Len)) 32 if err != nil { 33 InitError = err 34 return 35 } 36 if retInst.Op != x86asm.RET { 37 InitError = rookoutErrors.NewUnexpectedInstruction(movGInst, retInst) 38 return 39 } 40 41 movGToR12Bytes = utils.MakeSliceFromPointer(entry, movGInst.Len) 42 } 43 44 45 func MovGToR12(b *assembler.Builder) *assembler.Instruction { 46 return b.Bytes(movGToR12Bytes) 47 }