Files
yusufcanislek ad41d97112 fix: correctness bugs and inconsistencies in post-lifting passes
GEPLoadPass:
- Check readMemory return value; previously used uninitialized memory
  as a constant replacement on failure (UB + silent miscompile)
- Guard against non-integer load types; getIntegerBitWidth() asserts on
  float/vector/pointer types, causing a crash
- Only process GEPs rooted on the lifter's memory base pointer, not
  arbitrary GEPs created by LLVM optimizations
- Erase replaced LoadInsts and dead GEPs immediately instead of leaving
  dead instructions for the next DCE pass

PromotePseudoStackPass:
- Promote stack accesses both below AND above STACKP_VALUE; previously
  only captured below, missing return address, shadow space, and
  stack-passed arguments
- Use explicit stack bounds [STACKP_VALUE-reserve, STACKP_VALUE+reserve]
  instead of isConcrete(), which would also capture PE image sections
  and create a multi-gigabyte alloca
- Add stackReserve field to lifter class, set by configureDefaultMemoryPolicy
- Guard against unsigned underflow in stackLower computation

ReplaceTruncWithLoadPass:
- Generalize from hardcoded i64->i32 to any integer narrowing; now also
  handles i32->i16, i16->i8, etc.
- Erase original wide LoadInst when it has no remaining users

Stack bounds consistency:
- pageMap (markMemPaged/isMemPaged) now uses clamped stack reserve from
  lifter->stackReserve instead of raw PE header value, so pageMap,
  memoryPolicy, and PromotePseudoStackPass all agree on stack bounds
- Changed pageMap, markMemPaged, isMemPaged from int64_t to uint64_t
  to match the actual address types and avoid signed/unsigned mismatch

Cleanup:
- Remove dead final_optpass declaration from PathSolver.h (no impl/callers)
- Remove fragile name-based 'memory' argument fallback in run_opts;
  assert memoryAlloc is set instead
2026-03-26 11:46:03 +03:00

17 lines
458 B
C

#pragma once
#include "MemoryPolicy.hpp"
#include <llvm/IR/Function.h>
#include <llvm/IR/Value.h>
enum PATH_info {
PATH_unsolved = 0,
PATH_solved = 1,
PATH_multi_solved = 2, // >2 targets resolved via SwitchInst
};
PATH_info getConstraintVal(llvm::Function* function, llvm::Value* constraint,
uint64_t& dest);
PATH_info solvePath(llvm::Function* function, uint64_t& dest,
llvm::Value* simplifyValue);