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 | #ifndef ART_SRC_OAT_H_ |
| 18 | #define ART_SRC_OAT_H_ |
| 19 | |
| 20 | #include <vector> |
| 21 | |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame^] | 22 | #include "constants.h" |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 23 | #include "dex_file.h" |
| 24 | #include "macros.h" |
| 25 | |
| 26 | namespace art { |
| 27 | |
| 28 | class PACKED OatHeader { |
| 29 | public: |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame^] | 30 | OatHeader(); |
| 31 | OatHeader(InstructionSet instruction_set, const std::vector<const DexFile*>* dex_files); |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 32 | |
| 33 | bool IsValid() const; |
| 34 | const char* GetMagic() const; |
| 35 | uint32_t GetChecksum() const; |
| 36 | void UpdateChecksum(const void* data, size_t length); |
| 37 | uint32_t GetDexFileCount() const; |
| 38 | uint32_t GetExecutableOffset() const; |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame^] | 39 | InstructionSet GetInstructionSet() const; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 40 | void SetExecutableOffset(uint32_t executable_offset); |
| 41 | |
| 42 | private: |
| 43 | static const uint8_t kOatMagic[4]; |
| 44 | static const uint8_t kOatVersion[4]; |
| 45 | |
| 46 | uint8_t magic_[4]; |
| 47 | uint8_t version_[4]; |
| 48 | uint32_t adler32_checksum_; |
Elliott Hughes | a72ec82 | 2012-03-05 17:12:22 -0800 | [diff] [blame^] | 49 | |
| 50 | InstructionSet instruction_set_; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 51 | uint32_t dex_file_count_; |
| 52 | uint32_t executable_offset_; |
| 53 | |
| 54 | DISALLOW_COPY_AND_ASSIGN(OatHeader); |
| 55 | }; |
| 56 | |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 57 | class PACKED OatMethodOffsets { |
| 58 | public: |
| 59 | OatMethodOffsets(); |
| 60 | OatMethodOffsets(uint32_t code_offset, |
| 61 | uint32_t frame_size_in_bytes, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 62 | uint32_t core_spill_mask, |
| 63 | uint32_t fp_spill_mask, |
| 64 | uint32_t mapping_table_offset, |
| 65 | uint32_t vmap_table_offset, |
Brian Carlstrom | e7d856b | 2012-01-11 18:10:55 -0800 | [diff] [blame] | 66 | uint32_t gc_map_offset, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 67 | uint32_t invoke_stub_offset); |
| 68 | ~OatMethodOffsets(); |
| 69 | |
| 70 | uint32_t code_offset_; |
| 71 | uint32_t frame_size_in_bytes_; |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 72 | uint32_t core_spill_mask_; |
| 73 | uint32_t fp_spill_mask_; |
| 74 | uint32_t mapping_table_offset_; |
| 75 | uint32_t vmap_table_offset_; |
Brian Carlstrom | e7d856b | 2012-01-11 18:10:55 -0800 | [diff] [blame] | 76 | uint32_t gc_map_offset_; |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 77 | uint32_t invoke_stub_offset_; |
| 78 | }; |
| 79 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 80 | } // namespace art |
| 81 | |
| 82 | #endif // ART_SRC_OAT_H_ |