OLLVM静态还原-1
分发块
真实块
块分类的功能实现
真实块中状态变量的值 - 分发块与真实块的分割点
真实块中状态变量的值 - 真实块中状态变量的变化
Last updated
Last updated
current_block = mba.get_mblock(0)
i = 0
# 既然获得了状态变量,通过对于状态变量的操作给块作记号(因为没有精确到block的instruction能力)
all_block_status = {}
while current_block.nextb != None:
current_block: mblock_t = mba.get_mblock(i)
# print(f"block-visitor: {hex(current_block.start)} - {hex(current_block.end)}")
block_kind = check_block(current_block)
# 通过block的define-use判断block的形态
all_block_status[current_block] = block_kind
i += 1def check_block(one_block, reg_bit_value = 72) -> int:
must_use = one_block.mustbuse
may_use = one_block.maybuse
must_def = one_block.mustbdef
may_def = one_block.maybdef
use_reg = False
define_reg = False
if must_use.reg.has(reg_bit_value) or may_use.reg.has(reg_bit_value):
use_reg = True
if must_def.reg.has(reg_bit_value) or may_def.reg.has(reg_bit_value):
define_reg = True
if use_reg and (not define_reg):
# 使用但是不定义,这是分发块
print(f"dispatch-block: {hex(one_block.start)} - {hex(one_block.end)}")
return 2
elif define_reg:
# 定义了,要不是真实块,要不是头部块
print(f"real-block: {hex(one_block.start)} - {hex(one_block.end)}")
return 1
else:
print(f"unknown-block: {hex(one_block.start)} - {hex(one_block.end)}")
return 0