Added more checking upon resolution and bytecode rewriting to verifier.

Access checks are performed when methods and fields are resolved. Also,
erroring bytecodes are now overwritten in the memory mapped dex file.
To do this, the code sets the memory mapped dex file as writable before
verification and set it back to read only after verification is done.
The overwritting occurs only in memory and the original dex file remains
unchanged.

Change-Id: I054394fb57e83d1ac5b6f200ab993d70cd9f55e6
diff --git a/src/compiler.cc b/src/compiler.cc
index 454c8f8..71727fd 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -143,6 +143,7 @@
 }
 
 void Compiler::VerifyDexFile(const ClassLoader* class_loader, const DexFile& dex_file) {
+  dex_file.ChangePermissions(PROT_READ | PROT_WRITE);
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
   for (size_t class_def_index = 0; class_def_index < dex_file.NumClassDefs(); class_def_index++) {
     const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
@@ -153,6 +154,7 @@
     class_linker->VerifyClass(klass);
     CHECK(klass->IsVerified() || klass->IsErroneous());
   }
+  dex_file.ChangePermissions(PROT_READ);
 }
 
 void Compiler::InitializeClassesWithoutClinit(const ClassLoader* class_loader) {