Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit c96402c

Browse files
author
Peter Goodman
authored
Fixes issue identified by BoLei related to a function that has no associated basic blocks in the CFG (#707)
1 parent ecc8ba9 commit c96402c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mcsema/BC/Function.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,12 +1436,6 @@ static llvm::Function *LiftFunction(const NativeModule *cfg_module,
14361436
return lifted_func;
14371437
}
14381438

1439-
if (cfg_func->blocks.empty()) {
1440-
LOG(WARNING) << "Function " << cfg_func->lifted_name << " is empty!";
1441-
remill::AddTerminatingTailCall(lifted_func, intrinsics.missing_block);
1442-
return lifted_func;
1443-
}
1444-
14451439
remill::CloneBlockFunctionInto(lifted_func);
14461440

14471441
lifted_func->removeFnAttr(llvm::Attribute::NoReturn);
@@ -1473,9 +1467,15 @@ static llvm::Function *LiftFunction(const NativeModule *cfg_module,
14731467

14741468
// Collect the known set of blocks into a work list, and add basic blocks
14751469
// for each of them.
1476-
for (const auto cfg_block : cfg_func->blocks) {
1477-
const auto block_ea = cfg_block->ea;
1478-
(void) GetOrCreateBlock(ctx, block_ea, true /* force */);
1470+
if (cfg_func->blocks.empty()) {
1471+
LOG(WARNING) << "Function " << cfg_func->lifted_name << " is empty!";
1472+
GetOrCreateBlock(ctx, cfg_func->ea, true /* force */);
1473+
1474+
} else {
1475+
for (const auto cfg_block : cfg_func->blocks) {
1476+
const auto block_ea = cfg_block->ea;
1477+
(void) GetOrCreateBlock(ctx, block_ea, true /* force */);
1478+
}
14791479
}
14801480

14811481
std::sort(ctx.work_list.begin(), ctx.work_list.end(),

0 commit comments

Comments
 (0)