• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef COMPILER_AOT_AOT_HEADERS_H
17 #define COMPILER_AOT_AOT_HEADERS_H
18 
19 #include <array>
20 #include <cstddef>
21 #include <cstdint>
22 
23 namespace panda::compiler {
24 
25 constexpr size_t AOT_HEADER_MAGIC_SIZE = 4;
26 constexpr size_t AOT_HEADER_VERSION_SIZE = 4;
27 
28 struct AotHeader {
29     alignas(alignof(uint32_t)) std::array<char, AOT_HEADER_MAGIC_SIZE> magic;
30     alignas(alignof(uint32_t)) std::array<char, AOT_HEADER_VERSION_SIZE> version;
31     uint32_t checksum;
32     uint32_t environment_checksum;
33     uint32_t arch;
34     uint32_t gc_type;
35     uint32_t files_count;
36     uint32_t files_offset;
37     uint32_t class_hash_tables_offset;
38     uint32_t classes_offset;
39     uint32_t methods_offset;
40     uint32_t bitmap_offset;
41     uint32_t strtab_offset;
42     uint32_t file_name_str;
43     uint32_t cmdline_str;
44     uint32_t boot_aot;
45     uint32_t with_cha;
46     uint32_t class_ctx_str;
47 };
48 
49 static_assert((sizeof(AotHeader) % sizeof(uint32_t)) == 0);
50 static_assert(alignof(AotHeader) == alignof(uint32_t));
51 
52 struct PandaFileHeader {
53     uint32_t class_hash_table_size;
54     uint32_t class_hash_table_offset;
55     uint32_t classes_count;
56     uint32_t classes_offset;
57     uint32_t methods_count;
58     uint32_t methods_offset;
59     uint32_t file_checksum;
60     uint32_t file_offset;
61     uint32_t file_name_str;
62 };
63 
64 struct ClassHeader {
65     uint32_t class_id;
66     uint32_t pab_offset;
67     uint32_t methods_count;
68     uint32_t methods_offset;
69     // Offset to the methods bitmap (aligned as uint32_t)
70     uint32_t methods_bitmap_offset;
71     // Size of bitmap in bits
72     uint32_t methods_bitmap_size;
73 };
74 
75 struct MethodHeader {
76     uint32_t method_id;
77     uint32_t code_offset;
78     uint32_t code_size;
79 };
80 
81 }  // namespace panda::compiler
82 
83 #endif  // COMPILER_AOT_AOT_HEADERS_H
84