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