Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 16 | |
| 17 | #include "oat.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 18 | #include "utils.h" |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 19 | |
| 20 | #include <zlib.h> |
| 21 | |
| 22 | namespace art { |
| 23 | |
| 24 | const uint8_t OatHeader::kOatMagic[] = { 'o', 'a', 't', '\n' }; |
Brian Carlstrom | 7f9d66c | 2014-01-28 18:21:49 -0800 | [diff] [blame] | 25 | const uint8_t OatHeader::kOatVersion[] = { '0', '1', '4', '\0' }; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 26 | |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame] | 27 | OatHeader::OatHeader() { |
| 28 | memset(this, 0, sizeof(*this)); |
| 29 | } |
| 30 | |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 31 | OatHeader::OatHeader(InstructionSet instruction_set, |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 32 | const InstructionSetFeatures& instruction_set_features, |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 33 | const std::vector<const DexFile*>* dex_files, |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 34 | uint32_t image_file_location_oat_checksum, |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 35 | uint32_t image_file_location_oat_data_begin, |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 36 | const std::string& image_file_location) { |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 37 | memcpy(magic_, kOatMagic, sizeof(kOatMagic)); |
| 38 | memcpy(version_, kOatVersion, sizeof(kOatVersion)); |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 39 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 40 | adler32_checksum_ = adler32(0L, Z_NULL, 0); |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 41 | |
Brian Carlstrom | f852fb2 | 2012-10-19 11:01:58 -0700 | [diff] [blame] | 42 | CHECK_NE(instruction_set, kNone); |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame] | 43 | instruction_set_ = instruction_set; |
| 44 | UpdateChecksum(&instruction_set_, sizeof(instruction_set_)); |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 45 | |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 46 | instruction_set_features_ = instruction_set_features; |
| 47 | UpdateChecksum(&instruction_set_features_, sizeof(instruction_set_features_)); |
| 48 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 49 | dex_file_count_ = dex_files->size(); |
| 50 | UpdateChecksum(&dex_file_count_, sizeof(dex_file_count_)); |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 51 | |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 52 | image_file_location_oat_checksum_ = image_file_location_oat_checksum; |
| 53 | UpdateChecksum(&image_file_location_oat_checksum_, sizeof(image_file_location_oat_checksum_)); |
| 54 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 55 | CHECK(IsAligned<kPageSize>(image_file_location_oat_data_begin)); |
| 56 | image_file_location_oat_data_begin_ = image_file_location_oat_data_begin; |
| 57 | UpdateChecksum(&image_file_location_oat_data_begin_, sizeof(image_file_location_oat_data_begin_)); |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 58 | |
| 59 | image_file_location_size_ = image_file_location.size(); |
| 60 | UpdateChecksum(&image_file_location_size_, sizeof(image_file_location_size_)); |
| 61 | UpdateChecksum(image_file_location.data(), image_file_location_size_); |
| 62 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 63 | executable_offset_ = 0; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 64 | interpreter_to_interpreter_bridge_offset_ = 0; |
| 65 | interpreter_to_compiled_code_bridge_offset_ = 0; |
| 66 | jni_dlsym_lookup_offset_ = 0; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 67 | portable_imt_conflict_trampoline_offset_ = 0; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 68 | portable_resolution_trampoline_offset_ = 0; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 69 | portable_to_interpreter_bridge_offset_ = 0; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 70 | quick_imt_conflict_trampoline_offset_ = 0; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 71 | quick_resolution_trampoline_offset_ = 0; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 72 | quick_to_interpreter_bridge_offset_ = 0; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | bool OatHeader::IsValid() const { |
Brian Carlstrom | f852fb2 | 2012-10-19 11:01:58 -0700 | [diff] [blame] | 76 | if (memcmp(magic_, kOatMagic, sizeof(kOatMagic)) != 0) { |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 77 | return false; |
| 78 | } |
Brian Carlstrom | f852fb2 | 2012-10-19 11:01:58 -0700 | [diff] [blame] | 79 | if (memcmp(version_, kOatVersion, sizeof(kOatVersion)) != 0) { |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 80 | return false; |
| 81 | } |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | const char* OatHeader::GetMagic() const { |
| 86 | CHECK(IsValid()); |
| 87 | return reinterpret_cast<const char*>(magic_); |
| 88 | } |
| 89 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 90 | uint32_t OatHeader::GetChecksum() const { |
| 91 | CHECK(IsValid()); |
| 92 | return adler32_checksum_; |
| 93 | } |
| 94 | |
| 95 | void OatHeader::UpdateChecksum(const void* data, size_t length) { |
| 96 | DCHECK(IsValid()); |
| 97 | const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data); |
| 98 | adler32_checksum_ = adler32(adler32_checksum_, bytes, length); |
| 99 | } |
| 100 | |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame] | 101 | InstructionSet OatHeader::GetInstructionSet() const { |
| 102 | CHECK(IsValid()); |
| 103 | return instruction_set_; |
| 104 | } |
| 105 | |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 106 | const InstructionSetFeatures& OatHeader::GetInstructionSetFeatures() const { |
| 107 | CHECK(IsValid()); |
| 108 | return instruction_set_features_; |
| 109 | } |
| 110 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 111 | uint32_t OatHeader::GetExecutableOffset() const { |
| 112 | DCHECK(IsValid()); |
Elliott Hughes | 06b37d9 | 2011-10-16 11:51:29 -0700 | [diff] [blame] | 113 | DCHECK_ALIGNED(executable_offset_, kPageSize); |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 114 | CHECK_GT(executable_offset_, sizeof(OatHeader)); |
| 115 | return executable_offset_; |
| 116 | } |
| 117 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 118 | void OatHeader::SetExecutableOffset(uint32_t executable_offset) { |
| 119 | DCHECK_ALIGNED(executable_offset, kPageSize); |
| 120 | CHECK_GT(executable_offset, sizeof(OatHeader)); |
| 121 | DCHECK(IsValid()); |
| 122 | DCHECK_EQ(executable_offset_, 0U); |
| 123 | |
| 124 | executable_offset_ = executable_offset; |
| 125 | UpdateChecksum(&executable_offset_, sizeof(executable_offset)); |
| 126 | } |
| 127 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 128 | const void* OatHeader::GetInterpreterToInterpreterBridge() const { |
| 129 | return reinterpret_cast<const uint8_t*>(this) + GetInterpreterToInterpreterBridgeOffset(); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 132 | uint32_t OatHeader::GetInterpreterToInterpreterBridgeOffset() const { |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 133 | DCHECK(IsValid()); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 134 | CHECK_GE(interpreter_to_interpreter_bridge_offset_, executable_offset_); |
| 135 | return interpreter_to_interpreter_bridge_offset_; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 138 | void OatHeader::SetInterpreterToInterpreterBridgeOffset(uint32_t offset) { |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 139 | CHECK(offset == 0 || offset >= executable_offset_); |
| 140 | DCHECK(IsValid()); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 141 | DCHECK_EQ(interpreter_to_interpreter_bridge_offset_, 0U) << offset; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 142 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 143 | interpreter_to_interpreter_bridge_offset_ = offset; |
| 144 | UpdateChecksum(&interpreter_to_interpreter_bridge_offset_, sizeof(offset)); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 147 | const void* OatHeader::GetInterpreterToCompiledCodeBridge() const { |
| 148 | return reinterpret_cast<const uint8_t*>(this) + GetInterpreterToCompiledCodeBridgeOffset(); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 151 | uint32_t OatHeader::GetInterpreterToCompiledCodeBridgeOffset() const { |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 152 | DCHECK(IsValid()); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 153 | CHECK_GE(interpreter_to_compiled_code_bridge_offset_, interpreter_to_interpreter_bridge_offset_); |
| 154 | return interpreter_to_compiled_code_bridge_offset_; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 157 | void OatHeader::SetInterpreterToCompiledCodeBridgeOffset(uint32_t offset) { |
| 158 | CHECK(offset == 0 || offset >= interpreter_to_interpreter_bridge_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 159 | DCHECK(IsValid()); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 160 | DCHECK_EQ(interpreter_to_compiled_code_bridge_offset_, 0U) << offset; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 161 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 162 | interpreter_to_compiled_code_bridge_offset_ = offset; |
| 163 | UpdateChecksum(&interpreter_to_compiled_code_bridge_offset_, sizeof(offset)); |
| 164 | } |
| 165 | |
| 166 | const void* OatHeader::GetJniDlsymLookup() const { |
| 167 | return reinterpret_cast<const uint8_t*>(this) + GetJniDlsymLookupOffset(); |
| 168 | } |
| 169 | |
| 170 | uint32_t OatHeader::GetJniDlsymLookupOffset() const { |
| 171 | DCHECK(IsValid()); |
| 172 | CHECK_GE(jni_dlsym_lookup_offset_, interpreter_to_compiled_code_bridge_offset_); |
| 173 | return jni_dlsym_lookup_offset_; |
| 174 | } |
| 175 | |
| 176 | void OatHeader::SetJniDlsymLookupOffset(uint32_t offset) { |
| 177 | CHECK(offset == 0 || offset >= interpreter_to_compiled_code_bridge_offset_); |
| 178 | DCHECK(IsValid()); |
| 179 | DCHECK_EQ(jni_dlsym_lookup_offset_, 0U) << offset; |
| 180 | |
| 181 | jni_dlsym_lookup_offset_ = offset; |
| 182 | UpdateChecksum(&jni_dlsym_lookup_offset_, sizeof(offset)); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 185 | const void* OatHeader::GetPortableImtConflictTrampoline() const { |
| 186 | return reinterpret_cast<const uint8_t*>(this) + GetPortableImtConflictTrampolineOffset(); |
| 187 | } |
| 188 | |
| 189 | uint32_t OatHeader::GetPortableImtConflictTrampolineOffset() const { |
| 190 | DCHECK(IsValid()); |
| 191 | CHECK_GE(portable_imt_conflict_trampoline_offset_, jni_dlsym_lookup_offset_); |
| 192 | return portable_imt_conflict_trampoline_offset_; |
| 193 | } |
| 194 | |
| 195 | void OatHeader::SetPortableImtConflictTrampolineOffset(uint32_t offset) { |
| 196 | CHECK(offset == 0 || offset >= jni_dlsym_lookup_offset_); |
| 197 | DCHECK(IsValid()); |
| 198 | DCHECK_EQ(portable_imt_conflict_trampoline_offset_, 0U) << offset; |
| 199 | |
| 200 | portable_imt_conflict_trampoline_offset_ = offset; |
| 201 | UpdateChecksum(&portable_imt_conflict_trampoline_offset_, sizeof(offset)); |
| 202 | } |
| 203 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 204 | const void* OatHeader::GetPortableResolutionTrampoline() const { |
| 205 | return reinterpret_cast<const uint8_t*>(this) + GetPortableResolutionTrampolineOffset(); |
| 206 | } |
| 207 | |
| 208 | uint32_t OatHeader::GetPortableResolutionTrampolineOffset() const { |
| 209 | DCHECK(IsValid()); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 210 | CHECK_GE(portable_resolution_trampoline_offset_, portable_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 211 | return portable_resolution_trampoline_offset_; |
| 212 | } |
| 213 | |
| 214 | void OatHeader::SetPortableResolutionTrampolineOffset(uint32_t offset) { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 215 | CHECK(offset == 0 || offset >= portable_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 216 | DCHECK(IsValid()); |
| 217 | DCHECK_EQ(portable_resolution_trampoline_offset_, 0U) << offset; |
| 218 | |
| 219 | portable_resolution_trampoline_offset_ = offset; |
| 220 | UpdateChecksum(&portable_resolution_trampoline_offset_, sizeof(offset)); |
| 221 | } |
| 222 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 223 | const void* OatHeader::GetPortableToInterpreterBridge() const { |
| 224 | return reinterpret_cast<const uint8_t*>(this) + GetPortableToInterpreterBridgeOffset(); |
| 225 | } |
| 226 | |
| 227 | uint32_t OatHeader::GetPortableToInterpreterBridgeOffset() const { |
| 228 | DCHECK(IsValid()); |
| 229 | CHECK_GE(portable_to_interpreter_bridge_offset_, portable_resolution_trampoline_offset_); |
| 230 | return portable_to_interpreter_bridge_offset_; |
| 231 | } |
| 232 | |
| 233 | void OatHeader::SetPortableToInterpreterBridgeOffset(uint32_t offset) { |
| 234 | CHECK(offset == 0 || offset >= portable_resolution_trampoline_offset_); |
| 235 | DCHECK(IsValid()); |
| 236 | DCHECK_EQ(portable_to_interpreter_bridge_offset_, 0U) << offset; |
| 237 | |
| 238 | portable_to_interpreter_bridge_offset_ = offset; |
| 239 | UpdateChecksum(&portable_to_interpreter_bridge_offset_, sizeof(offset)); |
| 240 | } |
| 241 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 242 | const void* OatHeader::GetQuickImtConflictTrampoline() const { |
| 243 | return reinterpret_cast<const uint8_t*>(this) + GetQuickImtConflictTrampolineOffset(); |
| 244 | } |
| 245 | |
| 246 | uint32_t OatHeader::GetQuickImtConflictTrampolineOffset() const { |
| 247 | DCHECK(IsValid()); |
| 248 | CHECK_GE(quick_imt_conflict_trampoline_offset_, portable_to_interpreter_bridge_offset_); |
| 249 | return quick_imt_conflict_trampoline_offset_; |
| 250 | } |
| 251 | |
| 252 | void OatHeader::SetQuickImtConflictTrampolineOffset(uint32_t offset) { |
| 253 | CHECK(offset == 0 || offset >= portable_to_interpreter_bridge_offset_); |
| 254 | DCHECK(IsValid()); |
| 255 | DCHECK_EQ(quick_imt_conflict_trampoline_offset_, 0U) << offset; |
| 256 | |
| 257 | quick_imt_conflict_trampoline_offset_ = offset; |
| 258 | UpdateChecksum(&quick_imt_conflict_trampoline_offset_, sizeof(offset)); |
| 259 | } |
| 260 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 261 | const void* OatHeader::GetQuickResolutionTrampoline() const { |
| 262 | return reinterpret_cast<const uint8_t*>(this) + GetQuickResolutionTrampolineOffset(); |
| 263 | } |
| 264 | |
| 265 | uint32_t OatHeader::GetQuickResolutionTrampolineOffset() const { |
| 266 | DCHECK(IsValid()); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 267 | CHECK_GE(quick_resolution_trampoline_offset_, quick_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 268 | return quick_resolution_trampoline_offset_; |
| 269 | } |
| 270 | |
| 271 | void OatHeader::SetQuickResolutionTrampolineOffset(uint32_t offset) { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 272 | CHECK(offset == 0 || offset >= quick_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 273 | DCHECK(IsValid()); |
| 274 | DCHECK_EQ(quick_resolution_trampoline_offset_, 0U) << offset; |
| 275 | |
| 276 | quick_resolution_trampoline_offset_ = offset; |
| 277 | UpdateChecksum(&quick_resolution_trampoline_offset_, sizeof(offset)); |
| 278 | } |
| 279 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 280 | const void* OatHeader::GetQuickToInterpreterBridge() const { |
| 281 | return reinterpret_cast<const uint8_t*>(this) + GetQuickToInterpreterBridgeOffset(); |
| 282 | } |
| 283 | |
| 284 | uint32_t OatHeader::GetQuickToInterpreterBridgeOffset() const { |
| 285 | DCHECK(IsValid()); |
| 286 | CHECK_GE(quick_to_interpreter_bridge_offset_, quick_resolution_trampoline_offset_); |
| 287 | return quick_to_interpreter_bridge_offset_; |
| 288 | } |
| 289 | |
| 290 | void OatHeader::SetQuickToInterpreterBridgeOffset(uint32_t offset) { |
| 291 | CHECK(offset == 0 || offset >= quick_resolution_trampoline_offset_); |
| 292 | DCHECK(IsValid()); |
| 293 | DCHECK_EQ(quick_to_interpreter_bridge_offset_, 0U) << offset; |
| 294 | |
| 295 | quick_to_interpreter_bridge_offset_ = offset; |
| 296 | UpdateChecksum(&quick_to_interpreter_bridge_offset_, sizeof(offset)); |
| 297 | } |
| 298 | |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 299 | uint32_t OatHeader::GetImageFileLocationOatChecksum() const { |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 300 | CHECK(IsValid()); |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 301 | return image_file_location_oat_checksum_; |
| 302 | } |
| 303 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 304 | uint32_t OatHeader::GetImageFileLocationOatDataBegin() const { |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 305 | CHECK(IsValid()); |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 306 | return image_file_location_oat_data_begin_; |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | uint32_t OatHeader::GetImageFileLocationSize() const { |
| 310 | CHECK(IsValid()); |
| 311 | return image_file_location_size_; |
| 312 | } |
| 313 | |
| 314 | const uint8_t* OatHeader::GetImageFileLocationData() const { |
| 315 | CHECK(IsValid()); |
| 316 | return image_file_location_data_; |
| 317 | } |
| 318 | |
| 319 | std::string OatHeader::GetImageFileLocation() const { |
| 320 | CHECK(IsValid()); |
| 321 | return std::string(reinterpret_cast<const char*>(GetImageFileLocationData()), |
| 322 | GetImageFileLocationSize()); |
| 323 | } |
| 324 | |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 325 | OatMethodOffsets::OatMethodOffsets() |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 326 | : code_offset_(0), |
| 327 | frame_size_in_bytes_(0), |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 328 | core_spill_mask_(0), |
| 329 | fp_spill_mask_(0), |
| 330 | mapping_table_offset_(0), |
| 331 | vmap_table_offset_(0), |
Jeff Hao | 74180ca | 2013-03-27 15:29:11 -0700 | [diff] [blame] | 332 | gc_map_offset_(0) |
Logan Chien | ccb7bf1 | 2012-03-28 12:52:32 +0800 | [diff] [blame] | 333 | {} |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 334 | |
| 335 | OatMethodOffsets::OatMethodOffsets(uint32_t code_offset, |
| 336 | uint32_t frame_size_in_bytes, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 337 | uint32_t core_spill_mask, |
| 338 | uint32_t fp_spill_mask, |
| 339 | uint32_t mapping_table_offset, |
| 340 | uint32_t vmap_table_offset, |
Jeff Hao | 74180ca | 2013-03-27 15:29:11 -0700 | [diff] [blame] | 341 | uint32_t gc_map_offset |
Logan Chien | ccb7bf1 | 2012-03-28 12:52:32 +0800 | [diff] [blame] | 342 | ) |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 343 | : code_offset_(code_offset), |
| 344 | frame_size_in_bytes_(frame_size_in_bytes), |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 345 | core_spill_mask_(core_spill_mask), |
| 346 | fp_spill_mask_(fp_spill_mask), |
| 347 | mapping_table_offset_(mapping_table_offset), |
| 348 | vmap_table_offset_(vmap_table_offset), |
Jeff Hao | 74180ca | 2013-03-27 15:29:11 -0700 | [diff] [blame] | 349 | gc_map_offset_(gc_map_offset) |
Logan Chien | ccb7bf1 | 2012-03-28 12:52:32 +0800 | [diff] [blame] | 350 | {} |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 351 | |
| 352 | OatMethodOffsets::~OatMethodOffsets() {} |
| 353 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 354 | } // namespace art |