mirror of
https://github.com/lifting-bits/remill
synced 2026-06-21 13:56:07 +00:00
Fix bug with uninitialized MONITOR variable causing UB
This commit is contained in:
committed by
Kyle Elliott
parent
eba0652f86
commit
6082054723
+5
-1
@@ -758,7 +758,11 @@ void Arch::InitializeEmptyLiftedFunction(llvm::Function *func) const {
|
||||
llvm::IRBuilder<> ir(block);
|
||||
ir.CreateAlloca(u8, nullptr, "BRANCH_TAKEN");
|
||||
ir.CreateAlloca(addr, nullptr, "RETURN_PC");
|
||||
ir.CreateAlloca(addr, nullptr, "MONITOR");
|
||||
|
||||
// NOTE: we need to start with an initialize MONITOR state,
|
||||
// otherwise STLXR without a preceding LDXR/LDAXR will do UB
|
||||
auto monitor = ir.CreateAlloca(addr, nullptr, "MONITOR");
|
||||
ir.CreateStore(llvm::ConstantInt::get(addr, 0), monitor);
|
||||
|
||||
// NOTE(pag): `PC` and `NEXT_PC` are handled by
|
||||
// `FinishLiftedFunctionInitialization`.
|
||||
|
||||
Reference in New Issue
Block a user