Rizin
unix-like reverse engineering framework and cli tools
elf_specs.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 08A <08A@riseup.net>
2 // SPDX-FileCopyrightText: 2009 Nibble <nibble.ds@gmail.com>
3 // SPDX-FileCopyrightText: 2009 pancake <pancake@nopcode.org>
4 // SPDX-License-Identifier: LGPL-3.0-only
5 
6 #undef Elf_
7 #undef Elf_Vword
8 #undef ELF_ST_BIND
9 #undef ELF_ST_TYPE
10 #undef ELF_ST_INFO
11 #undef ELF_ST_VISIBILITY
12 #undef ELF_R_SYM
13 #undef ELF_R_TYPE
14 #undef ELF_R_INFO
15 #undef ELF_M_SYM
16 #undef ELF_M_SIZE
17 #undef ELF_M_INFO
18 
19 #ifdef RZ_BIN_ELF64
20 #define Elf_(name) Elf64_##name
21 #define ELF_ST_BIND ELF64_ST_BIND
22 #define ELF_ST_TYPE ELF64_ST_TYPE
23 #define ELF_ST_INFO ELF64_ST_INFO
24 #define ELF_ST_VISIBILITY ELF64_ST_VISIBILITY
25 #define ELF_R_SYM ELF64_R_SYM
26 #define ELF_R_TYPE ELF64_R_TYPE
27 #define ELF_R_INFO ELF64_R_INFO
28 #define ELF_M_SYM ELF64_M_SYM
29 #define ELF_M_SIZE ELF64_M_SIZE
30 #define ELF_M_INFO ELF64_M_INFO
31 #else
32 #define Elf_(name) Elf32_##name
33 #define ELF_ST_BIND ELF32_ST_BIND
34 #define ELF_ST_TYPE ELF32_ST_TYPE
35 #define ELF_ST_INFO ELF32_ST_INFO
36 #define ELF_ST_VISIBILITY ELF32_ST_VISIBILITY
37 #define ELF_R_SYM ELF32_R_SYM
38 #define ELF_R_TYPE ELF32_R_TYPE
39 #define ELF_R_INFO ELF32_R_INFO
40 #define ELF_M_SYM ELF32_M_SYM
41 #define ELF_M_SIZE ELF32_M_SIZE
42 #define ELF_M_INFO ELF32_M_INFO
43 #endif
44 
45 #define E_IDENT_OFFSET offsetof(Elf_(Ehdr), e_ident)
46 #define E_TYPE_OFFSET offsetof(Elf_(Ehdr), e_type)
47 #define E_MACHINE_OFFSET offsetof(Elf_(Ehdr), e_machine)
48 #define E_VERSION_OFFSET offsetof(Elf_(Ehdr), e_version)
49 #define E_ENTRYPOINT_OFFSET offsetof(Elf_(Ehdr), e_entry)
50 #define E_PHOFF_OFFSET offsetof(Elf_(Ehdr), e_phoff)
51 #define E_SHOFF_OFFSET offsetof(Elf_(Ehdr), e_shoff)
52 #define E_FLAGS_OFFSET offsetof(Elf_(Ehdr), e_flags)
53 #define E_EHSIZE_OFFSET offsetof(Elf_(Ehdr), e_ehsize)
54 #define E_PHENTSIZE_OFFSET offsetof(Elf_(Ehdr), e_phentsize)
55 #define E_PHNUM_OFFSET offsetof(Elf_(Ehdr), e_phnum)
56 #define E_SHENTSIZE_OFFSET offsetof(Elf_(Ehdr), e_shentsize)
57 #define E_SHNUM_OFFSET offsetof(Elf_(Ehdr), e_shnum)
58 #define E_SHSTRNDX_OFFSET offsetof(Elf_(Ehdr), e_shstrndx)
59 
60 /* MingW doesn't define __BEGIN_DECLS / __END_DECLS. */
61 #ifndef __BEGIN_DECLS
62 #ifdef __cplusplus
63 #define __BEGIN_DECLS extern "C" {
64 #else
65 #define __BEGIN_DECLS
66 #endif
67 #endif
68 #ifndef __END_DECLS
69 #ifdef __cplusplus
70 #define __END_DECLS }
71 #else
72 #define __END_DECLS
73 #endif
74 #endif
75 
76 #include "glibc_elf.h"
77 
78 #ifndef _INCLUDE_ELF_SPECS_H
79 #define _INCLUDE_ELF_SPECS_H
80 
81 // not strictly ELF, but close enough:
82 #define CGCMAG "\177CGC"
83 #define SCGCMAG 4
84 
85 #define ELFOSABI_HURD 4 /* GNU/HURD */
86 #define ELFOSABI_86OPEN 5 /* 86open */
87 #define ELFOSABI_OPENVMS 13 /* OpenVMS */
88 #define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
89 
90 #define EM_PROPELLER 0x5072
91 #define EM_LANAI 0x8123
92 #define EM_VIDEOCORE4 200
93 
94 #define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */
95 #define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */
96 
97 #define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ // XXX dupe for EM_NUM
98 #define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */
99 #define EM_NS32K 97 /* National Semiconductor 32000 series */
100 #define EM_TPC 98 /* Tenor Network TPC processor */
101 #define EM_SNP1K 99 /* Trebia SNP 1000 processor */
102 #define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 microcontroller */
103 #define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */
104 #define EM_MAX 102 /* MAX Processor */
105 #define EM_CR 103 /* National Semiconductor CompactRISC microprocessor */
106 #define EM_F2MC16 104 /* Fujitsu F2MC16 */
107 #define EM_MSP430 105 /* Texas Instruments embedded microcontroller msp430 */
108 #define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
109 #define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
110 #define EM_SEP 108 /* Sharp embedded microprocessor */
111 #define EM_ARCA 109 /* Arca RISC Microprocessor */
112 #define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */
113 #define EM_EXCESS 111 /* eXcess: 16/32/64-bit configurable embedded CPU */
114 #define EM_DXP 112 /* Icera Semiconductor Inc. Deep Execution Processor */
115 
116 // http://www.sco.com/developers/gabi/latest/ch4.eheader.html
117 
118 #define EM_CRX 114 /* National Semiconductor CompactRISC CRX microprocessor */
119 #define EM_XGATE 115 /* Motorola XGATE embedded processor */
120 #define EM_C166 116 /* Infineon C16x/XC16x processor */
121 #define EM_M16C 117 /* Renesas M16C series microprocessors */
122 #define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F Digital Signal Controller */
123 #define EM_CE 119 /* Freescale Communication Engine RISC core */
124 #define EM_M32C 120 /* Renesas M32C series microprocessors */
125 #define EM_TSK3000 131 /* Altium TSK3000 core */
126 #define EM_RS08 132 /* Freescale RS08 embedded processor */
127 #define EM_SHARC 133 /* Analog Devices SHARC family of 32-bit DSP processors */
128 #define EM_ECOG2 134 /* Cyan Technology eCOG2 microprocessor */
129 #define EM_SCORE7 135 /* Sunplus S+core7 RISC processor */
130 #define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP Processor */
131 #define EM_VIDEOCORE3 137 /* Broadcom VideoCore III processor */
132 #define EM_LATTICEMICO32 138 /* RISC processor for Lattice FPGA architecture */
133 #define EM_SE_C17 139 /* Seiko Epson C17 family */
134 #define EM_TI_C6000 140 /* The Texas Instruments TMS320C6000 DSP family */
135 #define EM_TI_C2000 141 /* The Texas Instruments TMS320C2000 DSP family */
136 #define EM_TI_C5500 142 /* The Texas Instruments TMS320C55x DSP family */
137 #define EM_TI_ARP32 143 /* Texas Instruments Application Specific RISC Processor, 32bit fetch */
138 #define EM_TI_PRU 144 /* Texas Instruments Programmable Realtime Unit */
139 #define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW Data Signal Processor */
140 #define EM_CYPRESS_M8C 161 /* Cypress M8C microprocessor */
141 #define EM_R32C 162 /* Renesas R32C series microprocessors */
142 #define EM_TRIMEDIA 163 /* NXP Semiconductors TriMedia architecture family */
143 #define EM_QDSP6 164 /* QUALCOMM DSP6 Processor */ // Nonstandard
144 #define EM_8051 165 /* Intel 8051 and variants */
145 #define EM_STXP7X 166 /* STMicroelectronics STxP7x family of configurable and extensible RISC processors */
146 #define EM_NDS32 167 /* Andes Technology compact code size embedded RISC processor family */
147 #define EM_ECOG1 168 /* Cyan Technology eCOG1X family */
148 #define EM_MAXQ30 169 /* Dallas Semiconductor MAXQ30 Core Micro-controllers */
149 #define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP Processor */
150 #define EM_MANIK 171 /* M2000 Reconfigurable RISC Microprocessor */
151 #define EM_CRAYNV2 172 /* Cray Inc. NV2 vector architecture */
152 #define EM_RX 173 /* Renesas RX family */
153 #define EM_METAG 174 /* Imagination Technologies META processor architecture */
154 #define EM_MCST_ELBRUS 175 /* MCST Elbrus general purpose hardware architecture */
155 #define EM_ECOG16 176 /* Cyan Technology eCOG16 family */
156 #define EM_CR16 177 /* National Semiconductor CompactRISC CR16 16-bit microprocessor */
157 #define EM_ETPU 178 /* Freescale Extended Time Processing Unit */
158 #define EM_SLE9X 179 /* Infineon Technologies SLE9X core */
159 #define EM_L10M 180 /* Intel L10M */
160 #define EM_K10M 181 /* Intel K10M */
161 #define EM_AARCH64 183 /* ARM 64-bit architecture (AARCH64) */
162 #define EM_AVR32 185 /* Atmel Corporation 32-bit microprocessor family */
163 #define EM_STM8 186 /* STMicroeletronics STM8 8-bit microcontroller */
164 #define EM_TILE64 187 /* Tilera TILE64 multicore architecture family */
165 #define EM_TILEPRO 188 /* Tilera TILEPro multicore architecture family */
166 #define EM_MICROBLAZE 189 /* Xilinx MicroBlaze 32-bit RISC soft processor core */
167 #define EM_CUDA 190 /* NVIDIA CUDA architecture */
168 #define EM_TILEGX 191 /* Tilera TILE-Gx multicore architecture family */
169 #define EM_CLOUDSHIELD 192 /* CloudShield architecture family */
170 #define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st generation processor family */
171 #define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd generation processor family */
172 #define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */
173 #define EM_OPEN8 196 /* Open8 8-bit RISC soft processor core */
174 #define EM_RL78 197 /* Renesas RL78 family */
175 #define EM_VIDEOCORE5 198 /* Broadcom VideoCore V processor */
176 #define EM_78KOR 199 /* Renesas 78KOR family */
177 #define EM_56800EX 200 /* Freescale 56800EX Digital Signal Controller (DSC) */
178 #define EM_BA1 201 /* Beyond BA1 CPU architecture */
179 #define EM_BA2 202 /* Beyond BA2 CPU architecture */
180 #define EM_BA2_NON_STANDARD 0x8472 /* Beyond BA2 CPU architecture */
181 #define EM_XCORE 203 /* XMOS xCORE processor family */
182 #define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) family */
183 #define EM_INTEL205 205 /* Reserved by Intel */
184 #define EM_INTEL206 206 /* Reserved by Intel */
185 #define EM_INTEL207 207 /* Reserved by Intel */
186 #define EM_INTEL208 208 /* Reserved by Intel */
187 #define EM_INTEL209 209 /* Reserved by Intel */
188 #define EM_KM32 210 /* KM211 KM32 32-bit processor */
189 #define EM_KMX32 211 /* KM211 KMX32 32-bit processor */
190 #define EM_KMX16 212 /* KM211 KMX16 16-bit processor */
191 #define EM_KMX8 213 /* KM211 KMX8 8-bit processor */
192 #define EM_KVARC 214 /* KM211 KVARC processor */
193 #define EM_CDP 215 /* Paneve CDP architecture family */
194 #define EM_COGE 216 /* Cognitive Smart Memory Processor */
195 #define EM_COOL 217 /* Bluechip Systems CoolEngine */
196 #define EM_NORC 218 /* Nanoradio Optimized RISC */
197 #define EM_CSR_KALIMBA 219 /* CSR Kalimba architecture family */
198 #define EM_Z80 220 /* Zilog Z80 */
199 #define EM_VISIUM 221 /* Controls and Data Services VISIUMcore processor */
200 #define EM_FT32 222 /* FTDI Chip FT32 high performance 32-bit RISC architecture */
201 #define EM_MOXIE 223 /* Moxie processor family */
202 #define EM_AMDGPU 224 /* AMD GPU architecture */
203 #define EM_RISCV 243 /* RISC-V */
204 #define EM_KVX 256 /* Kalray VLIW core of the MPPA processor family */
205 
206 // specific OpenBSD sections
207 #ifndef PT_OPENBSD_RANDOMIZE
208 #define PT_OPENBSD_RANDOMIZE 0x65a3dbe6 /* Random data */
209 #define PT_OPENBSD_WXNEEDED 0x65a3dbe7 /* Allowing writable/executable mapping */
210 #define PT_OPENBSD_BOOTDATA 0x65a41be6 /* Boot time data */
211 #endif
212 
213 #endif // _INCLUDE_ELF_SPECS_H