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' }; |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 25 | const uint8_t OatHeader::kOatVersion[] = { '0', '3', '5', '\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; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 70 | quick_generic_jni_trampoline_offset_ = 0; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 71 | quick_imt_conflict_trampoline_offset_ = 0; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 72 | quick_resolution_trampoline_offset_ = 0; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 73 | quick_to_interpreter_bridge_offset_ = 0; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | bool OatHeader::IsValid() const { |
Brian Carlstrom | f852fb2 | 2012-10-19 11:01:58 -0700 | [diff] [blame] | 77 | if (memcmp(magic_, kOatMagic, sizeof(kOatMagic)) != 0) { |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 78 | return false; |
| 79 | } |
Brian Carlstrom | f852fb2 | 2012-10-19 11:01:58 -0700 | [diff] [blame] | 80 | if (memcmp(version_, kOatVersion, sizeof(kOatVersion)) != 0) { |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 81 | return false; |
| 82 | } |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | const char* OatHeader::GetMagic() const { |
| 87 | CHECK(IsValid()); |
| 88 | return reinterpret_cast<const char*>(magic_); |
| 89 | } |
| 90 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 91 | uint32_t OatHeader::GetChecksum() const { |
| 92 | CHECK(IsValid()); |
| 93 | return adler32_checksum_; |
| 94 | } |
| 95 | |
| 96 | void OatHeader::UpdateChecksum(const void* data, size_t length) { |
| 97 | DCHECK(IsValid()); |
| 98 | const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data); |
| 99 | adler32_checksum_ = adler32(adler32_checksum_, bytes, length); |
| 100 | } |
| 101 | |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame] | 102 | InstructionSet OatHeader::GetInstructionSet() const { |
| 103 | CHECK(IsValid()); |
| 104 | return instruction_set_; |
| 105 | } |
| 106 | |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 107 | const InstructionSetFeatures& OatHeader::GetInstructionSetFeatures() const { |
| 108 | CHECK(IsValid()); |
| 109 | return instruction_set_features_; |
| 110 | } |
| 111 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 112 | uint32_t OatHeader::GetExecutableOffset() const { |
| 113 | DCHECK(IsValid()); |
Elliott Hughes | 06b37d9 | 2011-10-16 11:51:29 -0700 | [diff] [blame] | 114 | DCHECK_ALIGNED(executable_offset_, kPageSize); |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 115 | CHECK_GT(executable_offset_, sizeof(OatHeader)); |
| 116 | return executable_offset_; |
| 117 | } |
| 118 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 119 | void OatHeader::SetExecutableOffset(uint32_t executable_offset) { |
| 120 | DCHECK_ALIGNED(executable_offset, kPageSize); |
| 121 | CHECK_GT(executable_offset, sizeof(OatHeader)); |
| 122 | DCHECK(IsValid()); |
| 123 | DCHECK_EQ(executable_offset_, 0U); |
| 124 | |
| 125 | executable_offset_ = executable_offset; |
| 126 | UpdateChecksum(&executable_offset_, sizeof(executable_offset)); |
| 127 | } |
| 128 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 129 | const void* OatHeader::GetInterpreterToInterpreterBridge() const { |
| 130 | return reinterpret_cast<const uint8_t*>(this) + GetInterpreterToInterpreterBridgeOffset(); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 133 | uint32_t OatHeader::GetInterpreterToInterpreterBridgeOffset() const { |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 134 | DCHECK(IsValid()); |
Dave Allison | c6104ae | 2014-03-12 11:05:39 -0700 | [diff] [blame] | 135 | CHECK(interpreter_to_interpreter_bridge_offset_ == 0 || |
| 136 | interpreter_to_interpreter_bridge_offset_ >= executable_offset_); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 137 | return interpreter_to_interpreter_bridge_offset_; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 140 | void OatHeader::SetInterpreterToInterpreterBridgeOffset(uint32_t offset) { |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 141 | CHECK(offset == 0 || offset >= executable_offset_); |
| 142 | DCHECK(IsValid()); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 143 | DCHECK_EQ(interpreter_to_interpreter_bridge_offset_, 0U) << offset; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 144 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 145 | interpreter_to_interpreter_bridge_offset_ = offset; |
| 146 | UpdateChecksum(&interpreter_to_interpreter_bridge_offset_, sizeof(offset)); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 149 | const void* OatHeader::GetInterpreterToCompiledCodeBridge() const { |
| 150 | return reinterpret_cast<const uint8_t*>(this) + GetInterpreterToCompiledCodeBridgeOffset(); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 153 | uint32_t OatHeader::GetInterpreterToCompiledCodeBridgeOffset() const { |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 154 | DCHECK(IsValid()); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 155 | CHECK_GE(interpreter_to_compiled_code_bridge_offset_, interpreter_to_interpreter_bridge_offset_); |
| 156 | return interpreter_to_compiled_code_bridge_offset_; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 159 | void OatHeader::SetInterpreterToCompiledCodeBridgeOffset(uint32_t offset) { |
| 160 | CHECK(offset == 0 || offset >= interpreter_to_interpreter_bridge_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 161 | DCHECK(IsValid()); |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 162 | DCHECK_EQ(interpreter_to_compiled_code_bridge_offset_, 0U) << offset; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 163 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 164 | interpreter_to_compiled_code_bridge_offset_ = offset; |
| 165 | UpdateChecksum(&interpreter_to_compiled_code_bridge_offset_, sizeof(offset)); |
| 166 | } |
| 167 | |
| 168 | const void* OatHeader::GetJniDlsymLookup() const { |
| 169 | return reinterpret_cast<const uint8_t*>(this) + GetJniDlsymLookupOffset(); |
| 170 | } |
| 171 | |
| 172 | uint32_t OatHeader::GetJniDlsymLookupOffset() const { |
| 173 | DCHECK(IsValid()); |
| 174 | CHECK_GE(jni_dlsym_lookup_offset_, interpreter_to_compiled_code_bridge_offset_); |
| 175 | return jni_dlsym_lookup_offset_; |
| 176 | } |
| 177 | |
| 178 | void OatHeader::SetJniDlsymLookupOffset(uint32_t offset) { |
| 179 | CHECK(offset == 0 || offset >= interpreter_to_compiled_code_bridge_offset_); |
| 180 | DCHECK(IsValid()); |
| 181 | DCHECK_EQ(jni_dlsym_lookup_offset_, 0U) << offset; |
| 182 | |
| 183 | jni_dlsym_lookup_offset_ = offset; |
| 184 | UpdateChecksum(&jni_dlsym_lookup_offset_, sizeof(offset)); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 187 | const void* OatHeader::GetPortableImtConflictTrampoline() const { |
| 188 | return reinterpret_cast<const uint8_t*>(this) + GetPortableImtConflictTrampolineOffset(); |
| 189 | } |
| 190 | |
| 191 | uint32_t OatHeader::GetPortableImtConflictTrampolineOffset() const { |
| 192 | DCHECK(IsValid()); |
| 193 | CHECK_GE(portable_imt_conflict_trampoline_offset_, jni_dlsym_lookup_offset_); |
| 194 | return portable_imt_conflict_trampoline_offset_; |
| 195 | } |
| 196 | |
| 197 | void OatHeader::SetPortableImtConflictTrampolineOffset(uint32_t offset) { |
| 198 | CHECK(offset == 0 || offset >= jni_dlsym_lookup_offset_); |
| 199 | DCHECK(IsValid()); |
| 200 | DCHECK_EQ(portable_imt_conflict_trampoline_offset_, 0U) << offset; |
| 201 | |
| 202 | portable_imt_conflict_trampoline_offset_ = offset; |
| 203 | UpdateChecksum(&portable_imt_conflict_trampoline_offset_, sizeof(offset)); |
| 204 | } |
| 205 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 206 | const void* OatHeader::GetPortableResolutionTrampoline() const { |
| 207 | return reinterpret_cast<const uint8_t*>(this) + GetPortableResolutionTrampolineOffset(); |
| 208 | } |
| 209 | |
| 210 | uint32_t OatHeader::GetPortableResolutionTrampolineOffset() const { |
| 211 | DCHECK(IsValid()); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 212 | CHECK_GE(portable_resolution_trampoline_offset_, portable_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 213 | return portable_resolution_trampoline_offset_; |
| 214 | } |
| 215 | |
| 216 | void OatHeader::SetPortableResolutionTrampolineOffset(uint32_t offset) { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 217 | CHECK(offset == 0 || offset >= portable_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 218 | DCHECK(IsValid()); |
| 219 | DCHECK_EQ(portable_resolution_trampoline_offset_, 0U) << offset; |
| 220 | |
| 221 | portable_resolution_trampoline_offset_ = offset; |
| 222 | UpdateChecksum(&portable_resolution_trampoline_offset_, sizeof(offset)); |
| 223 | } |
| 224 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 225 | const void* OatHeader::GetPortableToInterpreterBridge() const { |
| 226 | return reinterpret_cast<const uint8_t*>(this) + GetPortableToInterpreterBridgeOffset(); |
| 227 | } |
| 228 | |
| 229 | uint32_t OatHeader::GetPortableToInterpreterBridgeOffset() const { |
| 230 | DCHECK(IsValid()); |
| 231 | CHECK_GE(portable_to_interpreter_bridge_offset_, portable_resolution_trampoline_offset_); |
| 232 | return portable_to_interpreter_bridge_offset_; |
| 233 | } |
| 234 | |
| 235 | void OatHeader::SetPortableToInterpreterBridgeOffset(uint32_t offset) { |
| 236 | CHECK(offset == 0 || offset >= portable_resolution_trampoline_offset_); |
| 237 | DCHECK(IsValid()); |
| 238 | DCHECK_EQ(portable_to_interpreter_bridge_offset_, 0U) << offset; |
| 239 | |
| 240 | portable_to_interpreter_bridge_offset_ = offset; |
| 241 | UpdateChecksum(&portable_to_interpreter_bridge_offset_, sizeof(offset)); |
| 242 | } |
| 243 | |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 244 | const void* OatHeader::GetQuickGenericJniTrampoline() const { |
| 245 | return reinterpret_cast<const uint8_t*>(this) + GetQuickGenericJniTrampolineOffset(); |
| 246 | } |
| 247 | |
| 248 | uint32_t OatHeader::GetQuickGenericJniTrampolineOffset() const { |
| 249 | DCHECK(IsValid()); |
| 250 | CHECK_GE(quick_generic_jni_trampoline_offset_, portable_to_interpreter_bridge_offset_); |
| 251 | return quick_generic_jni_trampoline_offset_; |
| 252 | } |
| 253 | |
| 254 | void OatHeader::SetQuickGenericJniTrampolineOffset(uint32_t offset) { |
| 255 | CHECK(offset == 0 || offset >= portable_to_interpreter_bridge_offset_); |
| 256 | DCHECK(IsValid()); |
| 257 | DCHECK_EQ(quick_generic_jni_trampoline_offset_, 0U) << offset; |
| 258 | |
| 259 | quick_generic_jni_trampoline_offset_ = offset; |
| 260 | UpdateChecksum(&quick_generic_jni_trampoline_offset_, sizeof(offset)); |
| 261 | } |
| 262 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 263 | const void* OatHeader::GetQuickImtConflictTrampoline() const { |
| 264 | return reinterpret_cast<const uint8_t*>(this) + GetQuickImtConflictTrampolineOffset(); |
| 265 | } |
| 266 | |
| 267 | uint32_t OatHeader::GetQuickImtConflictTrampolineOffset() const { |
| 268 | DCHECK(IsValid()); |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 269 | CHECK_GE(quick_imt_conflict_trampoline_offset_, quick_generic_jni_trampoline_offset_); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 270 | return quick_imt_conflict_trampoline_offset_; |
| 271 | } |
| 272 | |
| 273 | void OatHeader::SetQuickImtConflictTrampolineOffset(uint32_t offset) { |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 274 | CHECK(offset == 0 || offset >= quick_generic_jni_trampoline_offset_); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 275 | DCHECK(IsValid()); |
| 276 | DCHECK_EQ(quick_imt_conflict_trampoline_offset_, 0U) << offset; |
| 277 | |
| 278 | quick_imt_conflict_trampoline_offset_ = offset; |
| 279 | UpdateChecksum(&quick_imt_conflict_trampoline_offset_, sizeof(offset)); |
| 280 | } |
| 281 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 282 | const void* OatHeader::GetQuickResolutionTrampoline() const { |
| 283 | return reinterpret_cast<const uint8_t*>(this) + GetQuickResolutionTrampolineOffset(); |
| 284 | } |
| 285 | |
| 286 | uint32_t OatHeader::GetQuickResolutionTrampolineOffset() const { |
| 287 | DCHECK(IsValid()); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 288 | CHECK_GE(quick_resolution_trampoline_offset_, quick_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 289 | return quick_resolution_trampoline_offset_; |
| 290 | } |
| 291 | |
| 292 | void OatHeader::SetQuickResolutionTrampolineOffset(uint32_t offset) { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 293 | CHECK(offset == 0 || offset >= quick_imt_conflict_trampoline_offset_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 294 | DCHECK(IsValid()); |
| 295 | DCHECK_EQ(quick_resolution_trampoline_offset_, 0U) << offset; |
| 296 | |
| 297 | quick_resolution_trampoline_offset_ = offset; |
| 298 | UpdateChecksum(&quick_resolution_trampoline_offset_, sizeof(offset)); |
| 299 | } |
| 300 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 301 | const void* OatHeader::GetQuickToInterpreterBridge() const { |
| 302 | return reinterpret_cast<const uint8_t*>(this) + GetQuickToInterpreterBridgeOffset(); |
| 303 | } |
| 304 | |
| 305 | uint32_t OatHeader::GetQuickToInterpreterBridgeOffset() const { |
| 306 | DCHECK(IsValid()); |
| 307 | CHECK_GE(quick_to_interpreter_bridge_offset_, quick_resolution_trampoline_offset_); |
| 308 | return quick_to_interpreter_bridge_offset_; |
| 309 | } |
| 310 | |
| 311 | void OatHeader::SetQuickToInterpreterBridgeOffset(uint32_t offset) { |
| 312 | CHECK(offset == 0 || offset >= quick_resolution_trampoline_offset_); |
| 313 | DCHECK(IsValid()); |
| 314 | DCHECK_EQ(quick_to_interpreter_bridge_offset_, 0U) << offset; |
| 315 | |
| 316 | quick_to_interpreter_bridge_offset_ = offset; |
| 317 | UpdateChecksum(&quick_to_interpreter_bridge_offset_, sizeof(offset)); |
| 318 | } |
| 319 | |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 320 | uint32_t OatHeader::GetImageFileLocationOatChecksum() const { |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 321 | CHECK(IsValid()); |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 322 | return image_file_location_oat_checksum_; |
| 323 | } |
| 324 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 325 | uint32_t OatHeader::GetImageFileLocationOatDataBegin() const { |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 326 | CHECK(IsValid()); |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 327 | return image_file_location_oat_data_begin_; |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | uint32_t OatHeader::GetImageFileLocationSize() const { |
| 331 | CHECK(IsValid()); |
| 332 | return image_file_location_size_; |
| 333 | } |
| 334 | |
| 335 | const uint8_t* OatHeader::GetImageFileLocationData() const { |
| 336 | CHECK(IsValid()); |
| 337 | return image_file_location_data_; |
| 338 | } |
| 339 | |
| 340 | std::string OatHeader::GetImageFileLocation() const { |
| 341 | CHECK(IsValid()); |
| 342 | return std::string(reinterpret_cast<const char*>(GetImageFileLocationData()), |
| 343 | GetImageFileLocationSize()); |
| 344 | } |
| 345 | |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 346 | OatMethodOffsets::OatMethodOffsets() |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 347 | : code_offset_(0), |
Jeff Hao | 74180ca | 2013-03-27 15:29:11 -0700 | [diff] [blame] | 348 | gc_map_offset_(0) |
Logan Chien | ccb7bf1 | 2012-03-28 12:52:32 +0800 | [diff] [blame] | 349 | {} |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 350 | |
| 351 | OatMethodOffsets::OatMethodOffsets(uint32_t code_offset, |
Jeff Hao | 74180ca | 2013-03-27 15:29:11 -0700 | [diff] [blame] | 352 | uint32_t gc_map_offset |
Logan Chien | ccb7bf1 | 2012-03-28 12:52:32 +0800 | [diff] [blame] | 353 | ) |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 354 | : code_offset_(code_offset), |
Jeff Hao | 74180ca | 2013-03-27 15:29:11 -0700 | [diff] [blame] | 355 | gc_map_offset_(gc_map_offset) |
Logan Chien | ccb7bf1 | 2012-03-28 12:52:32 +0800 | [diff] [blame] | 356 | {} |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 357 | |
| 358 | OatMethodOffsets::~OatMethodOffsets() {} |
| 359 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 360 | OatQuickMethodHeader::OatQuickMethodHeader() |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 361 | : mapping_table_offset_(0), |
| 362 | vmap_table_offset_(0), |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 363 | frame_info_(0, 0, 0), |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 364 | code_size_(0) |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 365 | {} |
| 366 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 367 | OatQuickMethodHeader::OatQuickMethodHeader( |
| 368 | uint32_t mapping_table_offset, uint32_t vmap_table_offset, uint32_t frame_size_in_bytes, |
| 369 | uint32_t core_spill_mask, uint32_t fp_spill_mask, uint32_t code_size) |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 370 | : mapping_table_offset_(mapping_table_offset), |
| 371 | vmap_table_offset_(vmap_table_offset), |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 372 | frame_info_(frame_size_in_bytes, core_spill_mask, fp_spill_mask), |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 373 | code_size_(code_size) |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 374 | {} |
| 375 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 376 | OatQuickMethodHeader::~OatQuickMethodHeader() {} |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 377 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 378 | } // namespace art |