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_32__
16 #define __LUME_ELF_32__
17 #include "elf_common.h"
18 
19 #define ELF32_ST_VISIBILITY(o) ((o)&0x3)
20 
21 typedef uint32_t Elf32_Addr;
22 typedef uint32_t Elf32_Off;
23 typedef uint16_t Elf32_Half;
24 typedef uint32_t Elf32_Word;
25 
26 typedef struct {
27     ElfIdent e_ident = { 0x7f, 'E', 'L', 'F', ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_NONE };
28     Elf32_Half e_type;
29     Elf32_Half e_machine;
30     Elf32_Word e_version;
31     Elf32_Addr e_entry;
32     Elf32_Off e_phoff;
33     Elf32_Off e_shoff;
34     Elf32_Word e_flags;
35     Elf32_Half e_ehsize;
36     Elf32_Half e_phentsize;
37     Elf32_Half e_phnum;
38     Elf32_Half e_shentsize;
39     Elf32_Half e_shnum;
40     Elf32_Half e_shstrndx;
41 } Elf32_Ehdr;
42 
43 typedef struct elf32_shdr {
44     Elf32_Word sh_name;
45     Elf32_Word sh_type;
46     Elf32_Word sh_flags;
47     Elf32_Addr sh_addr;
48     Elf32_Off sh_offset;
49     Elf32_Word sh_size;
50     Elf32_Word sh_link;
51     Elf32_Word sh_info;
52     Elf32_Word sh_addralign;
53     Elf32_Word sh_entsize;
54 } Elf32_Shdr;
55 
56 typedef struct {
57     Elf32_Word st_name;
58     Elf32_Addr st_value;
59     Elf32_Word st_size;
60     unsigned char st_info;
61     unsigned char st_other;
62     Elf32_Half st_shndx;
63 } Elf32_Sym;
64 #endif