diff options
author | 2017-10-23 13:53:13 -0700 | |
---|---|---|
committer | 2018-01-10 09:17:41 -0800 | |
commit | fbe5f2f85244bf57707afb5520b2f9aa189d9d55 (patch) | |
tree | ad98d2749023f6661b485b0466fc992505fa3019 /patchoat/patchoat.h | |
parent | 680e88ba30d1c599c5eaab4a207db3e39bf2d57f (diff) |
Enable patchoat to write image relocation files
This adds an off by default feature to patchoat whereby it can write
image relocation information (i.e., which offsets are patched up by
patchoat) to .rel files. .rel file writing is enabled by specifying
the name of boot.art.rel file using command-line parameter
--output-image-relocation-file=...
The currently intended use case is to make the Android build process
store these files on the system image next to boot*.art files. At boot
time, in follow-up commits, these .rel files will then be used to
verify that all differences between /system boot*.art and
/data/dalvik-cache boot*.art files can be explained by relocation. The
goal is to mitigate /data/dalvik-cache boot*.art being a persistence
vector.
Test: ./art/test/testrunner/run_build_test_target.py art-gtest-debug-gc
Test: make test-art-host-gtest-patchoat_test
Test: make test-art-target-gtest-patchoat_test
Test: ANDROID_ROOT=out/target/product/sailfish/system \
ANDROID_DATA=out/target/product/sailfish/dex_bootjars/system/framework/arm64/ \
out/host/linux-x86/bin/patchoat \
--input-image-location=<full path to>/out/target/product/sailfish/dex_bootjars/system/framework/boot.art \
--output-image-file=out/target/product/sailfish/dex_bootjars/system/framework/arm64/boot.art \
--instruction-set=arm64 --base-offset-delta=0x10000000
produces same boot*.art files as prior to this change
Test: ANDROID_ROOT=out/target/product/sailfish/system \
ANDROID_DATA=out/target/product/sailfish/dex_bootjars/system/framework/arm64/ \
out/host/linux-x86/bin/patchoat \
--input-image-location=<full path to>/out/target/product/sailfish/dex_bootjars/system/framework/boot.art \
--output-image-relocation-file=out/target/product/sailfish/dex_bootjars/system/framework/arm64/boot.art.rel \
--instruction-set=arm64 --base-offset-delta=0x10000000
produces no boot*.art files, but produces expected boot.art.rel files
Bug: 66697305
Change-Id: If18814f03dba3d72ae15981625473f4da303b1d6
Diffstat (limited to 'patchoat/patchoat.h')
-rw-r--r-- | patchoat/patchoat.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/patchoat/patchoat.h b/patchoat/patchoat.h index 83516845d8..1033a2e5e1 100644 --- a/patchoat/patchoat.h +++ b/patchoat/patchoat.h @@ -44,12 +44,25 @@ class Class; class PatchOat { public: + // Relocates the provided image by the specified offset. If output_image_directory is non-empty, + // outputs the relocated image into that directory. If output_image_relocation_directory is + // non-empty, outputs image relocation files (see GeneratePatch) into that directory. static bool Patch(const std::string& image_location, off_t delta, - const std::string& output_directory, + const std::string& output_image_directory, + const std::string& output_image_relocation_directory, InstructionSet isa, TimingLogger* timings); + // Generates a patch which can be used to efficiently relocate the original file or to check that + // a relocated file matches the original. The patch is generated from the difference of the + // |original| and the already |relocated| image, and written to |output| in the form of unsigned + // LEB128 for each relocation position. + static bool GeneratePatch(const MemMap& original, + const MemMap& relocated, + std::vector<uint8_t>* output, + std::string* error_msg); + ~PatchOat() {} PatchOat(PatchOat&&) = default; |