Add patchoat tool to Art.
Add a new executable called patchoat to art. This tool takes already
compiled images and oat files and changes their base address, acting as
a cheap form of relocation.
Add a --include-patch-information flag to dex2oat and code to add
required patch information to oat files created with the quick compiler.
Bug: 15358152
Change-Id: Ie0c580db45bb14ec180deb84930def6c3628d97d
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 3387f91..80e7724 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -60,6 +60,7 @@
#include "runtime.h"
#include "ScopedLocalRef.h"
#include "scoped_thread_state_change.h"
+#include "utils.h"
#include "vector_output_stream.h"
#include "well_known_classes.h"
#include "zip_archive.h"
@@ -144,8 +145,8 @@
UsageError(" Example: --android-root=out/host/linux-x86");
UsageError(" Default: $ANDROID_ROOT");
UsageError("");
- UsageError(" --instruction-set=(arm|arm64|mips|x86|x86_64): compile for a particular instruction");
- UsageError(" set.");
+ UsageError(" --instruction-set=(arm|arm64|mips|x86|x86_64): compile for a particular");
+ UsageError(" instruction set.");
UsageError(" Example: --instruction-set=x86");
UsageError(" Default: arm");
UsageError("");
@@ -203,6 +204,11 @@
UsageError("");
UsageError(" --dump-timing: display a breakdown of where time was spent");
UsageError("");
+ UsageError(" --include-patch-information: Include patching information so the generated code");
+ UsageError(" can have its base address moved without full recompilation.");
+ UsageError("");
+ UsageError(" --no-include-patch-information: Do not include patching information.");
+ UsageError("");
UsageError(" --include-debug-symbols: Include ELF symbols in this oat file");
UsageError("");
UsageError(" --no-include-debug-symbols: Do not include ELF symbols in this oat file");
@@ -271,7 +277,7 @@
LOG(ERROR) << "Failed to open image classes file " << image_classes_filename;
return nullptr;
}
- std::unique_ptr<CompilerDriver::DescriptorSet> result(ReadImageClasses(*image_classes_file.get()));
+ std::unique_ptr<CompilerDriver::DescriptorSet> result(ReadImageClasses(*image_classes_file));
image_classes_file->close();
return result.release();
}
@@ -510,16 +516,6 @@
DISALLOW_IMPLICIT_CONSTRUCTORS(Dex2Oat);
};
-static bool ParseInt(const char* in, int* out) {
- char* end;
- int result = strtol(in, &end, 10);
- if (in == end || *end != '\0') {
- return false;
- }
- *out = result;
- return true;
-}
-
static size_t OpenDexFiles(const std::vector<const char*>& dex_filenames,
const std::vector<const char*>& dex_locations,
std::vector<const DexFile*>& dex_files) {
@@ -827,6 +823,8 @@
bool dump_stats = false;
bool dump_timing = false;
bool dump_passes = false;
+ bool include_patch_information = CompilerOptions::kDefaultIncludePatchInformation;
+ bool explicit_include_patch_information = false;
bool include_debug_symbols = kIsDebugBuild;
bool dump_slow_timing = kIsDebugBuild;
bool watch_dog_enabled = !kIsTargetBuild;
@@ -1037,6 +1035,12 @@
}
}
has_explicit_checks_options = true;
+ } else if (option == "--include-patch-information") {
+ include_patch_information = true;
+ explicit_include_patch_information = true;
+ } else if (option == "--no-include-patch-information") {
+ include_patch_information = false;
+ explicit_include_patch_information = true;
} else {
Usage("Unknown argument %s", option.data());
}
@@ -1166,6 +1170,11 @@
CheckExplicitCheckOptions(instruction_set, &explicit_null_checks, &explicit_so_checks,
&explicit_suspend_checks);
+ if (!explicit_include_patch_information) {
+ include_patch_information =
+ (compiler_kind == Compiler::kQuick && CompilerOptions::kDefaultIncludePatchInformation);
+ }
+
CompilerOptions compiler_options(compiler_filter,
huge_method_threshold,
large_method_threshold,
@@ -1173,6 +1182,7 @@
tiny_method_threshold,
num_dex_methods_threshold,
generate_gdb_information,
+ include_patch_information,
top_k_profile_threshold,
include_debug_symbols,
explicit_null_checks,