From 009e172a8f30d1538000866932d5e62c0b64e493 Mon Sep 17 00:00:00 2001 From: 2over12 Date: Wed, 28 Feb 2024 07:27:51 -0500 Subject: [PATCH 1/6] bump remill and fix initial state pc --- lib/Lifters/BasicBlockLifter.cpp | 14 +++++++++----- libraries/lifting-tools-ci | 2 +- remill | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Lifters/BasicBlockLifter.cpp b/lib/Lifters/BasicBlockLifter.cpp index f0a81d36a..ec402cfbc 100644 --- a/lib/Lifters/BasicBlockLifter.cpp +++ b/lib/Lifters/BasicBlockLifter.cpp @@ -200,7 +200,7 @@ bool BasicBlockLifter::DoInterProceduralControlFlow( auto func = block->getParent(); auto should_return = func->getArg(kShouldReturnArgNum); builder.CreateStore(llvm::Constant::getAllOnesValue( - llvm::IntegerType::getInt1Ty(llvm_context)), + llvm::IntegerType::getInt1Ty(llvm_context)), should_return); } } @@ -417,7 +417,8 @@ llvm::MDNode *BasicBlockLifter::GetBasicBlockUidAnnotation(Uid uid) const { llvm::Function *BasicBlockLifter::DeclareBasicBlockFunction() { std::string name_ = "func" + std::to_string(decl.address) + "basic_block" + - std::to_string(this->block_def.addr) + "_" + std::to_string(this->block_def.uid.value); + std::to_string(this->block_def.addr) + "_" + + std::to_string(this->block_def.uid.value); auto &context = this->semantics_module->getContext(); llvm::FunctionType *lifted_func_type = llvm::dyn_cast(remill::RecontextualizeType( @@ -597,7 +598,8 @@ BasicBlockFunction BasicBlockLifter::CreateBasicBlockFunction() { auto pc_ptr = pc_reg->AddressOf(this->state_ptr, ir); auto pc_val = this->options.program_counter_init_procedure( ir, this->address_type, this->block_def.addr); - ir.CreateStore(pc_val, pc_ptr); + + ir.CreateStore(ir.CreateZExtOrTrunc(pc_val, pc_reg_type), pc_ptr); std::array args = { this->state_ptr, pc_val, mem_res, next_pc, should_return}; @@ -648,7 +650,8 @@ void BasicBlockLifter::TerminateBasicBlockFunction( llvm::IRBuilder<> calling_bb_builder(calling_bb); auto edge_bb = this->decl.cfg.find(edge_uid); CHECK(edge_bb != this->decl.cfg.end()); - auto &child_lifter = this->flifter.GetOrCreateBasicBlockLifter(edge_bb->second.uid); + auto &child_lifter = + this->flifter.GetOrCreateBasicBlockLifter(edge_bb->second.uid); auto retval = child_lifter.ControlFlowCallBasicBlockFunction( caller, calling_bb_builder, this->state_ptr, bbfunc.stack, next_mem); if (this->flifter.curr_decl->type->getReturnType()->isVoidTy()) { @@ -658,7 +661,8 @@ void BasicBlockLifter::TerminateBasicBlockFunction( } auto succ_const = llvm::ConstantInt::get( - llvm::cast(this->address_type), edge_bb->second.addr); + llvm::cast(this->address_type), + edge_bb->second.addr); sw->addCase(succ_const, calling_bb); } diff --git a/libraries/lifting-tools-ci b/libraries/lifting-tools-ci index 8322d34e2..95b0aa262 160000 --- a/libraries/lifting-tools-ci +++ b/libraries/lifting-tools-ci @@ -1 +1 @@ -Subproject commit 8322d34e2360688938f2ef9ba877aaa613101e32 +Subproject commit 95b0aa2621908df4982a18b02ef50fcb94d1044c diff --git a/remill b/remill index 17cff6b4d..cd3a3705e 160000 --- a/remill +++ b/remill @@ -1 +1 @@ -Subproject commit 17cff6b4df900c68ff583debec5fabe76a01d9a5 +Subproject commit cd3a3705e61c50af8655d92e20551c0ab51c0f89 From 68c08c8e709c86c88455950d9acf5402eda16a02 Mon Sep 17 00:00:00 2001 From: 2over12 Date: Wed, 28 Feb 2024 11:17:12 -0500 Subject: [PATCH 2/6] bump remill --- remill | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remill b/remill index cd3a3705e..874490a89 160000 --- a/remill +++ b/remill @@ -1 +1 @@ -Subproject commit cd3a3705e61c50af8655d92e20551c0ab51c0f89 +Subproject commit 874490a894c5c8f0920af0fb583ca500abc5d65d From 486a80abdbaeeb6de4750971c4c5eed49c261967 Mon Sep 17 00:00:00 2001 From: William Tan <1284324+Ninja3047@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:54:11 -0500 Subject: [PATCH 3/6] don't install python3 bindings in CI --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57f6a23ec..b11855114 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -286,6 +286,7 @@ jobs: -Dsleigh_DIR:PATH=${{ steps.remill_installer.outputs.PATH }}/usr/local/lib/cmake/sleigh \ -DANVILL_ENABLE_TESTS=true \ -DANVILL_ENABLE_INSTALL=true \ + -DANVILL_INSTALL_PYTHON3_LIBS=false \ -G Ninja \ ${{ steps.build_paths.outputs.SOURCE }}/anvill From 8a586f75882900225059159bfea126f51a080615 Mon Sep 17 00:00:00 2001 From: 2over12 Date: Wed, 28 Feb 2024 13:08:04 -0500 Subject: [PATCH 4/6] dont set body twice if struct named twice --- lib/Protobuf.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Protobuf.cpp b/lib/Protobuf.cpp index 9e267f867..1064876c6 100644 --- a/lib/Protobuf.cpp +++ b/lib/Protobuf.cpp @@ -933,7 +933,9 @@ Result ProtobufTranslator::DecodeTypeMap( std::string name = names.at(k); auto res = getOrCreateNamedStruct(this->context, name); - res->setBody(sty->elements()); + if (res->isOpaque()) { + res->setBody(sty->elements()); + } } type_names[k] = names.at(k); } else { From 7580fc91feac127938b194a9f202ee318a67bd2b Mon Sep 17 00:00:00 2001 From: 2over12 Date: Wed, 28 Feb 2024 13:13:35 -0500 Subject: [PATCH 5/6] completely remove python --- lib/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 16d3e66b1..882775249 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -198,10 +198,6 @@ target_link_libraries(anvill add_dependencies(anvill check_git_anvill) -if(ANVILL_ENABLE_PYTHON3_LIBS) - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../python" python) -endif() - # if(ANVILL_ENABLE_TESTS) # add_subdirectory("tests") # endif() From b8ab33b4c6f33b0e7e868d5e49e0dcd652aeb6b4 Mon Sep 17 00:00:00 2001 From: 2over12 Date: Wed, 28 Feb 2024 14:21:50 -0500 Subject: [PATCH 6/6] try to be robust to overlapping vars --- lib/Passes/ReplaceStackReferences.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Passes/ReplaceStackReferences.cpp b/lib/Passes/ReplaceStackReferences.cpp index 60c94a38d..958cd5021 100644 --- a/lib/Passes/ReplaceStackReferences.cpp +++ b/lib/Passes/ReplaceStackReferences.cpp @@ -235,11 +235,12 @@ class StackModel { GetParamDeclSize(var) - 1); } - LOG(FATAL) << "Inserting variable that overlaps with current frame " + LOG(ERROR) << "Inserting variable that overlaps with current frame " << var.ordered_locs[0].mem_offset << " with size: " << GetParamDeclSize(var) << " Overlaps with " << oparam->decl.decl.ordered_locs[0].mem_offset << " with size " << GetParamDeclSize(oparam->decl.decl); + return; } this->frame.insert({var.ordered_locs[0].mem_offset, {index, var}});