1 /* 2 * Copyright (c) 2021-2024 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 ark::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 environmentChecksum; 33 uint32_t arch; 34 uint32_t gcType; 35 uint32_t filesCount; 36 uint32_t filesOffset; 37 uint32_t classHashTablesOffset; 38 uint32_t classesOffset; 39 uint32_t methodsOffset; 40 uint32_t bitmapOffset; 41 uint32_t strtabOffset; 42 uint32_t fileNameStr; 43 uint32_t cmdlineStr; 44 uint32_t bootAot; 45 uint32_t withCha; 46 uint32_t classCtxStr; 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 classHashTableSize; 54 uint32_t classHashTableOffset; 55 uint32_t classesCount; 56 uint32_t classesOffset; 57 uint32_t methodsCount; 58 uint32_t methodsOffset; 59 uint32_t fileChecksum; 60 uint32_t fileOffset; 61 uint32_t fileNameStr; 62 }; 63 64 struct ClassHeader { 65 uint32_t classId; 66 uint32_t pabOffset; 67 uint32_t methodsCount; 68 uint32_t methodsOffset; 69 // Offset to the methods bitmap (aligned as uint32_t) 70 uint32_t methodsBitmapOffset; 71 // Size of bitmap in bits 72 uint32_t methodsBitmapSize; 73 }; 74 75 struct MethodHeader { 76 uint32_t methodId; 77 uint32_t codeOffset; 78 uint32_t codeSize; 79 }; 80 81 } // namespace ark::compiler 82 83 #endif // COMPILER_AOT_AOT_HEADERS_H 84