Add an option for disabling dex file verifier.

Useful for boot classpath dex files, that may contain
hidden api flags.

bug: 73879013
Test: dexdump2 -b -d out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar

Change-Id: I38513c357473a751ad826c6974c0b3eefd04bfea
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index 61a1209..9536381 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -1882,10 +1882,11 @@
     fprintf(gOutFile, "Processing '%s'...\n", fileName);
   }
 
+  const bool kVerifyChecksum = !gOptions.ignoreBadChecksum;
+  const bool kVerify = !gOptions.disableVerifier;
+  std::string content;
   // If the file is not a .dex file, the function tries .zip/.jar/.apk files,
   // all of which are Zip archives with "classes.dex" inside.
-  const bool kVerifyChecksum = !gOptions.ignoreBadChecksum;
-  std::string content;
   // TODO: add an api to android::base to read a std::vector<uint8_t>.
   if (!android::base::ReadFileToString(fileName, &content)) {
     LOG(ERROR) << "ReadFileToString failed";
@@ -1897,7 +1898,7 @@
   if (!dex_file_loader.OpenAll(reinterpret_cast<const uint8_t*>(content.data()),
                                content.size(),
                                fileName,
-                               /*verify*/ true,
+                               kVerify,
                                kVerifyChecksum,
                                &error_msg,
                                &dex_files)) {
diff --git a/dexdump/dexdump.h b/dexdump/dexdump.h
index 6939f90..930d0ce 100644
--- a/dexdump/dexdump.h
+++ b/dexdump/dexdump.h
@@ -42,6 +42,7 @@
   bool disassemble;
   bool exportsOnly;
   bool ignoreBadChecksum;
+  bool disableVerifier;
   bool showAnnotations;
   bool showCfg;
   bool showFileHeaders;
diff --git a/dexdump/dexdump_main.cc b/dexdump/dexdump_main.cc
index 3c16fbe..f4a3866 100644
--- a/dexdump/dexdump_main.cc
+++ b/dexdump/dexdump_main.cc
@@ -39,7 +39,7 @@
  */
 static void usage(void) {
   LOG(ERROR) << "Copyright (C) 2007 The Android Open Source Project\n";
-  LOG(ERROR) << gProgName << ": [-a] [-c] [-d] [-e] [-f] [-h] [-i] [-l layout] [-o outfile]"
+  LOG(ERROR) << gProgName << ": [-a] [-c] [-d] [-e] [-f] [-h] [-i] [-j] [-l layout] [-o outfile]"
                   " dexfile...\n";
   LOG(ERROR) << " -a : display annotations";
   LOG(ERROR) << " -c : verify checksum and exit";
@@ -49,6 +49,7 @@
   LOG(ERROR) << " -g : display CFG for dex";
   LOG(ERROR) << " -h : display file header details";
   LOG(ERROR) << " -i : ignore checksum failures";
+  LOG(ERROR) << " -j : disable dex file verification";
   LOG(ERROR) << " -l : output layout, either 'plain' or 'xml'";
   LOG(ERROR) << " -o : output file name (defaults to stdout)";
 }
@@ -64,7 +65,7 @@
 
   // Parse all arguments.
   while (1) {
-    const int ic = getopt(argc, argv, "acdefghil:o:");
+    const int ic = getopt(argc, argv, "acdefghijl:o:");
     if (ic < 0) {
       break;  // done
     }
@@ -93,6 +94,9 @@
       case 'i':  // continue even if checksum is bad
         gOptions.ignoreBadChecksum = true;
         break;
+      case 'j':  // disable dex file verification
+        gOptions.disableVerifier = true;
+        break;
       case 'l':  // layout
         if (strcmp(optarg, "plain") == 0) {
           gOptions.outputFormat = OUTPUT_PLAIN;