Added first pass of verifier and supporting changes.
The verifier still needs to make a second pass through the code where it
checks the code flow. A TODO marks where it will be added.
Change-Id: I0abea5bad563776186df342d8132fb1ca8869652
diff --git a/src/dex_file.h b/src/dex_file.h
index 76b9c2f..2dcb3b2 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -229,7 +229,7 @@
CatchHandlerIterator(const byte* handler_data) {
current_data_ = handler_data;
- remaining_count_ = DecodeUnsignedLeb128(¤t_data_);
+ remaining_count_ = DecodeSignedLeb128(¤t_data_);
// If remaining_count_ is non-positive, then it is the negative of
// the number of catch types, and the catches are followed by a
@@ -247,6 +247,10 @@
return handler_;
}
+ const byte* GetData() const {
+ return current_data_;
+ }
+
void Next() {
if (remaining_count_ > 0) {
handler_.type_idx_ = DecodeUnsignedLeb128(¤t_data_);
@@ -570,14 +574,14 @@
*last_idx = idx;
}
- const TryItem* dexGetTryItems(const CodeItem& code_item, uint32_t offset) const {
+ static const TryItem* dexGetTryItems(const CodeItem& code_item, uint32_t offset) {
const uint16_t* insns_end_ = &code_item.insns_[code_item.insns_size_];
return reinterpret_cast<const TryItem*>
(RoundUp(reinterpret_cast<uint32_t>(insns_end_), 4)) + offset;
}
// Get the base of the encoded data for the given DexCode.
- const byte* dexGetCatchHandlerData(const CodeItem& code_item, uint32_t offset) const {
+ static const byte* dexGetCatchHandlerData(const CodeItem& code_item, uint32_t offset) {
const byte* handler_data = reinterpret_cast<const byte*>
(dexGetTryItems(code_item, code_item.tries_size_));
return handler_data + offset;
@@ -586,7 +590,7 @@
// Find the handler associated with a given address, if any.
// Initializes the given iterator and returns true if a match is
// found. Returns end if there is no applicable handler.
- CatchHandlerIterator dexFindCatchHandler(const CodeItem& code_item, uint32_t address) const {
+ static CatchHandlerIterator dexFindCatchHandler(const CodeItem& code_item, uint32_t address) {
CatchHandlerItem handler;
handler.address_ = -1;
int32_t offset = -1;
@@ -619,9 +623,9 @@
return CatchHandlerIterator();
}
- int32_t dexFindCatchHandlerOffset0(const CodeItem &code_item,
- int32_t tries_size,
- uint32_t address) const {
+ static int32_t dexFindCatchHandlerOffset0(const CodeItem &code_item,
+ int32_t tries_size,
+ uint32_t address) {
// Note: Signed type is important for max and min.
int32_t min = 0;
int32_t max = tries_size - 1;