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

Commit

Permalink
Fixes issue identified by BoLei related to a function that has no ass…
Browse files Browse the repository at this point in the history
…ociated basic blocks in the CFG (#707)
  • Loading branch information
Peter Goodman authored Oct 26, 2020
1 parent ecc8ba9 commit c96402c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions mcsema/BC/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,12 +1436,6 @@ static llvm::Function *LiftFunction(const NativeModule *cfg_module,
return lifted_func;
}

if (cfg_func->blocks.empty()) {
LOG(WARNING) << "Function " << cfg_func->lifted_name << " is empty!";
remill::AddTerminatingTailCall(lifted_func, intrinsics.missing_block);
return lifted_func;
}

remill::CloneBlockFunctionInto(lifted_func);

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

// Collect the known set of blocks into a work list, and add basic blocks
// for each of them.
for (const auto cfg_block : cfg_func->blocks) {
const auto block_ea = cfg_block->ea;
(void) GetOrCreateBlock(ctx, block_ea, true /* force */);
if (cfg_func->blocks.empty()) {
LOG(WARNING) << "Function " << cfg_func->lifted_name << " is empty!";
GetOrCreateBlock(ctx, cfg_func->ea, true /* force */);

} else {
for (const auto cfg_block : cfg_func->blocks) {
const auto block_ea = cfg_block->ea;
(void) GetOrCreateBlock(ctx, block_ea, true /* force */);
}
}

std::sort(ctx.work_list.begin(), ctx.work_list.end(),
Expand Down

0 comments on commit c96402c

Please sign in to comment.