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/dex_file.h b/src/dex_file.h
index 3a9d58a..9ebcce2 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -832,11 +832,14 @@
     }
   }
 
+  void ChangePermissions(int prot) const;
+
  private:
   // Helper class to deallocate underlying storage.
   class Closer {
    public:
     virtual ~Closer();
+    virtual void ChangePermissions(int prot) = 0;
   };
 
   // Helper class to deallocate mmap-backed .dex files.
@@ -844,6 +847,7 @@
    public:
     MmapCloser(void* addr, size_t length);
     virtual ~MmapCloser();
+    virtual void ChangePermissions(int prot);
    private:
     void* addr_;
     size_t length_;
@@ -854,6 +858,7 @@
    public:
     PtrCloser(byte* addr);
     virtual ~PtrCloser();
+    virtual void ChangePermissions(int prot);
    private:
     byte* addr_;
   };