diff options
| author | Anestis Bechtsoudis <anestis@census-labs.com> | 2018-09-08 22:32:29 +0300 |
|---|---|---|
| committer | Anestis Bechtsoudis <anestis@census-labs.com> | 2018-09-10 23:21:28 +0300 |
| commit | 8583bec99a94c47831da2a54bd097ecf1f08347a (patch) | |
| tree | 2fa8c70e44ba3e95a0b52c3a427224494694a8c9 /libdexfile | |
| parent | 9c987cac63304d3a9efef800e25cd86f313c1b09 (diff) | |
| download | art-8583bec99a94c47831da2a54bd097ecf1f08347a.tar.gz art-8583bec99a94c47831da2a54bd097ecf1f08347a.tar.bz2 art-8583bec99a94c47831da2a54bd097ecf1f08347a.zip | |
oatdump: Convert cdex before exporting dex files
Use DexLayout to convert the compact dex files inside a vdex container
back to a standard dex file before exporting. There is limited benefit
when exporting a cdex file since it is an art internal format that is
not supported from most dex parsers/tools. Backwards compatibility is
still maintained, although not really useful since the oat loader will
reject files of different versions.
Also since commit 734806, the VdexFile::UnquickenDexFile() is no longer
implementing apis unhiding. Therefore, the oatdump should manually
unhide them before exporting. Otherwise the verifier will complain
when reading the exported standard dex files.
This feature is mostly useful when inspecting oat files that have the
original bytecode being stripped from the matching archive (apk, jar).
Test: oatdump --oat-file=services.odex --export-dex-to=/tmp \
--header-only && dexdump2 /tmp/services.jar_export.dex (manual)
Test: test-art-host-gtest
Change-Id: Ide79c5b778f1d6d6b4e58a95811e66cccb20735e
Signed-off-by: Anestis Bechtsoudis <anestis@census-labs.com>
Diffstat (limited to 'libdexfile')
| -rw-r--r-- | libdexfile/dex/dex_file.cc | 11 | ||||
| -rw-r--r-- | libdexfile/dex/dex_file.h | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc index a2198b7c98..a3e62216b0 100644 --- a/libdexfile/dex/dex_file.cc +++ b/libdexfile/dex/dex_file.cc @@ -60,6 +60,17 @@ void DexFile::UnHideAccessFlags(uint8_t* data_ptr, UpdateUnsignedLeb128(data_ptr, new_access_flags); } +void DexFile::UnhideApis() const { + for (ClassAccessor accessor : GetClasses()) { + for (const ClassAccessor::Field& field : accessor.GetFields()) { + field.UnHideAccessFlags(); + } + for (const ClassAccessor::Method& method : accessor.GetMethods()) { + method.UnHideAccessFlags(); + } + } +} + uint32_t DexFile::CalculateChecksum() const { return CalculateChecksum(Begin(), Size()); } diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h index 98787d1dd0..fc218fba71 100644 --- a/libdexfile/dex/dex_file.h +++ b/libdexfile/dex/dex_file.h @@ -1013,6 +1013,9 @@ class DexFile { // Changes the dex class data pointed to by data_ptr it to not have any hiddenapi flags. static void UnHideAccessFlags(uint8_t* data_ptr, uint32_t new_access_flags, bool is_method); + // Iterate dex classes and remove hiddenapi flags in fields and methods. + void UnhideApis() const; + inline IterationRange<ClassIterator> GetClasses() const; protected: |
