Beispiel #1
0
func (i insnAddr32) op(code gen.OpCoder, addr int32) {
	var offset int32
	if addr != 0 {
		siteAddr := code.Len() + i.size()
		offset = addr - siteAddr
	} else {
		offset = -i.size() // infinite loop as placeholder
	}
	i.writeTo(code, offset)
}
Beispiel #2
0
func (opcode insnAddr8) op(code gen.OpCoder, addr int32) (ok bool) {
	insnSize := int32(len(opcode)) + 1
	siteAddr := code.Len() + insnSize
	offset := addr - siteAddr

	if offset >= -0x80 && offset < 0x80 {
		code.Write(opcode)
		code.WriteByte(uint8(offset))
		ok = true
	}
	return
}
Beispiel #3
0
func (mach X86) OpInit(code gen.OpCoder, startAddr int32) (retAddr int32) {
	if code.Len() == 0 || code.Len() > functionAlignment {
		panic("inconsistency")
	}
	code.Align(functionAlignment, paddingByte)
	Add.opImm(code, types.I64, regStackLimit, gen.StackReserve)

	var notResume links.L

	Test.opFromReg(code, types.I64, regResult, regResult)
	Je.rel8.opStub(code)
	notResume.AddSite(code.Len())
	Ret.op(code) // simulate return from snapshot function call

	notResume.Addr = code.Len()
	mach.updateBranches8(code, &notResume)

	CallRel.op(code, startAddr)
	return code.Len()
}
Beispiel #4
0
func (i insnAddr32) opMissingFunction(code gen.OpCoder) {
	siteAddr := code.Len() + i.size()
	i.writeTo(code, -siteAddr)
}
Beispiel #5
0
func (i insnAddr8) opStub(code gen.OpCoder) {
	i.op(code, code.Len()) // infinite loop as placeholder
}