blob: cd3330bebd318783a9f78e712ecaa44d9707eade [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,
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();
Logan Chien971bf3f2012-05-01 15:47:55 +080071
Brian Carlstrom3320cf42011-10-04 14:58:28 -070072 OatMethodOffsets(uint32_t code_offset,
73 uint32_t frame_size_in_bytes,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070074 uint32_t core_spill_mask,
75 uint32_t fp_spill_mask,
76 uint32_t mapping_table_offset,
77 uint32_t vmap_table_offset,
Brian Carlstrome7d856b2012-01-11 18:10:55 -080078 uint32_t gc_map_offset,
Logan Chienccb7bf12012-03-28 12:52:32 +080079 uint32_t invoke_stub_offset
80#if defined(ART_USE_LLVM_COMPILER)
Logan Chien971bf3f2012-05-01 15:47:55 +080081 , uint32_t proxy_stub_offset
Logan Chienccb7bf12012-03-28 12:52:32 +080082#endif
83 );
Logan Chien971bf3f2012-05-01 15:47:55 +080084
Brian Carlstrom3320cf42011-10-04 14:58:28 -070085 ~OatMethodOffsets();
86
87 uint32_t code_offset_;
88 uint32_t frame_size_in_bytes_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070089 uint32_t core_spill_mask_;
90 uint32_t fp_spill_mask_;
91 uint32_t mapping_table_offset_;
92 uint32_t vmap_table_offset_;
Brian Carlstrome7d856b2012-01-11 18:10:55 -080093 uint32_t gc_map_offset_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070094 uint32_t invoke_stub_offset_;
Logan Chienccb7bf12012-03-28 12:52:32 +080095
96#if defined(ART_USE_LLVM_COMPILER)
Logan Chien971bf3f2012-05-01 15:47:55 +080097 uint32_t proxy_stub_offset_;
Logan Chienccb7bf12012-03-28 12:52:32 +080098#endif
Brian Carlstrom3320cf42011-10-04 14:58:28 -070099};
100
Brian Carlstrome24fa612011-09-29 00:53:55 -0700101} // namespace art
102
103#endif // ART_SRC_OAT_H_