コード例 #1
0
def CBZClass(binary, width, bool):
    rtKey = binary[-5:]
    inst = 'CBZ '
    char = ''
    if width == 64:
        char = 'X'
    else:
        char = 'W'
    inst += char
    regnum = utilFunc.uInt(rtKey)
    inst += str(regnum) + ', OFFSET('
    imm19Key = binary[8:27]

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

    regValue = getRegValueByStringkey(rtKey, '0')
    regValue = regValue[0:width]  #since CBZ_32
    if bool:
        if regValue == '0' * width:
            utilFunc.branchWithOffset(offset)
    else:
        if regValue != '0' * width:
            utilFunc.branchWithOffset(offset)
    utilFunc.finalize_simple(inst)
コード例 #2
0
def CBZClass(binary,width,bool):
    rtKey=binary[-5:]
    inst='CBZ '
    char=''
    if width==64:
        char='X'
    else:
        char='W'
    inst+=char
    regnum=utilFunc.uInt(rtKey)
    inst+=str(regnum)+', OFFSET('
    imm19Key=binary[8:27]

    (instpart,offset)=utilFunc.getOffset(imm19Key)
    inst+=instpart+')'
    
    regValue=getRegValueByStringkey(rtKey, '0')
    regValue=regValue[0:width]#since CBZ_32
    if bool:
        if regValue=='0'*width:
            utilFunc.branchWithOffset(offset)
    else:
        if regValue!='0'*width:
            utilFunc.branchWithOffset(offset)
    utilFunc.finalize_simple(inst)
コード例 #3
0
def execB(binary):
    inst = 'B OFFSET('
    imm26key = binary[6:32]

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

    utilFunc.branchWithOffset(offset)  #the magic!
    utilFunc.finalize_simple(inst)
コード例 #4
0
def execB(binary):
    inst ='B OFFSET('
    imm26key=binary[6:32]
    
    (instpart,offset)=utilFunc.getOffset(imm26key)
    inst+=instpart+')'
    
    utilFunc.branchWithOffset(offset) #the magic!
    utilFunc.finalize_simple(inst)
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
def execBCond(binary):

    bits_four = binary[-4:]
    xx = utilFunc.conditionHolds(bits_four)
    if not xx[0]:
        return

    inst = 'B.' + xx[1] + ' OFFSET('
    imm19key = binary[8:27]

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

    utilFunc.branchWithOffset(offset)  #the magic!
    utilFunc.finalize_simple(inst)
コード例 #8
0
def execBCond(binary):
    
    bits_four=binary[-4:]
    xx=utilFunc.conditionHolds(bits_four)    
    if not xx[0]:
        return
    
    inst ='B.'+xx[1]+' OFFSET('
    imm19key=binary[8:27]
    
    (instpart,offset)=utilFunc.getOffset(imm19key)
    inst+=instpart+')'
    
    utilFunc.branchWithOffset(offset) #the magic!
    utilFunc.finalize_simple(inst)