dexdump: Expand version check to allow 039 DEX files
Remove unused logic for extended bytecodes libdex/DexOpcodes.h which
breaks dexdump output for the const-method-type bytecode. This dates
back to 111221644 when there were raw and packed opcodes.
Add --no-clean option to the dx run-test script to use DEX file from
test to validate dexdump (dexdump is deprecated and has no tests of
it's own).
Bug: 117409365
Bug: 117767860
Test: dalvik/dx/run-test --no-clean 142-const-method-handle && dexdump -d ${TEST_DIR}/constmethodhandle.dex
(cherry picked from commit ea2a4f6e68fc75705d0c4d1298605696dbfa30d1)
Change-Id: Id7aa87a7d1634d4ccd2a96fc4b27da36fbc28cc6
diff --git a/dx/tests/run-test b/dx/tests/run-test
index f205c46..a781d8d 100755
--- a/dx/tests/run-test
+++ b/dx/tests/run-test
@@ -54,6 +54,7 @@
expected="expected.txt"
output="out.txt"
+clean_on_exit="yes"
dev_mode="no"
update_mode="no"
tmpdir=/tmp/test-$$
@@ -61,7 +62,8 @@
while [[ "x$1" = "x-"* ]]; do
case $1 in
- --dev) dev_mode="yes" ;;
+ --dev) dev_mode="yes" ;;
+ --no-clean) clean_on_exit="no" ;;
--output_dir)
tmpdir=$2
shift ;;
@@ -156,7 +158,11 @@
if [ "$good" = "yes" ]; then
cd "$oldwd"
- rm -rf "$tmpdir"
+ if [ "$clean_on_exit" = "yes" ]; then
+ rm -rf "$tmpdir"
+ else
+ echo "Test artifacts left in $tmpdir"
+ fi
exit 0
fi
diff --git a/libdex/DexOpcodes.h b/libdex/DexOpcodes.h
index 1c684ab..f4dcd6b 100644
--- a/libdex/DexOpcodes.h
+++ b/libdex/DexOpcodes.h
@@ -609,11 +609,7 @@
* that data tables get generated in a consistent way.
*/
int lowByte = codeUnit & 0xff;
- if (lowByte != 0xff) {
- return (Opcode) lowByte;
- } else {
- return (Opcode) ((codeUnit >> 8) | 0x100);
- }
+ return (Opcode) lowByte;
}
/*
diff --git a/libdex/DexSwapVerify.cpp b/libdex/DexSwapVerify.cpp
index 8836ab2..1f8eed8 100644
--- a/libdex/DexSwapVerify.cpp
+++ b/libdex/DexSwapVerify.cpp
@@ -2908,7 +2908,8 @@
if ((memcmp(version, DEX_MAGIC_VERS, 4) != 0) &&
(memcmp(version, DEX_MAGIC_VERS_API_13, 4) != 0) &&
(memcmp(version, DEX_MAGIC_VERS_37, 4) != 0) &&
- (memcmp(version, DEX_MAGIC_VERS_38, 4) != 0)) {
+ (memcmp(version, DEX_MAGIC_VERS_38, 4) != 0) &&
+ (memcmp(version, DEX_MAGIC_VERS_39, 4) != 0)) {
/*
* Magic was correct, but this is an unsupported older or
* newer format variant.