blob: f07d3f7879641bbc082e4a8fbafd1da43c27f256 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
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 Carlstrome24fa612011-09-29 00:53:55 -070016
17#ifndef ART_SRC_OAT_H_
18#define ART_SRC_OAT_H_
19
20#include <vector>
21
22#include "dex_file.h"
Elliott Hughes0f3c5532012-03-30 14:51:51 -070023#include "instruction_set.h"
Brian Carlstrome24fa612011-09-29 00:53:55 -070024#include "macros.h"
25
26namespace art {
27
28class PACKED OatHeader {
29 public:
Elliott Hughesa72ec822012-03-05 17:12:22 -080030 OatHeader();
Brian Carlstrom81f3ca12012-03-17 00:27:35 -070031 OatHeader(InstructionSet instruction_set,
32 const std::vector<const DexFile*>* dex_files,
Logan Chien25ae6402012-03-20 20:19:26 +080033 uint32_t elf_image_count,
Brian Carlstrom81f3ca12012-03-17 00:27:35 -070034 uint32_t image_file_location_checksum,
35 const std::string& image_file_location);
Brian Carlstrome24fa612011-09-29 00:53:55 -070036
37 bool IsValid() const;
38 const char* GetMagic() const;
39 uint32_t GetChecksum() const;
40 void UpdateChecksum(const void* data, size_t length);
41 uint32_t GetDexFileCount() const;
Logan Chien25ae6402012-03-20 20:19:26 +080042 uint32_t GetElfImageCount() const;
43 uint32_t GetElfImageTableOffset() const;
Brian Carlstrome24fa612011-09-29 00:53:55 -070044 uint32_t GetExecutableOffset() const;
Elliott Hughesa72ec822012-03-05 17:12:22 -080045 InstructionSet GetInstructionSet() const;
Logan Chien25ae6402012-03-20 20:19:26 +080046 void SetElfImageTableOffset(uint32_t elf_image_offset);
Brian Carlstrome24fa612011-09-29 00:53:55 -070047 void SetExecutableOffset(uint32_t executable_offset);
Brian Carlstrom81f3ca12012-03-17 00:27:35 -070048 uint32_t GetImageFileLocationChecksum() const;
49 uint32_t GetImageFileLocationSize() const;
50 const uint8_t* GetImageFileLocationData() const;
51 std::string GetImageFileLocation() const;
Brian Carlstrome24fa612011-09-29 00:53:55 -070052
53 private:
54 static const uint8_t kOatMagic[4];
55 static const uint8_t kOatVersion[4];
56
57 uint8_t magic_[4];
58 uint8_t version_[4];
59 uint32_t adler32_checksum_;
Elliott Hughesa72ec822012-03-05 17:12:22 -080060
61 InstructionSet instruction_set_;
Brian Carlstrome24fa612011-09-29 00:53:55 -070062 uint32_t dex_file_count_;
Logan Chien25ae6402012-03-20 20:19:26 +080063 uint32_t elf_image_count_;
64 uint32_t elf_image_table_offset_;
Brian Carlstrome24fa612011-09-29 00:53:55 -070065 uint32_t executable_offset_;
66
Brian Carlstrom81f3ca12012-03-17 00:27:35 -070067 uint32_t image_file_location_checksum_;
68 uint32_t image_file_location_size_;
69 uint8_t image_file_location_data_[0]; // note variable width data at end
70
Brian Carlstrome24fa612011-09-29 00:53:55 -070071 DISALLOW_COPY_AND_ASSIGN(OatHeader);
72};
73
Brian Carlstrom3320cf42011-10-04 14:58:28 -070074class PACKED OatMethodOffsets {
75 public:
76 OatMethodOffsets();
77 OatMethodOffsets(uint32_t code_offset,
78 uint32_t frame_size_in_bytes,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070079 uint32_t core_spill_mask,
80 uint32_t fp_spill_mask,
81 uint32_t mapping_table_offset,
82 uint32_t vmap_table_offset,
Brian Carlstrome7d856b2012-01-11 18:10:55 -080083 uint32_t gc_map_offset,
Logan Chienccb7bf12012-03-28 12:52:32 +080084 uint32_t invoke_stub_offset
85#if defined(ART_USE_LLVM_COMPILER)
86 , uint32_t code_elf_idx,
87 uint32_t invoke_stub_elf_idx
88#endif
89 );
Brian Carlstrom3320cf42011-10-04 14:58:28 -070090 ~OatMethodOffsets();
91
92 uint32_t code_offset_;
93 uint32_t frame_size_in_bytes_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070094 uint32_t core_spill_mask_;
95 uint32_t fp_spill_mask_;
96 uint32_t mapping_table_offset_;
97 uint32_t vmap_table_offset_;
Brian Carlstrome7d856b2012-01-11 18:10:55 -080098 uint32_t gc_map_offset_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070099 uint32_t invoke_stub_offset_;
Logan Chienccb7bf12012-03-28 12:52:32 +0800100
101#if defined(ART_USE_LLVM_COMPILER)
102 uint32_t code_elf_idx_;
103 uint32_t invoke_stub_elf_idx_;
104#endif
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700105};
106
Brian Carlstrome24fa612011-09-29 00:53:55 -0700107} // namespace art
108
109#endif // ART_SRC_OAT_H_