blob: 25a4373b73f2a38523b87defe2f56969f3bb1c25 [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();
Brian Carlstrom81f3ca12012-03-17 00:27:35 -070031 OatHeader(InstructionSet instruction_set,
32 const std::vector<const DexFile*>* dex_files,
33 uint32_t image_file_location_checksum,
34 const std::string& image_file_location);
Brian Carlstrome24fa612011-09-29 00:53:55 -070035
36 bool IsValid() const;
37 const char* GetMagic() const;
38 uint32_t GetChecksum() const;
39 void UpdateChecksum(const void* data, size_t length);
40 uint32_t GetDexFileCount() const;
41 uint32_t GetExecutableOffset() const;
Elliott Hughesa72ec822012-03-05 17:12:22 -080042 InstructionSet GetInstructionSet() const;
Brian Carlstrome24fa612011-09-29 00:53:55 -070043 void SetExecutableOffset(uint32_t executable_offset);
Brian Carlstrom81f3ca12012-03-17 00:27:35 -070044 uint32_t GetImageFileLocationChecksum() const;
45 uint32_t GetImageFileLocationSize() const;
46 const uint8_t* GetImageFileLocationData() const;
47 std::string GetImageFileLocation() const;
Brian Carlstrome24fa612011-09-29 00:53:55 -070048
49 private:
50 static const uint8_t kOatMagic[4];
51 static const uint8_t kOatVersion[4];
52
53 uint8_t magic_[4];
54 uint8_t version_[4];
55 uint32_t adler32_checksum_;
Elliott Hughesa72ec822012-03-05 17:12:22 -080056
57 InstructionSet instruction_set_;
Brian Carlstrome24fa612011-09-29 00:53:55 -070058 uint32_t dex_file_count_;
59 uint32_t executable_offset_;
60
Brian Carlstrom81f3ca12012-03-17 00:27:35 -070061 uint32_t image_file_location_checksum_;
62 uint32_t image_file_location_size_;
63 uint8_t image_file_location_data_[0]; // note variable width data at end
64
Brian Carlstrome24fa612011-09-29 00:53:55 -070065 DISALLOW_COPY_AND_ASSIGN(OatHeader);
66};
67
Brian Carlstrom3320cf42011-10-04 14:58:28 -070068class PACKED OatMethodOffsets {
69 public:
70 OatMethodOffsets();
71 OatMethodOffsets(uint32_t code_offset,
72 uint32_t frame_size_in_bytes,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070073 uint32_t core_spill_mask,
74 uint32_t fp_spill_mask,
75 uint32_t mapping_table_offset,
76 uint32_t vmap_table_offset,
Brian Carlstrome7d856b2012-01-11 18:10:55 -080077 uint32_t gc_map_offset,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070078 uint32_t invoke_stub_offset);
79 ~OatMethodOffsets();
80
81 uint32_t code_offset_;
82 uint32_t frame_size_in_bytes_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070083 uint32_t core_spill_mask_;
84 uint32_t fp_spill_mask_;
85 uint32_t mapping_table_offset_;
86 uint32_t vmap_table_offset_;
Brian Carlstrome7d856b2012-01-11 18:10:55 -080087 uint32_t gc_map_offset_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070088 uint32_t invoke_stub_offset_;
89};
90
Brian Carlstrome24fa612011-09-29 00:53:55 -070091} // namespace art
92
93#endif // ART_SRC_OAT_H_