Add shadow stack support to Dex compiler.
Change-Id: I8e188be3fb30c81e2a9e6e466264074ddf7b1624
diff --git a/src/compiler_llvm/ir_builder.cc b/src/compiler_llvm/ir_builder.cc
index 582af65..30ed6ec 100644
--- a/src/compiler_llvm/ir_builder.cc
+++ b/src/compiler_llvm/ir_builder.cc
@@ -16,6 +16,7 @@
#include "ir_builder.h"
#include "runtime_support_func.h"
+#include "stringprintf.h"
#include <llvm/Module.h>
@@ -39,6 +40,10 @@
llvm::Type* jenv_struct_type = llvm::StructType::create(context, "JEnv");
jenv_type_ = jenv_struct_type->getPointerTo();
+ // Get Art shadow frame struct type from module
+ art_frame_type_ = module.getTypeByName("ArtFrame");
+ CHECK_NE(art_frame_type_, static_cast<llvm::StructType*>(NULL));
+
// Load the runtime support function declaration from module
InitRuntimeSupportFuncDecl();
}
@@ -179,5 +184,24 @@
}
+llvm::StructType* IRBuilder::getShadowFrameTy(uint32_t sirt_size) {
+ std::string name(StringPrintf("ArtFrame%u", sirt_size));
+
+ // Try to find the existing struct type definition
+ if (llvm::Type* type = module_->getTypeByName(name)) {
+ CHECK(llvm::isa<llvm::StructType>(type));
+ return static_cast<llvm::StructType*>(type);
+ }
+
+ // Create new struct type definition
+ llvm::Type* elem_types[] = {
+ art_frame_type_,
+ llvm::ArrayType::get(jobject_type_, sirt_size),
+ };
+
+ return llvm::StructType::create(elem_types, name);
+}
+
+
} // namespace compiler_llvm
} // namespace art