1 /* 2 * Copyright (C) 2023 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 #ifndef __LUME_ELF_64__ 16 #define __LUME_ELF_64__ 17 #include "elf_common.h" 18 19 #define ELF64_ST_VISIBILITY(o) ((o)&0x3) 20 21 typedef uint64_t Elf64_Addr; 22 typedef uint64_t Elf64_Off; 23 typedef uint16_t Elf64_Half; 24 typedef uint32_t Elf64_Word; 25 typedef uint64_t Elf64_Xword; 26 27 typedef struct { 28 ElfIdent e_ident = { 0x7f, 'E', 'L', 'F', ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ELFOSABI_NONE }; 29 Elf64_Half e_type; 30 Elf64_Half e_machine; 31 Elf64_Word e_version; 32 Elf64_Addr e_entry; 33 Elf64_Off e_phoff; 34 Elf64_Off e_shoff; 35 Elf64_Word e_flags; 36 Elf64_Half e_ehsize; 37 Elf64_Half e_phentsize; 38 Elf64_Half e_phnum; 39 Elf64_Half e_shentsize; 40 Elf64_Half e_shnum; 41 Elf64_Half e_shstrndx; 42 } Elf64_Ehdr; 43 44 typedef struct elf64_shdr { 45 Elf64_Word sh_name; 46 Elf64_Word sh_type; 47 Elf64_Xword sh_flags; 48 Elf64_Addr sh_addr; 49 Elf64_Off sh_offset; 50 Elf64_Xword sh_size; 51 Elf64_Word sh_link; 52 Elf64_Word sh_info; 53 Elf64_Xword sh_addralign; 54 Elf64_Xword sh_entsize; 55 } Elf64_Shdr; 56 57 typedef struct { 58 Elf64_Word st_name; 59 unsigned char st_info; 60 unsigned char st_other; 61 Elf64_Half st_shndx; 62 Elf64_Addr st_value; 63 Elf64_Xword st_size; 64 } Elf64_Sym; 65 #endif