RetroArch
elf.h
Go to the documentation of this file.
1 #pragma once
2 #include <cstdint>
3 #include "be_val.h"
4 
5 #pragma pack(push, 1)
6 
7 namespace elf
8 {
9 
10 enum Machine : uint32_t /* e_machine */
11 {
12  EM_PPC = 20 /* PowerPC */
13 };
14 
15 enum Encoding : uint32_t /* e_encoding */
16 {
20 };
21 
22 enum Class : uint32_t /* e_class */
23 {
27 };
28 
29 enum Version : uint32_t /* e_elf_version */
30 {
31  EV_NONE = 0,
33 };
34 
35 enum FileType : uint32_t /* e_type */
36 {
37  ET_NONE = 0, /* No file type */
38  ET_REL = 1, /* Relocatable file */
39  ET_EXEC = 2, /* Executable file */
40  ET_DYN = 3, /* Shared object file */
41  ET_CORE = 4, /* Core file */
42  ET_LOPROC = 0xff00, /* Beginning of processor-specific codes */
43  ET_CAFE_RPL = 0xff01, /* Cafe RPL file */
44  ET_HIPROC = 0xffff /* Processor-specific */
45 };
46 
47 enum EABI : uint32_t /* e_abi */
48 {
49  EABI_CAFE = 0xcafe /* WiiU CafeOS */
50 };
51 
52 enum SectionFlags : uint32_t /* sh_flags */
53 {
54  SHF_WRITE = 0x1,
55  SHF_ALLOC = 0x2,
57  SHF_DEFLATED = 0x08000000,
58  SHF_MASKPROC = 0xF0000000,
59 };
60 
61 enum SectionType : uint32_t /* sh_type */
62 {
63  SHT_NULL = 0, /* No associated section (inactive entry). */
64  SHT_PROGBITS = 1, /* Program-defined contents. */
65  SHT_SYMTAB = 2, /* Symbol table. */
66  SHT_STRTAB = 3, /* String table. */
67  SHT_RELA = 4, /* Relocation entries; explicit addends. */
68  SHT_HASH = 5, /* Symbol hash table. */
69  SHT_DYNAMIC = 6, /* Information for dynamic linking. */
70  SHT_NOTE = 7, /* Information about the file. */
71  SHT_NOBITS = 8, /* Data occupies no space in the file. */
72  SHT_REL = 9, /* Relocation entries; no explicit addends. */
73  SHT_SHLIB = 10, /* Reserved. */
74  SHT_DYNSYM = 11, /* Symbol table. */
75  SHT_INIT_ARRAY = 14, /* Pointers to initialization functions. */
76  SHT_FINI_ARRAY = 15, /* Pointers to termination functions. */
77  SHT_PREINIT_ARRAY = 16, /* Pointers to pre-init functions. */
78  SHT_GROUP = 17, /* Section group. */
79  SHT_SYMTAB_SHNDX = 18, /* Indices for SHN_XINDEX entries. */
80  SHT_LOPROC = 0x70000000, /* Lowest processor arch-specific type. */
81  SHT_HIPROC = 0x7fffffff, /* Highest processor arch-specific type. */
82  SHT_LOUSER = 0x80000000, /* Lowest type reserved for applications. */
83  SHT_RPL_EXPORTS = 0x80000001, /* RPL Exports */
84  SHT_RPL_IMPORTS = 0x80000002, /* RPL Imports */
85  SHT_RPL_CRCS = 0x80000003, /* RPL CRCs */
86  SHT_RPL_FILEINFO = 0x80000004,/* RPL FileInfo */
87  SHT_HIUSER = 0xffffffff /* Highest type reserved for applications. */
88 };
89 
90 enum SymbolBinding : uint32_t /* st_info >> 4 */
91 {
92  STB_LOCAL = 0, /* Local symbol, not visible outside obj file containing def */
93  STB_GLOBAL = 1, /* Global symbol, visible to all object files being combined */
94  STB_WEAK = 2, /* Weak symbol, like global but lower-precedence */
96  STB_LOOS = 10, /* Lowest operating system-specific binding type */
97  STB_HIOS = 12, /* Highest operating system-specific binding type */
98  STB_LOPROC = 13, /* Lowest processor-specific binding type */
99  STB_HIPROC = 15 /* Highest processor-specific binding type */
100 };
101 
102 enum SymbolType : uint32_t /* st_info & f */
103 {
104  STT_NOTYPE = 0, /* Symbol's type is not specified */
105  STT_OBJECT = 1, /* Symbol is a data object (variable, array, etc.) */
106  STT_FUNC = 2, /* Symbol is executable code (function, etc.) */
107  STT_SECTION = 3, /* Symbol refers to a section */
108  STT_FILE = 4, /* Local, absolute symbol that refers to a file */
109  STT_COMMON = 5, /* An uninitialized common block */
110  STT_TLS = 6, /* Thread local data object */
111  STT_LOOS = 7, /* Lowest operating system-specific symbol type */
112  STT_HIOS = 8, /* Highest operating system-specific symbol type */
113  STT_GNU_IFUNC = 10, /* GNU indirect function */
114  STT_LOPROC = 13, /* Lowest processor-specific symbol type */
115  STT_HIPROC = 15 /* Highest processor-specific symbol type */
116 };
117 
118 enum SectionIndex : uint16_t /* st_shndx */
119 {
120  SHN_UNDEF = 0, /* Undefined */
121  SHN_LORESERVE = 0xff00, /* Reserved range */
122  SHN_ABS = 0xfff1, /* Absolute symbols */
123  SHN_COMMON = 0xfff2, /* Common symbols */
124  SHN_XINDEX = 0xffff, /* Escape -- index stored elsewhere */
125  SHN_HIRESERVE = 0xffff
126 };
127 
128 enum RelocationType : uint32_t /* r_info & 0xff */
129 {
153  R_PPC_TLS = 67,
184  R_PPC_REL16 = 249,
188 };
189 
191 {
192  RPL_IS_RPX = 0x2,
193 };
194 
195 static const unsigned HeaderMagic = 0x7f454c46;
196 
197 struct Header
198 {
199  be_val<uint32_t> magic; /* File identification. */
200  be_val<uint8_t> fileClass; /* File class. */
201  be_val<uint8_t> encoding; /* Data encoding. */
202  be_val<uint8_t> elfVersion; /* File version. */
203  be_val<uint16_t> abi; /* OS/ABI identification. (EABI_*) */
205 
206  be_val<uint16_t> type; /* Type of file (ET_*) */
207  be_val<uint16_t> machine; /* Required architecture for this file (EM_*) */
208  be_val<uint32_t> version; /* Must be equal to 1 */
209  be_val<uint32_t> entry; /* Address to jump to in order to start program */
210  be_val<uint32_t> phoff; /* Program header table's file offset, in bytes */
211  be_val<uint32_t> shoff; /* Section header table's file offset, in bytes */
212  be_val<uint32_t> flags; /* Processor-specific flags */
213  be_val<uint16_t> ehsize; /* Size of ELF header, in bytes */
214  be_val<uint16_t> phentsize; /* Size of an entry in the program header table */
215  be_val<uint16_t> phnum; /* Number of entries in the program header table */
216  be_val<uint16_t> shentsize; /* Size of an entry in the section header table */
217  be_val<uint16_t> shnum; /* Number of entries in the section header table */
218  be_val<uint16_t> shstrndx; /* Sect hdr table index of sect name string table */
219 };
220 CHECK_SIZE(Header, 0x34);
221 
223 {
224  be_val<uint32_t> name; /* Section name (index into string table) */
225  be_val<uint32_t> type; /* Section type (SHT_*) */
226  be_val<uint32_t> flags; /* Section flags (SHF_*) */
227  be_val<uint32_t> addr; /* Address where section is to be loaded */
228  be_val<uint32_t> offset; /* File offset of section data, in bytes */
229  be_val<uint32_t> size; /* Size of section, in bytes */
230  be_val<uint32_t> link; /* Section type-specific header table index link */
231  be_val<uint32_t> info; /* Section type-specific extra information */
232  be_val<uint32_t> addralign; /* Section address alignment */
233  be_val<uint32_t> entsize; /* Size of records contained within the section */
234 };
236 
237 struct Symbol
238 {
239  be_val<uint32_t> name; /* Symbol name (index into string table) */
240  be_val<uint32_t> value; /* Value or address associated with the symbol */
241  be_val<uint32_t> size; /* Size of the symbol */
242  be_val<uint8_t> info; /* Symbol's type and binding attributes */
243  be_val<uint8_t> other; /* Must be zero; reserved */
244  be_val<uint16_t> shndx; /* Which section (header table index) it's defined in (SHN_*) */
245 };
246 CHECK_SIZE(Symbol, 0x10);
247 
248 struct Rela
249 {
253 };
254 CHECK_SIZE(Rela, 0x0C);
255 
256 struct RplImport
257 {
260  char name[1];
261 };
262 
263 struct RplExport
264 {
265  struct Export
266  {
269  };
270 
274 };
275 
276 struct RplCrc
277 {
279 };
280 CHECK_SIZE(RplCrc, 0x04);
281 
283 {
309 };
310 CHECK_SIZE(RplFileInfo, 0x60);
311 
312 } /* namespace elf */
313 
314 #pragma pack(pop)
Definition: elf.h:7
Definition: elf.h:114
Definition: elf.h:248
GLuint const GLchar * name
Definition: glext.h:6671
Definition: elf.h:81
Definition: elf.h:122
Definition: elf.h:148
be_val< uint32_t > value
Definition: elf.h:267
Definition: elf.h:79
Definition: elf.h:137
Definition: elf.h:113
Definition: elf.h:167
be_val< uint8_t > elfVersion
Definition: elf.h:202
Definition: elf.h:149
be_val< uint32_t > loadAlign
Definition: elf.h:290
Definition: elf.h:186
Definition: elf.h:158
Definition: elf.h:94
Definition: elf.h:168
Definition: elf.h:84
Definition: elf.h:160
Definition: elf.h:68
Definition: elf.h:192
Definition: elf.h:139
be_val< int32_t > addend
Definition: elf.h:252
Definition: elf.h:72
Definition: elf.h:97
Definition: elf.h:37
be_val< uint32_t > flags
Definition: elf.h:226
Encoding
Definition: elf.h:15
Definition: elf.h:282
Definition: elf.h:134
Definition: elf.h:87
Definition: elf.h:183
Definition: elf.h:164
Definition: elf.h:106
Definition: elf.h:112
be_val< uint32_t > trampAdjust
Definition: elf.h:292
be_val< uint8_t > pad[7]
Definition: elf.h:204
be_val< uint16_t > machine
Definition: elf.h:207
Definition: elf.h:174
FileType
Definition: elf.h:35
Definition: elf.h:175
be_val< uint32_t > name
Definition: elf.h:268
Definition: elf.h:170
Definition: elf.h:99
Definition: elf.h:41
Definition: elf.h:66
be_val< uint8_t > encoding
Definition: elf.h:201
Definition: elf.h:54
be_val< uint32_t > flags
Definition: elf.h:212
Definition: elf.h:197
Definition: elf.h:58
Definition: elf.h:165
Definition: elf.h:163
be_val< uint32_t > tagOffset
Definition: elf.h:299
Definition: elf.h:147
Definition: elf.h:92
be_val< uint8_t > fileClass
Definition: elf.h:200
Definition: elf.h:136
Definition: elf.h:185
Definition: elf.h:123
be_val< uint32_t > loadSize
Definition: elf.h:289
Definition: elf.h:108
be_val< uint32_t > dataAlign
Definition: elf.h:288
be_val< uint16_t > shndx
Definition: elf.h:244
Definition: elf.h:98
Version
Definition: elf.h:29
be_val< uint32_t > value
Definition: elf.h:240
Definition: elf.h:56
be_val< uint32_t > offset
Definition: elf.h:228
Definition: elf.h:263
Definition: elf.h:125
be_val< uint16_t > tlsModuleIndex
Definition: elf.h:306
be_val< uint32_t > tempSize
Definition: elf.h:291
Definition: elf.h:237
Definition: elf.h:69
Definition: elf.h:26
Definition: elf.h:93
be_val< uint8_t > info
Definition: elf.h:242
Definition: elf.h:153
Definition: elf.h:77
Definition: elf.h:86
Definition: elf.h:105
Definition: elf.h:57
be_val< uint16_t > type
Definition: elf.h:206
Definition: elf.h:73
Definition: elf.h:135
be_val< uint32_t > sdaBase
Definition: elf.h:293
be_val< uint32_t > stackSize
Definition: elf.h:295
Definition: elf.h:120
Definition: elf.h:182
Definition: elf.h:276
be_val< uint32_t > version
Definition: elf.h:284
be_val< uint32_t > addr
Definition: elf.h:227
be_val< uint32_t > trampAddition
Definition: elf.h:302
Definition: elf.h:80
be_val< uint32_t > size
Definition: elf.h:229
Definition: elf.h:107
Definition: elf.h:256
Definition: elf.h:38
be_val< uint32_t > flags
Definition: elf.h:297
Definition: elf.h:25
Definition: elf.h:24
Definition: elf.h:18
Definition: elf.h:111
Definition: elf.h:142
Definition: elf.h:124
Definition: elf.h:222
be_val< uint32_t > textAlign
Definition: elf.h:286
Definition: elf.h:184
Definition: elf.h:177
SectionIndex
Definition: elf.h:118
Definition: elf.h:173
Definition: elf.h:162
Definition: elf.h:169
Definition: elf.h:179
be_val< uint32_t > type
Definition: elf.h:225
Definition: elf.h:176
be_val< uint32_t > runtimeFileInfoSize
Definition: elf.h:308
be_val< uint32_t > magic
Definition: elf.h:199
Definition: elf.h:70
be_val< uint32_t > name
Definition: elf.h:224
Definition: elf.h:71
Definition: elf.h:95
be_val< uint32_t > crc
Definition: elf.h:278
RplFileInfoFlag
Definition: elf.h:190
Definition: elf.h:55
be_val< uint32_t > version
Definition: elf.h:208
Definition: elf.h:32
Definition: elf.h:187
be_val< uint32_t > dataSize
Definition: elf.h:287
Definition: elf.h:43
be_val< uint32_t > signature
Definition: elf.h:259
Definition: elf.h:44
be_val< uint32_t > signature
Definition: elf.h:272
Definition: elf.h:65
Definition: elf.h:156
be_val< uint32_t > name
Definition: elf.h:239
Definition: elf.h:265
Definition: elf.h:166
be_val< uint32_t > count
Definition: elf.h:271
be_val< uint16_t > tlsAlignShift
Definition: elf.h:307
RelocationType
Definition: elf.h:128
Definition: elf.h:152
Definition: elf.h:17
EABI
Definition: elf.h:47
be_val< uint32_t > heapSize
Definition: elf.h:298
Definition: elf.h:172
Definition: elf.h:75
Definition: elf.h:82
Definition: elf.h:131
SymbolBinding
Definition: elf.h:90
Definition: elf.h:12
Definition: elf.h:39
be_val< uint32_t > count
Definition: elf.h:258
Definition: elf.h:115
Definition: elf.h:104
Definition: elf.h:145
Definition: elf.h:144
be_val< uint32_t > sda2Base
Definition: elf.h:294
Definition: elf.h:150
Definition: elf.h:64
Class
Definition: elf.h:22
Definition: elf.h:74
be_val< uint16_t > ehsize
Definition: elf.h:213
Export exports[1]
Definition: elf.h:273
Definition: elf.h:138
Definition: elf.h:180
be_val< uint16_t > phnum
Definition: elf.h:215
Definition: elf.h:132
be_val< uint16_t > abi
Definition: elf.h:203
be_val< uint32_t > phoff
Definition: elf.h:210
be_val< uint32_t > fileInfoPad
Definition: elf.h:303
Definition: elf.h:143
Definition: elf.h:133
Definition: elf.h:161
be_val< uint32_t > filename
Definition: elf.h:296
static const unsigned HeaderMagic
Definition: elf.h:195
Definition: elf.h:141
Definition: elf.h:31
CHECK_SIZE(Header, 0x34)
be_val< uint32_t > addralign
Definition: elf.h:232
Definition: elf.h:178
be_val< uint16_t > shstrndx
Definition: elf.h:218
Definition: elf.h:96
Definition: elf.h:146
be_val< uint16_t > phentsize
Definition: elf.h:214
be_val< uint16_t > shentsize
Definition: elf.h:216
Definition: elf.h:151
Definition: elf.h:49
Definition: elf.h:181
Definition: elf.h:83
Definition: elf.h:67
Definition: elf.h:157
be_val< uint32_t > info
Definition: elf.h:231
be_val< uint32_t > textSize
Definition: elf.h:285
Definition: elf.h:42
be_val< uint32_t > info
Definition: elf.h:251
be_val< uint32_t > cafeSdkRevision
Definition: elf.h:305
be_val< uint32_t > size
Definition: elf.h:241
Definition: elf.h:159
Definition: elf.h:154
be_val< uint32_t > offset
Definition: elf.h:250
Definition: elf.h:19
be_val< uint32_t > entsize
Definition: elf.h:233
Definition: elf.h:109
Definition: elf.h:63
Definition: elf.h:155
SectionType
Definition: elf.h:61
unsigned short uint16_t
Definition: stdint.h:125
Definition: elf.h:85
SymbolType
Definition: elf.h:102
be_val< uint32_t > shoff
Definition: elf.h:211
Machine
Definition: elf.h:10
Definition: elf.h:171
unsigned int uint32_t
Definition: stdint.h:126
Definition: elf.h:110
Definition: elf.h:40
Definition: elf.h:130
SectionFlags
Definition: elf.h:52
Definition: elf.h:121
be_val< int32_t > compressionLevel
Definition: elf.h:301
be_val< uint32_t > minVersion
Definition: elf.h:300
be_val< uint32_t > cafeSdkVersion
Definition: elf.h:304
be_val< uint32_t > entry
Definition: elf.h:209
be_val< uint16_t > shnum
Definition: elf.h:217
be_val< uint8_t > other
Definition: elf.h:243
Definition: elf.h:76
be_val< uint32_t > link
Definition: elf.h:230
Definition: elf.h:78
Definition: elf.h:140