blob: 2f3cf9d3a1a55a55dd1347a03dc824b1ba8e7044 [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
Elliott Hughesa72ec822012-03-05 17:12:22 -080022#include "constants.h"
Brian Carlstrome24fa612011-09-29 00:53:55 -070023#include "dex_file.h"
24#include "macros.h"
25
26namespace art {
27
28class PACKED OatHeader {
29 public:
Elliott Hughesa72ec822012-03-05 17:12:22 -080030 OatHeader();
31 OatHeader(InstructionSet instruction_set, const std::vector<const DexFile*>* dex_files);
Brian Carlstrome24fa612011-09-29 00:53:55 -070032
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 Hughesa72ec822012-03-05 17:12:22 -080039 InstructionSet GetInstructionSet() const;
Brian Carlstrome24fa612011-09-29 00:53:55 -070040 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 Hughesa72ec822012-03-05 17:12:22 -080049
50 InstructionSet instruction_set_;
Brian Carlstrome24fa612011-09-29 00:53:55 -070051 uint32_t dex_file_count_;
52 uint32_t executable_offset_;
53
54 DISALLOW_COPY_AND_ASSIGN(OatHeader);
55};
56
Brian Carlstrom3320cf42011-10-04 14:58:28 -070057class PACKED OatMethodOffsets {
58 public:
59 OatMethodOffsets();
60 OatMethodOffsets(uint32_t code_offset,
61 uint32_t frame_size_in_bytes,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070062 uint32_t core_spill_mask,
63 uint32_t fp_spill_mask,
64 uint32_t mapping_table_offset,
65 uint32_t vmap_table_offset,
Brian Carlstrome7d856b2012-01-11 18:10:55 -080066 uint32_t gc_map_offset,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070067 uint32_t invoke_stub_offset);
68 ~OatMethodOffsets();
69
70 uint32_t code_offset_;
71 uint32_t frame_size_in_bytes_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070072 uint32_t core_spill_mask_;
73 uint32_t fp_spill_mask_;
74 uint32_t mapping_table_offset_;
75 uint32_t vmap_table_offset_;
Brian Carlstrome7d856b2012-01-11 18:10:55 -080076 uint32_t gc_map_offset_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070077 uint32_t invoke_stub_offset_;
78};
79
Brian Carlstrome24fa612011-09-29 00:53:55 -070080} // namespace art
81
82#endif // ART_SRC_OAT_H_