Introduce MetaAddress

`MetaAddress` replaces all the `uint64_t` used to represent a virtual
address. Its main features are:

* It has a non-zero representation of invalid addresses.
* It supports tags to represent code that has different interpretations but
  resides at the same address in memory (namely ARM vs Thumb).
* Arithmetic operations cannot overflow.
* It supports epochs, a way we intend to employ to handle self-modifying code
  (i.e., different code at the same address at different times).
* It supports "address spaces", which enable handling architectures with
  multiple address spaces.
* It fits in two 64-bit registers.
This commit is contained in:
Alessandro Di Federico
2019-08-29 11:40:07 +02:00
parent e336a33545
commit dc48188f37
27 changed files with 991 additions and 423 deletions
+5 -1
View File
@@ -26,6 +26,10 @@ static RegisterGCBI X("gcbi", "Generated Code Basic Info", true, true);
bool GeneratedCodeBasicInfo::runOnModule(llvm::Module &M) {
Function &F = *M.getFunction("root");
NewPC = M.getFunction("newpc");
if (NewPC != nullptr) {
MetaAddressStruct = cast<StructType>(NewPC->arg_begin()->getType());
}
revng_log(PassesLog, "Starting GeneratedCodeBasicInfo");
@@ -83,7 +87,7 @@ bool GeneratedCodeBasicInfo::runOnModule(llvm::Module &M) {
case BlockType::JumpTargetBlock: {
auto *Call = cast<CallInst>(&*BB.begin());
revng_assert(Call->getCalledFunction()->getName() == "newpc");
JumpTargets[getLimitedValue(Call->getArgOperand(0))] = &BB;
JumpTargets[MetaAddress::fromConstant(Call->getArgOperand(0))] = &BB;
break;
}
case BlockType::EntryPoint: