From a59dd80f9f48cb750d329d4d4af2d99d72b484d1 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Wed, 2 Jul 2014 16:28:08 -0700 Subject: Runtime can now be set to require relocation Add a pair of runtime flags -Xrelocate and -Xnorelocate that can force the runtime to require that all files that are run are relocated, to prevent attacks based on the known art base address. Add support for running patchoat on oat files compiled without an image. Change run-test to have new --prebuild and --relocate flags. Bug: 15358152 Change-Id: I91166c62dd1ab80e5cbcb7883a2cd0d56afca32d --- runtime/runtime.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'runtime/runtime.cc') diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 0398365..b7eae85 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -101,6 +101,7 @@ Runtime::Runtime() instruction_set_(kNone), compiler_callbacks_(nullptr), is_zygote_(false), + must_relocate_(false), is_concurrent_gc_enabled_(true), is_explicit_gc_disabled_(false), default_stack_size_(0), @@ -385,6 +386,15 @@ jobject CreateSystemClassLoader() { return env->NewGlobalRef(system_class_loader.get()); } +std::string Runtime::GetPatchoatExecutable() const { + if (!patchoat_executable_.empty()) { + return patchoat_executable_; + } + std::string patchoat_executable_(GetAndroidRoot()); + patchoat_executable_ += (kIsDebugBuild ? "/bin/patchoatd" : "/bin/patchoat"); + return patchoat_executable_; +} + std::string Runtime::GetCompilerExecutable() const { if (!compiler_executable_.empty()) { return compiler_executable_; @@ -557,6 +567,8 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) properties_ = options->properties_; compiler_callbacks_ = options->compiler_callbacks_; + patchoat_executable_ = options->patchoat_executable_; + must_relocate_ = options->must_relocate_; is_zygote_ = options->is_zygote_; is_explicit_gc_disabled_ = options->is_explicit_gc_disabled_; -- cgit v1.1