Skip to content

Commit 3aea800

Browse files
committed
fix: lab8 no angr
1 parent 37d8c2e commit 3aea800

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

.github/workflows/lab-autograding.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ jobs:
5656
if [ ${{ steps.lab.outputs.result }} -eq 6 ]; then
5757
sudo apt install -y llvm-14
5858
fi
59+
if [ ${{ steps.lab.outputs.result }} -eq 8 ]; then
60+
python3 -m pip install angr
61+
fi
5962
./validate.sh

lab6/llvm-pass.so.cc

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,7 @@ PreservedAnalyses LLVMPass::run(Module &M, ModuleAnalysisManager &MAM) {
1313
IntegerType *Int32Ty = IntegerType::getInt32Ty(Ctx);
1414
FunctionCallee debug_func = M.getOrInsertFunction("debug", Int32Ty);
1515
ConstantInt *debug_arg = ConstantInt::get(Int32Ty, 48763);
16-
PointerType *CharPtrTy = Type::getInt8PtrTy(Ctx);
1716

18-
19-
Function *MainFunc = M.getFunction("main");
20-
if (!MainFunc) {
21-
errs() << "Could not find main function\n";
22-
return PreservedAnalyses::none();
23-
}
24-
25-
BasicBlock &EntryBB = MainFunc->getEntryBlock();
26-
IRBuilder<> Builder(&*EntryBB.begin());
27-
28-
29-
Builder.CreateCall(debug_func, {debug_arg});
30-
31-
32-
Constant *HayakuStr = ConstantDataArray::getString(Ctx, "hayaku... motohayaku!", true);
33-
GlobalVariable *HayakuGV = new GlobalVariable(M, HayakuStr->getType(), true,
34-
GlobalValue::PrivateLinkage, HayakuStr, ".str");
35-
36-
37-
Constant *Zero = ConstantInt::get(Int32Ty, 0);
38-
std::vector<Constant*> Indices = {Zero, Zero};
39-
Constant *HayakuPtr = ConstantExpr::getGetElementPtr(HayakuStr->getType(), HayakuGV, Indices);
40-
41-
42-
Value *Argv = &*std::next(MainFunc->arg_begin());
43-
Value *ArgvIdx = Builder.CreateGEP(CharPtrTy, Argv, Builder.getInt32(1));
44-
Builder.CreateStore(HayakuPtr, ArgvIdx);
45-
46-
47-
AllocaInst *LocalArgc = Builder.CreateAlloca(Int32Ty, nullptr, "local_argc");
48-
49-
50-
Builder.CreateStore(debug_arg, LocalArgc);
51-
52-
Value *Argc = &*MainFunc->arg_begin();
53-
SmallVector<User*, 8> Users(Argc->user_begin(), Argc->user_end());
54-
55-
for (User *U : Users) {
56-
if (Instruction *I = dyn_cast<Instruction>(U)) {
57-
IRBuilder<> UseBuilder(I);
58-
Value *LoadedArgc = UseBuilder.CreateLoad(Int32Ty, LocalArgc);
59-
I->replaceUsesOfWith(Argc, LoadedArgc);
60-
}
61-
}
6217
for (auto &F : M) {
6318
errs() << "func: " << F.getName() << "\n";
6419

0 commit comments

Comments
 (0)