1 /* 2 * Copyright (c) 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 LUME_ELF_COMMON_H 17 #define LUME_ELF_COMMON_H 18 19 #include <cstdint> 20 21 #define EI_NIDENT 16 22 #define ET_REL 1 23 #define EM_NONE 0 24 25 #define EV_CURRENT 1 /*original format...*/ 26 #define ELFCLASS32 1 27 #define ELFCLASS64 2 28 #define ELFDATA2LSB 1 29 #define ELFDATA2MSB 1 30 #define ELFOSABI_NONE 0 31 32 #define EM_NONE 0 33 #define EM_386 3 34 #define EM_ARM 40 /* ARM 32 bit */ 35 #define EM_X86_64 62 /* AMD x86-64 */ 36 #define EM_AARCH64 183 /* ARM 64 bit */ 37 38 #define SHT_PROGBITS 1 39 #define SHT_SYMTAB 2 40 #define SHT_STRTAB 3 41 42 #define SHF_ALLOC 0x2 43 #define SHF_MERGE 0x10 44 #define SHN_UNDEF 0 45 #define STB_GLOBAL 1 46 #define STT_OBJECT 1 47 #define STV_HIDDEN 2 48 #define ELF_ST_BIND(info) ((info) >> 4) 49 #define ELF_ST_TYPE(info) ((info)&0xf) 50 #define ELF_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) 51 52 typedef struct ElfIdent { 53 char EI_MAG0; 54 char EI_MAG1; 55 char EI_MAG2; 56 char EI_MAG3; 57 uint8_t EI_CLASS; 58 uint8_t EI_DATA; 59 uint8_t EI_VERSION; 60 uint8_t EI_OSABI; 61 uint8_t EI_PAD[EI_NIDENT - 8]; 62 } ElfIdent; 63 64 #endif // LUME_ELF_COMMON_H 65