oat.h revision 2faa5f1271587cda765f26bcf2951065300a01ff
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 */
16
17#ifndef ART_SRC_OAT_H_
18#define ART_SRC_OAT_H_
19
20#include <vector>
21
22#include "dex_file.h"
23#include "macros.h"
24
25namespace art {
26
27class PACKED OatHeader {
28 public:
29  OatHeader() {}
30  OatHeader(const std::vector<const DexFile*>* dex_files);
31
32  bool IsValid() const;
33  const char* GetMagic() const;
34  uint32_t GetChecksum() const;
35  void UpdateChecksum(const void* data, size_t length);
36  uint32_t GetDexFileCount() const;
37  uint32_t GetExecutableOffset() const;
38  void SetExecutableOffset(uint32_t executable_offset);
39
40 private:
41  static const uint8_t kOatMagic[4];
42  static const uint8_t kOatVersion[4];
43
44  uint8_t magic_[4];
45  uint8_t version_[4];
46  uint32_t adler32_checksum_;
47  uint32_t dex_file_count_;
48  uint32_t executable_offset_;
49
50  DISALLOW_COPY_AND_ASSIGN(OatHeader);
51};
52
53class PACKED OatMethodOffsets {
54 public:
55  OatMethodOffsets();
56  OatMethodOffsets(uint32_t code_offset,
57                   uint32_t frame_size_in_bytes,
58                   uint32_t core_spill_mask,
59                   uint32_t fp_spill_mask,
60                   uint32_t mapping_table_offset,
61                   uint32_t vmap_table_offset,
62                   uint32_t gc_map_offset,
63                   uint32_t invoke_stub_offset);
64  ~OatMethodOffsets();
65
66  uint32_t code_offset_;
67  uint32_t frame_size_in_bytes_;
68  uint32_t core_spill_mask_;
69  uint32_t fp_spill_mask_;
70  uint32_t mapping_table_offset_;
71  uint32_t vmap_table_offset_;
72  uint32_t gc_map_offset_;
73  uint32_t invoke_stub_offset_;
74};
75
76}  // namespace art
77
78#endif  // ART_SRC_OAT_H_
79