Exemplo n.º 1
0
def helper_l(binary, instr):
    rtKey = utilFunc.getRegKeyByStringKey(binary[27:32])
    imm19 = binary[8:27]
    opc = binary[0:2]
    signed = False

    if (opc == '00'):
        size = 4
    elif (opc == '01'):
        size = 8
    elif (opc == '10'):
        size = 4
        signed = True

    offset = utilFunc.signExtend(imm19 + '00', 64)
    offset = utilFunc.sInt(offset, 64)

    address = armdebug.getPC() + offset
    dataSize = size * 8

    data = utilFunc.fetchFromMemory(address, dataSize)

    if (data == const.TRAP):
        utilFunc.finalize_simple(instr)
        print "HEY!!! There seems to be a problem - memory location can not be accessed"
        print "Moving ahead without executing the instruction"
        return

    if (signed):
        data = utilFunc.signExtend(data, 64)
    instr += str(rtKey) + ", #" + str(offset)
    utilFunc.finalize(rtKey, data.zfill(64), instr, '0')
def helper_l(binary, instr):
    rtKey = utilFunc.getRegKeyByStringKey(binary[27:32])
    imm19 = binary[8:27]
    opc = binary[0:2]
    signed = False
    
    if(opc == '00'):
        size = 4
    elif(opc == '01'):
        size = 8
    elif(opc == '10'):
        size = 4
        signed = True
        
    offset = utilFunc.signExtend(imm19 + '00', 64)
    offset = utilFunc.sInt(offset, 64)
    
    address = armdebug.getPC() + offset
    dataSize = size * 8
    
    data = utilFunc.fetchFromMemory(address, dataSize)
    
    if(data == const.TRAP):
            utilFunc.finalize_simple(instr)
            print "HEY!!! There seems to be a problem - memory location can not be accessed"
            print "Moving ahead without executing the instruction"
            return
    
    if(signed):
        data = utilFunc.signExtend(data, 64)
    instr += str(rtKey) + ", #" + str(offset)
    utilFunc.finalize(rtKey, data.zfill(64), instr, '0')
Exemplo n.º 3
0
def execBL(binary):
    inst = 'BL OFFSET('
    imm26key = binary[-26:]

    (instpart, offset) = utilFunc.getOffset(imm26key)
    inst += instpart + ')'

    nextAddr = armdebug.getPC() + 4
    utilFunc.setRegValue(30, utilFunc.intToBinary(nextAddr, 64), '0')
    utilFunc.branchWithOffset(offset)
    utilFunc.finalize_simple(inst)
Exemplo n.º 4
0
def execBL(binary):
    inst='BL OFFSET('
    imm26key=binary[-26:]
    
    (instpart,offset)=utilFunc.getOffset(imm26key)
    inst+=instpart+')'
    
    nextAddr=armdebug.getPC()+4
    utilFunc.setRegValue(30, utilFunc.intToBinary(nextAddr, 64), '0')
    utilFunc.branchWithOffset(offset)
    utilFunc.finalize_simple(inst)
Exemplo n.º 5
0
def execBLR(binary):
    inst='BLR X'
    rnKey=binary[22:27]
    address_binary=utilFunc.getRegValueByStringkey(rnKey, '0')
    regnum=utilFunc.uInt(rnKey)
    inst+=str(regnum)
    hexstr = utilFunc.binaryToHexStr(address_binary)
    if not armdebug.checkIfValidBreakPoint(hexstr):
        utilFunc.finalize_simple('Instruction aborted. Invalid instruction address in register.')
        return
    nextAddr=armdebug.getPC()+4
    utilFunc.setRegValue(30, utilFunc.intToBinary(nextAddr, 64), '0')
    utilFunc.branchToAddress(int(hexstr,16))
    utilFunc.finalize_simple(inst)
Exemplo n.º 6
0
def execBLR(binary):
    inst = 'BLR X'
    rnKey = binary[22:27]
    address_binary = utilFunc.getRegValueByStringkey(rnKey, '0')
    regnum = utilFunc.uInt(rnKey)
    inst += str(regnum)
    hexstr = utilFunc.binaryToHexStr(address_binary)
    if not armdebug.checkIfValidBreakPoint(hexstr):
        utilFunc.finalize_simple(
            'Instruction aborted. Invalid instruction address in register.')
        return
    nextAddr = armdebug.getPC() + 4
    utilFunc.setRegValue(30, utilFunc.intToBinary(nextAddr, 64), '0')
    utilFunc.branchToAddress(int(hexstr, 16))
    utilFunc.finalize_simple(inst)
Exemplo n.º 7
0
def PCwithPageOffset(N, offset):
    PCint = armdebug.getPC()
    PCbin = intToBinary(PCint, 64)
    PCbinModified = PCbin[0:52] + '0' * N
    PCnow = int(PCbinModified, 2)
    return PCnow + offset
Exemplo n.º 8
0
def PCwithOffset(offset):
    return armdebug.getPC() + offset  #don't change this, it is no 4 only!!!
Exemplo n.º 9
0
def branchWithOffset(offset):  # signed offset
    armdebug.setPC((armdebug.getPC() + offset -
                    4))  # the magic! #-4 for the current instruction
Exemplo n.º 10
0
def PCwithPageOffset(N,offset):
    PCint=armdebug.getPC()
    PCbin=intToBinary(PCint, 64)
    PCbinModified=PCbin[0:52]+'0'*N
    PCnow=int(PCbinModified,2)
    return PCnow+offset
Exemplo n.º 11
0
def PCwithOffset(offset):
    return armdebug.getPC()+offset#don't change this, it is no 4 only!!! 
Exemplo n.º 12
0
def branchWithOffset(offset):  # signed offset
    armdebug.setPC((armdebug.getPC() + offset - 4))  # the magic! #-4 for the current instruction