Add code size to oat files
Change-Id: Ic2519551864dd7090ba98f2fc92318f95f92947f
diff --git a/src/oat_file.h b/src/oat_file.h
index 831934a..9fcba2f 100644
--- a/src/oat_file.h
+++ b/src/oat_file.h
@@ -90,6 +90,15 @@
const void* GetCode() const {
return GetOatPointer<const void*>(code_offset_);
}
+ uint32_t GetCodeSize() const {
+ uintptr_t code = reinterpret_cast<uint32_t>(GetCode());
+ if (code == 0) {
+ return 0;
+ }
+ // TODO: make this Thumb2 specific
+ code &= ~0x1;
+ return reinterpret_cast<uint32_t*>(code)[-1];
+ }
const uint32_t* GetMappingTable() const {
return GetOatPointer<const uint32_t*>(mapping_table_offset_);
}
@@ -102,6 +111,13 @@
const Method::InvokeStub* GetInvokeStub() const {
return GetOatPointer<const Method::InvokeStub*>(invoke_stub_offset_);
}
+ uint32_t GetInvokeStubSize() const {
+ uintptr_t code = reinterpret_cast<uint32_t>(GetInvokeStub());
+ if (code == 0) {
+ return 0;
+ }
+ return reinterpret_cast<uint32_t*>(code)[-1];
+ }
~OatMethod();