RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
elf.h
1#ifndef ELF_H
2#define ELF_H
3
4#include <sstream>
5#include <vector>
6#include "../common.h"
7#include "../dumper/dumper.h"
8#include "../linker/buffer.h"
9#include "../linker/format.h"
10#include "../linker/module.h"
11#include "../linker/reader.h"
12#include "../linker/segment_manager.h"
13
14namespace ELF
15{
21 class ELFFormat : public virtual Linker::InputFormat, public virtual Linker::SegmentManager
22 {
23 public:
24 /* * * General members * * */
25
26 static constexpr uint8_t EI_OSABI = 7;
27 static constexpr uint8_t EI_ABIVERSION = 8;
28 static constexpr uint8_t EI_CLASS = 4;
29 static constexpr uint8_t EI_DATA = 5;
30
31 static constexpr uint8_t ELFCLASSNONE = 0;
32 static constexpr uint8_t ELFCLASS32 = 1;
33 static constexpr uint8_t ELFCLASS64 = 2;
34
35 static constexpr uint8_t ELFDATANONE = 0;
36 static constexpr uint8_t ELFDATA2LSB = 1;
37 static constexpr uint8_t ELFDATA2MSB = 2;
38
39 static constexpr uint8_t EV_NONE = 0;
40 static constexpr uint8_t EV_CURRENT = 1;
41
42 static constexpr uint8_t ELFOSABI_NONE = 0;
43
44 static constexpr offset_t SHF_WRITE = 0x0001;
45 static constexpr offset_t SHF_ALLOC = 0x0002;
46 static constexpr offset_t SHF_EXECINSTR = 0x0004;
47 static constexpr offset_t SHF_MERGE = 0x0010;
48 static constexpr offset_t SHF_STRINGS = 0x0020;
49 static constexpr offset_t SHF_INFO_LINK = 0x0040;
50 static constexpr offset_t SHF_LINK_ORDER = 0x0080;
51 static constexpr offset_t SHF_OS_NONCONFORMING = 0x0100;
52 static constexpr offset_t SHF_GROUP = 0x0200;
53 static constexpr offset_t SHF_TLS = 0x0400;
54 static constexpr offset_t SHF_COMPRESSED = 0x0800;
55 /* GNU specific */
56 static constexpr offset_t SHF_GNU_RETAIN = 0x00200000;
57 static constexpr offset_t SHF_GNU_MBIND = 0x01000000;
58 static constexpr offset_t SHF_EXCLUDE = 0x80000000;
59 /* OS/2 specific */
60 static constexpr offset_t SHF_BEGIN = 0x01000000;
61 static constexpr offset_t SHF_END = 0x02000000;
62
63 static constexpr uint16_t SHN_UNDEF = 0;
64 static constexpr uint16_t SHN_LORESERVE = 0xFF00;
65 static constexpr uint16_t SHN_ABS = 0xFFF1;
66 static constexpr uint16_t SHN_COMMON = 0xFFF2;
67 static constexpr uint16_t SHN_XINDEX = 0xFFFF;
68
69 static constexpr uint8_t STB_LOCAL = 0;
70 static constexpr uint8_t STB_GLOBAL = 1;
71 static constexpr uint8_t STB_WEAK = 2;
72 static constexpr uint8_t STB_ENTRY = 12; /* IBM OS/2 */
73
74 static constexpr uint8_t STT_NOTYPE = 0;
75 static constexpr uint8_t STT_OBJECT = 1;
76 static constexpr uint8_t STT_FUNC = 2;
77 static constexpr uint8_t STT_SECTION = 3;
78 static constexpr uint8_t STT_FILE = 4;
79 static constexpr uint8_t STT_COMMON = 5;
80 static constexpr uint8_t STT_TLS = 6;
81 static constexpr uint8_t STT_IMPORT = 11; /* IBM OS/2 */
82
83 static constexpr uint8_t STV_DEFAULT = 0;
84 static constexpr uint8_t STV_INTERNAL = 1;
85 static constexpr uint8_t STV_HIDDEN = 2;
86 static constexpr uint8_t STV_PROTECTED = 3;
87
88 static constexpr offset_t R_386_8 = 22;
89 static constexpr offset_t R_386_PC8 = 23;
90 static constexpr offset_t R_386_16 = 20;
91 static constexpr offset_t R_386_PC16 = 21;
92 static constexpr offset_t R_386_32 = 1;
93 static constexpr offset_t R_386_PC32 = 2;
94 static constexpr offset_t R_386_GOT32 = 3;
95 static constexpr offset_t R_386_GOTPC = 10;
96 static constexpr offset_t R_386_GOTOFF = 9;
97 static constexpr offset_t R_386_PLT32 = 4;
99 static constexpr offset_t R_386_SEG16 = 45;
101 static constexpr offset_t R_386_SUB16 = 46;
103 static constexpr offset_t R_386_SUB32 = 47;
105 static constexpr offset_t R_386_SEGRELATIVE = 48;
107 static constexpr offset_t R_386_OZSEG16 = 80;
109 static constexpr offset_t R_386_OZRELSEG16 = 81;
110
111 static constexpr offset_t R_68K_8 = 3;
112 static constexpr offset_t R_68K_PC8 = 6;
113 static constexpr offset_t R_68K_16 = 2;
114 static constexpr offset_t R_68K_PC16 = 5;
115 static constexpr offset_t R_68K_32 = 1;
116 static constexpr offset_t R_68K_PC32 = 4;
117 static constexpr offset_t R_68K_GOT8 = 9;
118 static constexpr offset_t R_68K_GOT8O = 12;
119 static constexpr offset_t R_68K_GOT16 = 8;
120 static constexpr offset_t R_68K_GOT16O = 11;
121 static constexpr offset_t R_68K_GOT32 = 7;
122 static constexpr offset_t R_68K_GOT32O = 10;
123 static constexpr offset_t R_68K_PLT8 = 15;
124 static constexpr offset_t R_68K_PLT8O = 18;
125 static constexpr offset_t R_68K_PLT16 = 14;
126 static constexpr offset_t R_68K_PLT16O = 17;
127 static constexpr offset_t R_68K_PLT32 = 13;
128 static constexpr offset_t R_68K_PLT32O = 16;
129
130 static constexpr offset_t R_ARM_ABS8 = 8;
131 static constexpr offset_t R_ARM_ABS16 = 16;
132 static constexpr offset_t R_ARM_ABS32 = 2;
133 static constexpr offset_t R_ARM_REL32 = 3;
134 static constexpr offset_t R_ARM_CALL = 28;
135 static constexpr offset_t R_ARM_JUMP24 = 29;
136 static constexpr offset_t R_ARM_PC24 = 1;
137 static constexpr offset_t R_ARM_V4BX = 40;
138
139 static constexpr offset_t DT_NULL = 0;
140 static constexpr offset_t DT_NEEDED = 1;
141 static constexpr offset_t DT_PLTRELSZ = 2;
142 static constexpr offset_t DT_PLTGOT = 3;
143 static constexpr offset_t DT_HASH = 4;
144 static constexpr offset_t DT_STRTAB = 5;
145 static constexpr offset_t DT_SYMTAB = 6;
146 static constexpr offset_t DT_RELA = 7;
147 static constexpr offset_t DT_RELASZ = 8;
148 static constexpr offset_t DT_RELAENT = 9;
149 static constexpr offset_t DT_STRSZ = 10;
150 static constexpr offset_t DT_SYMENT = 11;
151 static constexpr offset_t DT_INIT = 12;
152 static constexpr offset_t DT_FINI = 13;
153 static constexpr offset_t DT_SONAME = 14;
154 static constexpr offset_t DT_RPATH = 15;
155 static constexpr offset_t DT_SYMBOLIC = 16;
156 static constexpr offset_t DT_REL = 17;
157 static constexpr offset_t DT_RELSZ = 18;
158 static constexpr offset_t DT_RELENT = 19;
159 static constexpr offset_t DT_PLTREL = 20;
160 static constexpr offset_t DT_DEBUG = 21;
161 static constexpr offset_t DT_TEXTREL = 22;
162 static constexpr offset_t DT_JMPREL = 23;
163 static constexpr offset_t DT_BIND_NOW = 24;
164 static constexpr offset_t DT_INIT_ARRAY = 25;
165 static constexpr offset_t DT_FINI_ARRAY = 26;
166 static constexpr offset_t DT_INIT_ARRAYSZ = 27;
167 static constexpr offset_t DT_FINI_ARRAYSZ = 28;
168 static constexpr offset_t DT_RUNPATH = 29;
169 static constexpr offset_t DT_FLAGS = 30;
170 static constexpr offset_t DT_ENCODING = 31;
171 static constexpr offset_t DT_PREINIT_ARRAY = 32;
172 static constexpr offset_t DT_PREINIT_ARRAYSZ = 33;
173 static constexpr offset_t DT_SYMTAB_SHNDX = 34;
174 static constexpr offset_t DT_RELRSZ = 35;
175 static constexpr offset_t DT_RELR = 36;
176 static constexpr offset_t DT_RELRENT = 37;
177 /* IBM OS/2 specific */
178 static constexpr offset_t DT_EXPORT = 0x60000001;
179 static constexpr offset_t DT_EXPORTSZ = 0x60000002;
180 static constexpr offset_t DT_EXPENT = 0x60000003;
181 static constexpr offset_t DT_IMPORT = 0x60000004;
182 static constexpr offset_t DT_IMPORTSZ = 0x60000005;
183 static constexpr offset_t DT_IMPENT = 0x60000006;
184 static constexpr offset_t DT_IT = 0x60000007;
185 static constexpr offset_t DT_ITPRTY = 0x60000008;
186 static constexpr offset_t DT_INITTERM = 0x60000009;
187 static constexpr offset_t DT_STACKSZ = 0x6000000A;
188 /* GNU binutils */
189 static constexpr offset_t DT_GNU_FLAGS1 = 0x6FFFFDF4;
190 static constexpr offset_t DT_GNU_PRELINKED = 0x6FFFFDF5;
191 static constexpr offset_t DT_GNU_CONFLICTSZ = 0x6FFFFDF6;
192 static constexpr offset_t DT_GNU_LIBLISTSZ = 0x6FFFFDF7;
193 static constexpr offset_t DT_CHECKSUM = 0x6FFFFDF8;
194 static constexpr offset_t DT_PLTPADSZ = 0x6FFFFDF9;
195 static constexpr offset_t DT_MOVEENT = 0x6FFFFDFA;
196 static constexpr offset_t DT_MOVESZ = 0x6FFFFDFB;
197 static constexpr offset_t DT_FEATURE = 0x6FFFFDFC;
198 static constexpr offset_t DT_POSTFLAG_1 = 0x6FFFFDFD;
199 static constexpr offset_t DT_SYMINSZ = 0x6FFFFDFE;
200 static constexpr offset_t DT_SYMINENT = 0x6FFFFDFF;
201 static constexpr offset_t DT_GNU_HASH = 0x6FFFFEF5;
202 static constexpr offset_t DT_TLSDESC_PLT = 0x6FFFFEF6;
203 static constexpr offset_t DT_TLSDESC_GOT = 0x6FFFFEF7;
204 static constexpr offset_t DT_GNU_CONFLICT = 0x6FFFFFEF8;
205 static constexpr offset_t DT_GNU_LIBLIST = 0x6FFFFEF9;
206 static constexpr offset_t DT_CONFIG = 0x6FFFFEFA;
207 static constexpr offset_t DT_DEPAUDIT = 0x6FFFFEFB;
208 static constexpr offset_t DT_AUDIT = 0x6FFFFEFC;
209 static constexpr offset_t DT_PLTPAD = 0x6FFFFEFD;
210 static constexpr offset_t DT_MOVETAB = 0x6FFFFEFE;
211 static constexpr offset_t DT_SYMINFO = 0x6FFFFEFF;
212 static constexpr offset_t DT_VERSYM = 0x6FFFFFF0;
213 static constexpr offset_t DT_RELACOUNT = 0x6FFFFFF9;
214 static constexpr offset_t DT_RELCOUNT = 0x6FFFFFFA;
215 static constexpr offset_t DT_FLAGS_1 = 0x6FFFFFFB;
216 static constexpr offset_t DT_VERDEF = 0x6FFFFFFC;
217 static constexpr offset_t DT_VERDEFNUM = 0x6FFFFFFD;
218 static constexpr offset_t DT_VERNEED = 0x6FFFFFFE;
219 static constexpr offset_t DT_VERNEEDNUM = 0x6FFFFFFF;
220 static constexpr offset_t DT_AUXILIARY = 0x7FFFFFFD;
221 static constexpr offset_t DT_USED = 0x7FFFFFFE;
222 static constexpr offset_t DT_FILTER = 0x7FFFFFFFF;
223
224 offset_t file_offset = 0;
225
226 uint8_t file_class = 0;
227 EndianType endiantype = ::LittleEndian;
228
229 uint8_t data_encoding = 0;
230 size_t wordbytes = 4;
231
232 enum cpu_type
233 {
234 EM_NONE = 0,
235 EM_M32 = 1,
236 EM_SPARC = 2,
237 EM_386 = 3,
238 EM_68K = 4,
239 EM_88K = 5,
240 EM_IAMCU = 6,
241 EM_860 = 7,
242 EM_MIPS = 8,
243 EM_S370 = 9,
244 EM_MIPS_RS3_LE = 10,
245 EM_OLD_SPARCV9 = 11, // https://github.com/bminor/binutils-gdb/blob/master/include/elf/common.h
246
247 EM_PARISC = 15,
248
249 EM_VPP500 = 17,
250 EM_SPARC32PLUS = 18,
251 EM_960 = 19,
252 EM_PPC = 20,
253 EM_PPC64 = 21,
254 EM_S390 = 22,
255 EM_SPU = 23,
256
257 EM_V800 = 36,
258 EM_FR20 = 37,
259 EM_RH32 = 38,
260 EM_MCORE = 39,
261 EM_RCE = EM_MCORE,
262 EM_ARM = 40,
263 EM_ALPHA = 41,
264 EM_SH = 42,
265 EM_SPARCV9 = 43,
266 EM_TRICORE = 44,
267 EM_ARC = 45,
268 EM_H8_300 = 46,
269 EM_H8_300H = 47,
270 EM_H8S = 48,
271 EM_H8_500 = 49,
272 EM_IA_64 = 50,
273 EM_MIPS_X = 51,
274 EM_COLDFIRE = 52,
275 EM_68HC12 = 53,
276 EM_MMA = 54,
277 EM_PCP = 55,
278 EM_NCPU = 56,
279 EM_NDR1 = 57,
280 EM_STARCORE = 58,
281 EM_ME16 = 59,
282 EM_ST100 = 60,
283 EM_TINYJ = 61,
284 EM_X86_64 = 62,
285 EM_PDSP = 63,
286 EM_PDP10 = 64,
287 EM_PDP11 = 65,
288 EM_FX66 = 66,
289 EM_ST9PLUS = 67,
290 EM_ST7 = 68,
291 EM_68HC16 = 69,
292 EM_68HC11 = 70,
293 EM_68HC08 = 71,
294 EM_68HC05 = 72,
295 EM_SVX = 73,
296 EM_ST19 = 74,
297 EM_VAX = 75,
298 EM_CRIS = 76,
299 EM_JAVELIN = 77,
300 EM_FIREPATH = 78,
301 EM_ZSP = 79,
302 EM_MMIX = 80,
303 EM_HUANY = 81,
304 EM_PRISM = 82,
305 EM_AVR = 83,
306 EM_FR30 = 84,
307 EM_D10V = 85,
308 EM_D30V = 86,
309 EM_V850 = 87,
310 EM_M32R = 88,
311 EM_MN10300 = 89,
312 EM_MN10200 = 90,
313 EM_PJ = 91,
314 EM_OPENRISC = 92,
315 EM_ARC_COMPACT = 93,
316 EM_ARC_A5 = EM_ARC_COMPACT,
317 EM_XTENSA = 94,
318 EM_SCORE_OLD = 95,
319 EM_VIDEOCORE = 95,
320 EM_TMM_GPP = 96,
321 EM_NS32K = 97,
322 EM_TPC = 98,
323 EM_PJ_OLD = 99,
324 EM_SNP1K = 99,
325 EM_ST200 = 100,
326 EM_IP2K = 101,
327 EM_MAX = 102,
328 EM_CR = 103,
329 EM_F2MC16 = 104,
330 EM_MSP430 = 105,
331 EM_BLACKFIN = 106,
332 EM_SE_C33 = 107,
333 EM_SEP = 108,
334 EM_ARCA = 109,
335 EM_UNICORE = 110,
336 EM_EXCESS = 111,
337 EM_DXP = 112,
338 EM_ALTERA_NIOS32 = 113,
339 EM_CRX = 114,
340 EM_CR16_OLD = 115,
341 EM_XGATE = 115,
342 EM_C166 = 116,
343 EM_M16C = 117,
344 EM_DSPIC30F = 118,
345 EM_CE = 119,
346 EM_M32C = 120,
347
348 EM_TSK3000 = 131,
349 EM_RS08 = 132,
350 EM_SHARC = 133,
351 EM_ECOG2 = 134,
352 EM_SCORE7 = 135,
353 EM_DSP24 = 136,
354 EM_VIDEOCORE3 = 137,
355 EM_LATTICEMICO32 = 138,
356 EM_SE_CE17 = 139,
357 EM_TI_C6000 = 140,
358 EM_TI_C2000 = 141,
359 EM_TI_C5500 = 142,
360 EM_TI_ARP32 = 143,
361 EM_TI_PRU = 144,
362
363 EM_MMDSP_PLUS = 160,
364 EM_CYPRESS_M8C = 161,
365 EM_R32C = 162,
366 EM_TRIMEDIA = 163,
367 EM_QDSP6 = 164,
368 EM_8051 = 165,
369 EM_STXP7X = 166,
370 EM_NDS32 = 167,
371 EM_ECOG1 = 168,
372 EM_ECOG1X = EM_ECOG1,
373 EM_MAXQ30 = 169,
374 EM_XIMO16 = 170,
375 EM_MANIK = 171,
376 EM_CRAYNV2 = 172,
377 EM_RX = 173,
378 EM_METAG = 174,
379 EM_MCST_ELBRUS = 175,
380 EM_ECOG16 = 176,
381 EM_CR16 = 177,
382 EM_ETPU = 178,
383 EM_SLE9X = 179,
384 EM_L10M = 180,
385 EM_K10M = 181,
386 EM_INTEL182 = 182,
387 EM_AARCH64 = 183,
388 EM_ARM184 = 184,
389 EM_AVR32 = 185,
390 EM_STM8 = 186,
391 EM_TILE64 = 187,
392 EM_TILEPRO = 188,
393 EM_MICROBLAZE = 189,
394 EM_CUDA = 190,
395 EM_TILEGX = 191,
396 EM_CLOUDSHIELD = 192,
397 EM_COREA_1ST = 193,
398 EM_COREA_2ND = 194,
399 EM_ARC_COMPACT2 = 195,
400 EM_OPEN8 = 196,
401 EM_RL78 = 197,
402 EM_VIDEOCORE5 = 198,
403 EM_78KOR = 199,
404 EM_56800EX = 200,
405 EM_BA1 = 201,
406 EM_BA2 = 202,
407 EM_XCORE = 203,
408 EM_MCHP_PIC = 204,
409 EM_INTELGT = 205, // https://github.com/bminor/binutils-gdb/blob/master/include/elf/common.h
410 EM_INTEL206 = 206,
411 EM_INTEL207 = 207,
412 EM_INTEL208 = 208,
413 EM_INTEL209 = 209,
414 EM_KM32 = 210,
415 EM_KMX32 = 211,
416 EM_KMX16 = 212,
417 EM_KMX8 = 213,
418 EM_KVARC = 214,
419 EM_CDP = 215,
420 EM_COGE = 216,
421 EM_COOL = 217,
422 EM_NORC = 218,
423 EM_CSR_KALIMBA = 219,
424 EM_Z80 = 220,
425 EM_VISIUM = 221,
426 EM_FT32 = 222,
427 EM_MOXIE = 223,
428 EM_AMDGPU = 224,
429
430 EM_RISCV = 243,
431 // https://github.com/bminor/binutils-gdb/blob/master/include/elf/common.h
432 EM_LANAI = 244,
433 EM_CEVA = 245,
434 EM_CEVA_X2 = 246,
435 EM_BPF = 247,
436 EM_GRAPHCORE_IPU = 248,
437 EM_IMG1 = 249,
438 EM_NFP = 250,
439 EM_VE = 251,
440 EM_CSKY = 252,
441 EM_ARC_COMPACT3_64 = 253,
442 EM_MCS6502 = 254,
443 EM_ARC_COMPACT3 = 255,
444 EM_KVX = 256,
445 EM_65816 = 257,
446 EM_LOONGARCH = 258,
447 EM_KF32 = 259,
448 EM_U16_U8CORE = 260,
449 EM_TACHYUM = 261,
450 EM_56800EF = 262,
451
452 // apparently used by BeOS for the AT&T Hobbit
453 EM_HOBBIT = 925,
454
455 // https://llvm-mos.org/wiki/ELF_specification
456 EM_MOS = 6502,
457 };
458 cpu_type cpu = EM_NONE;
459
460 uint8_t header_version = 0;
461 uint8_t osabi = 0;
462 uint8_t abi_version = 0;
463
464 enum file_type
465 {
466 ET_NONE = 0,
467 ET_REL = 1,
468 ET_EXEC = 2,
469 ET_DYN = 3,
470 ET_CORE = 4,
471 };
472 file_type object_file_type = ET_NONE;
473 uint16_t file_version = 0;
474
475 offset_t entry = 0;
476 offset_t program_header_offset = 0;
477 offset_t section_header_offset = 0;
478 uint32_t flags = 0;
479 uint16_t elf_header_size = 0;
480 uint16_t program_header_entry_size = 0;
481 uint16_t section_header_entry_size = 0;
482 uint16_t section_name_string_table = 0;
483
485 {
486 public:
487 virtual void AddDumperFields(std::unique_ptr<Dumper::Region>& region, Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const;
488 virtual void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const;
489 };
490
491 class Symbol
492 {
493 public:
494 uint32_t name_offset = 0;
495 std::string name;
496 offset_t value = 0, size = 0;
497 uint8_t bind = 0, type = 0, other = 0;
498 uint32_t shndx = 0;
499 uint32_t sh_link = 0;
500 bool defined = false;
501 bool unallocated = false;
502 Linker::Location location;
503 Linker::SymbolDefinition specification;
504 };
505
507 {
508 public:
509 size_t wordbytes;
510 offset_t entsize;
511 /* used for SHT_SYMTAB and SHT_DYNSYM */
512 std::vector<Symbol> symbols;
513
514 SymbolTable(size_t wordbytes, offset_t entsize)
515 : wordbytes(wordbytes), entsize(entsize)
516 {
517 }
518
519 offset_t ImageSize() const override;
521 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
522 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
523 };
524
526 {
527 public:
528 offset_t size;
529 /* used for SHT_STRTAB */
530 std::vector<std::string> strings;
531
532 StringTable(offset_t size)
533 : size(size)
534 {
535 }
536
537 offset_t ImageSize() const override;
539 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
540 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
541 };
542
543 class Array : public SectionContents
544 {
545 public:
546 offset_t entsize;
547 /* used for SHT_SYMTAB_SHNDX, SHT_INIT_ARRAY/SHT_FINI_ARRAY/SHT_PREINIT_ARRAY, SHT_GROUP */
548 std::vector<offset_t> array;
549
550 Array(offset_t entsize)
551 : entsize(entsize)
552 {
553 }
554
555 offset_t ImageSize() const override;
557 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
558 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
559 };
560
561 class SectionGroup : public Array
562 {
563 public:
564 offset_t flags = 0;
565
566 SectionGroup(offset_t entsize)
567 : Array(entsize)
568 {
569 }
570
571 offset_t ImageSize() const override;
573 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
574 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
575 void AddDumperFields(std::unique_ptr<Dumper::Region>& region, Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
576 };
577
578 class IndexArray : public Array
579 {
580 public:
581 IndexArray(offset_t entsize)
582 : Array(entsize)
583 {
584 }
585
586 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
587 };
588
590 {
591 public:
592 offset_t offset = 0;
593 uint32_t type = 0;
594 uint32_t symbol = 0;
595 int64_t addend = 0;
596 uint32_t sh_link = 0, sh_info = 0;
597 bool addend_from_section_data = false;
598
599 size_t GetSize(cpu_type cpu) const;
600 std::string GetName(cpu_type cpu) const;
601 };
602
604 {
605 public:
606 size_t wordbytes;
607 offset_t entsize;
608 /* used for SHT_REL, SHT_RELA */
609 std::vector<Relocation> relocations;
610
611 Relocations(size_t wordbytes, offset_t entsize)
612 : wordbytes(wordbytes), entsize(entsize)
613 {
614 }
615
616 offset_t ImageSize() const override;
618 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
619 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
620 };
621
623 {
624 public:
625 std::vector<uint32_t> buckets;
626 std::vector<uint32_t> chains;
627
628 static uint32_t Hash(const std::string& name);
629
630 offset_t ImageSize() const override;
632 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
633 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
634 void AddDumperFields(std::unique_ptr<Dumper::Region>& region, Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
635 };
636
638 {
639 public:
640 offset_t tag;
641 offset_t value;
642 std::string name;
643
645 : tag(0), value(0)
646 {
647 }
648
649 DynamicObject(offset_t tag, offset_t value)
650 : tag(tag), value(value)
651 {
652 }
653 };
654
656 {
657 public:
658 size_t wordbytes;
659 offset_t entsize;
660 /* used for SHT_DYNAMIC */
661 std::vector<DynamicObject> dynamic;
662
663 DynamicSection(size_t wordbytes, offset_t entsize)
664 : wordbytes(wordbytes), entsize(entsize)
665 {
666 }
667
668 offset_t ImageSize() const override;
670 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
671 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
672 };
673
674 class Note
675 {
676 public:
677 std::string name;
678 std::string descriptor;
679 offset_t type;
680 };
681
683 {
684 public:
685 offset_t size;
686
687 /* used for SHT_NOTE */
688 std::vector<Note> notes;
689
690 NotesSection(offset_t size)
691 : size(size)
692 {
693 }
694
695 offset_t ImageSize() const override;
697 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
698 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
699 };
700
702 {
703 public:
705 {
706 public:
707 uint32_t hash = 0;
708 uint16_t flags = 0;
709 uint16_t other = 0;
710 uint32_t name_offset = 0;
711 std::string name;
712 uint32_t offset_next_entry = 0;
713 };
714
715 uint16_t version = 0;
716 uint32_t file_name_offset = 0;
717 std::string file_name;
718 uint32_t offset_auxiliary_array = 0;
719 std::vector<Auxiliary> auxiliary_array;
720 uint32_t offset_next_entry = 0;
721 };
722
724 {
725 public:
726 std::vector<VersionRequirement> requirements;
727
728 offset_t ImageSize() const override;
730 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
731 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
732 };
733
734 /* IBM OS/2 extension */
736 {
737 public:
738 enum system_type : uint32_t
739 {
740 EOS_NONE = 0,
741 EOS_PN = 1,
742 EOS_SVR4 = 2,
743 EOS_AIX = 3,
744 EOS_OS2 = 4,
745 };
746 system_type os_type = EOS_NONE;
747 uint32_t os_size = 0;
748 bool IsOS2Specific() const;
750 {
751 /* OS/2 specific */
752 enum os2_session : uint8_t
753 {
754 OS2_SES_NONE = 0,
755 OS2_SES_FS = 1,
756 OS2_SES_PM = 2,
757 OS2_SES_VIO = 3,
758 };
759 os2_session sessiontype = OS2_SES_NONE;
760 uint8_t sessionflags;
761 } os2;
762 /* unspecified */
763 std::vector<uint8_t> os_specific;
764
765 offset_t ImageSize() const override;
767 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
768 void AddDumperFields(std::unique_ptr<Dumper::Region>& region, Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
769 };
770
771 /* IBM OS/2 extension */
773 {
774 public:
775 uint32_t ordinal = 0, name_offset = 0;
776 std::string name;
777 enum import_type
778 {
779 IMP_IGNORED = 0,
780 IMP_STR_IDX = 1,
781 IMP_DT_IDX = 2,
782 };
783 import_type type = IMP_IGNORED;
784 uint32_t dll = 0;
785 std::string dll_name;
786 };
787
788 /* IBM OS/2 extension */
790 {
791 public:
792 offset_t entsize;
793 std::vector<IBMImportEntry> imports;
794
795 IBMImportTable(offset_t entsize)
796 : entsize(entsize)
797 {
798 }
799
800 offset_t ImageSize() const override;
802 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
803 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
804 };
805
806 /* IBM OS/2 extension */
808 {
809 public:
810 uint32_t ordinal = 0, symbol_index = 0, name_offset = 0;
811 std::string name;
812 uint32_t sh_link = 0, sh_info = 0;
813 };
814
815 /* IBM OS/2 extension */
817 {
818 public:
819 offset_t entsize;
820 std::vector<IBMExportEntry> exports;
821
822 IBMExportTable(offset_t entsize)
823 : entsize(entsize)
824 {
825 }
826
827 offset_t ImageSize() const override;
829 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
830 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
831 };
832
833 /* IBM OS/2 extension */
835 {
836 public:
837 uint32_t type = 0;
838 uint32_t ordinal = 0;
839 uint32_t name_offset = 0;
840 std::string name;
841 uint32_t data_offset = 0;
842 uint32_t data_size = 0;
843 std::shared_ptr<Linker::Image> data;
844 };
845
846 /* IBM OS/2 extension */
848 {
849 public:
850#if 0
851 uint32_t offset = 0;
852 uint32_t size = 0;
853#endif
854
855 offset_t offset = 0;
856
857 uint16_t version = 0;
858 uint16_t flags = 0;
859 uint32_t name_offset = 0;
860 std::string name;
861 uint32_t item_array_offset = 0;
862 uint32_t item_array_entry_size = 0;
863 uint32_t header_size = 0;
864 uint32_t string_table_offset = 0;
865 uint32_t locale_offset = 0;
866
867 char16_t country[2] = { };
868 char16_t language[2] = { };
869
870 std::vector<IBMResource> resources;
871
872 offset_t ImageSize() const override;
874 offset_t WriteFile(Linker::Writer& wr, offset_t count, offset_t offset) const override;
875 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
876 void AddDumperFields(std::unique_ptr<Dumper::Region>& region, Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const override;
877 };
878
879#if 0
880 /* IBM OS/2 extension */
881 class IBMResourceFile
882 {
883 public:
884 uint8_t file_class = 0;
885 EndianType endiantype = ::LittleEndian;
886
887 uint8_t data_encoding = 0;
888 size_t wordbytes = 4;
889
890 uint8_t version = 0;
891
892 uint32_t header_size = 0;
893 uint32_t resource_collection_offset = 0;
894 std::vector<IBMResourceCollection> resource_collections;
895 };
896#endif
897
899 {
900 public:
901 uint32_t name_offset = 0;
902 std::string name;
903 enum section_type
904 {
905 SHT_NULL = 0,
906 SHT_PROGBITS = 1,
907 SHT_SYMTAB = 2,
908 SHT_STRTAB = 3,
909 SHT_RELA = 4,
910 SHT_HASH = 5,
911 SHT_DYNAMIC = 6,
912 SHT_NOTE = 7,
913 SHT_NOBITS = 8,
914 SHT_REL = 9,
915 SHT_SHLIB = 10, /* reserved */
916 SHT_DYNSYM = 11,
917 SHT_INIT_ARRAY = 14,
918 SHT_FINI_ARRAY = 15,
919 SHT_PREINIT_ARRAY = 16,
920 SHT_GROUP = 17,
921 SHT_SYMTAB_SHNDX = 18,
922 /* IBM OS/2 specific */
923 SHT_OS = 0x60000001,
924 SHT_IMPORTS = 0x60000002,
925 SHT_EXPORTS = 0x60000003,
926 SHT_RES = 0x60000004,
927
928 SHT_OLD_OS = 12,
929 SHT_OLD_IMPORTS = 13,
930 SHT_OLD_EXPORTS = 14,
931 SHT_OLD_RES = 15,
932
933 /* GNU extensions */
934 SHT_GNU_INCREMENTAL_INPUTS = 0x6FFF4700,
935 SHT_GNU_ATTRIBUTES = 0x6FFFFFF5,
936 SHT_GNU_HASH = 0x6FFFFFF6,
937 SHT_GNU_LIBLIST = 0x6FFFFFF7,
938 SHT_SUNW_verdef = 0x6FFFFFFD,
939 SHT_SUNW_verneed = 0x6FFFFFFE,
940 SHT_SUNW_versym = 0x6FFFFFFF,
941 };
942 section_type type = SHT_NULL;
943 uint32_t link = 0, info = 0;
944 offset_t flags = 0;
945 offset_t address = 0, file_offset = 0, size = 0, align = 0, entsize = 0;
946
947 std::shared_ptr<Linker::Image> contents;
948
949 std::shared_ptr<Linker::Section> GetSection();
950 const std::shared_ptr<Linker::Section> GetSection() const;
951
952 std::shared_ptr<SymbolTable> GetSymbolTable();
953 const std::shared_ptr<SymbolTable> GetSymbolTable() const;
954
955#if 0
956 std::shared_ptr<StringTable> GetStringTable();
957#endif
958 std::shared_ptr<Array> GetArray();
959
960 std::shared_ptr<Relocations> GetRelocations();
961 const std::shared_ptr<Relocations> GetRelocations() const;
962
963 std::shared_ptr<DynamicSection> GetDynamicSection();
964
965#if 0
966 std::shared_ptr<NotesSection> GetNotesSection();
967
968 std::shared_ptr<IBMSystemInfo> GetIBMSystemInfo();
969#endif
970
971 std::shared_ptr<IBMImportTable> GetIBMImportTable();
972 std::shared_ptr<IBMExportTable> GetIBMExportTable();
973
974 bool GetFileSize() const;
975
976 void Dump(Dumper::Dumper& dump, const ELFFormat& fmt, unsigned index) const;
977
978 static std::shared_ptr<Linker::Section> ReadProgBits(Linker::Reader& rd, offset_t file_offset, const std::string& name, offset_t size);
979 static std::shared_ptr<Linker::Section> ReadNoBits(const std::string& name, offset_t size);
980 static std::shared_ptr<SymbolTable> ReadSymbolTable(Linker::Reader& rd, offset_t file_offset, offset_t section_size, offset_t entsize, uint32_t section_link, size_t wordbytes);
981 static std::shared_ptr<Relocations> ReadRelocations(Linker::Reader& rd, Section::section_type type, offset_t file_offset, offset_t section_size, offset_t entsize, uint32_t section_link, uint32_t section_info, size_t wordbytes);
982 static std::shared_ptr<StringTable> ReadStringTable(Linker::Reader& rd, offset_t file_offset, offset_t section_size);
983 static std::shared_ptr<Array> ReadArray(Linker::Reader& rd, offset_t file_offset, offset_t section_size, offset_t entsize);
984 static std::shared_ptr<SectionGroup> ReadSectionGroup(Linker::Reader& rd, offset_t file_offset, offset_t section_size, offset_t entsize);
985 static std::shared_ptr<IndexArray> ReadIndexArray(Linker::Reader& rd, offset_t file_offset, offset_t section_size, offset_t entsize);
986 static std::shared_ptr<HashTable> ReadHashTable(Linker::Reader& rd, offset_t file_offset);
987 static std::shared_ptr<DynamicSection> ReadDynamic(Linker::Reader& rd, offset_t file_offset, offset_t section_size, offset_t entsize, size_t wordbytes);
988 static std::shared_ptr<NotesSection> ReadNote(Linker::Reader& rd, offset_t file_offset, offset_t section_size);
989 static std::shared_ptr<VersionRequirements> ReadVersionRequirements(Linker::Reader& rd, offset_t file_offset, offset_t section_link, offset_t section_info);
990 static std::shared_ptr<IBMSystemInfo> ReadIBMSystemInfo(Linker::Reader& rd, offset_t file_offset);
991 static std::shared_ptr<IBMImportTable> ReadIBMImportTable(Linker::Reader& rd, offset_t file_offset, offset_t section_size, offset_t entsize);
992 static std::shared_ptr<IBMExportTable> ReadIBMExportTable(Linker::Reader& rd, offset_t file_offset, offset_t section_size, offset_t entsize);
993 static std::shared_ptr<IBMResourceCollection> ReadIBMResourceCollection(Linker::Reader& rd, offset_t file_offset);
994 };
995 std::vector<Section> sections;
996
998 {
999 public:
1000 enum segment_type
1001 {
1002 PT_NULL = 0,
1003 PT_LOAD = 1,
1004 PT_DYNAMIC = 2,
1005 PT_INTERP = 3,
1006 PT_NOTE = 4,
1007 PT_SHLIB = 5,
1008 PT_PHDR = 6,
1009 PT_TLS = 7,
1010 /* IBM OS/2 specific */
1011 PT_OS = 0x60000001,
1012 PT_RES = 0x60000002,
1013
1014 PT_OLD_OS = 7,
1015 PT_OLD_RES = 9,
1016 /* SUN, GNU, OpenBSD extensions */
1017 PT_SUNW_EH_FRAME = 0x6474E550,
1018 PT_GNU_STACK = 0x6474E551,
1019 PT_GNU_RELRO = 0x6474E552,
1020 PT_GNU_PROPERTY = 0x6474E553,
1021 PT_GNU_SFRAME = 0x6474E554,
1022 PT_GNU_MBIND_LO = 0x6474E555,
1023 PT_GNU_MBIND_HI = 0x6474F554,
1024 PT_OPENBSD_MUTABLE = 0x65A3DBE5,
1025 PT_OPENBSD_RANDOMIZE = 0x65A3DBE6,
1026 PT_OPENBSD_WXNEEDED = 0x65A3DBE7,
1027 PT_OPENBSD_NOBTCFI = 0x65A3DBE8,
1028 PT_OPENBSD_BOOTDATA = 0x65A41BE6,
1029 };
1030 segment_type type;
1031 uint32_t flags = 0;
1032 offset_t offset = 0, vaddr = 0, paddr = 0, filesz = 0, memsz = 0, align = 0;
1033
1034 struct Part
1035 {
1036 public:
1038 {
1043 };
1044 part_type type;
1045
1046 uint16_t index;
1047 offset_t offset, size;
1048 Part(part_type type, uint16_t index, offset_t offset, offset_t size)
1049 : type(type), index(index), offset(offset), size(size)
1050 {
1051 }
1052
1053 offset_t GetOffset(const ELFFormat& fmt) const;
1054 offset_t GetActualSize(const ELFFormat& fmt) const;
1055 };
1056
1057 std::vector<Part> parts;
1058 };
1059 std::vector<Segment> segments;
1060
1061 class Block
1062 {
1063 public:
1064 offset_t offset = 0;
1065 offset_t size = 0;
1066 std::shared_ptr<Linker::Image> image;
1067 Block(offset_t offset = 0, offset_t size = 0)
1068 : offset(offset), size(size)
1069 {
1070 }
1071 };
1073 std::vector<Block> blocks;
1074
1075 /* AT&T Hobbit BeOS specific */
1076
1082 {
1083 char type[4];
1084 offset_t unknown1, offset, size, unknown2;
1085 std::shared_ptr<Linker::Buffer> image;
1086 };
1087 offset_t hobbit_beos_resource_offset = 0;
1088 std::vector<HobbitBeOSResource> hobbit_beos_resources;
1089
1090 ELFFormat()
1091 {
1092 }
1093
1094 void ReadFile(Linker::Reader& rd) override;
1095
1097 offset_t WriteFile(Linker::Writer& wr) const override;
1098
1099 void Dump(Dumper::Dumper& dump) const override;
1100
1104 bool IsOldOS2Format() const;
1105
1106 /* * * Reader members * * */
1107
1108 bool option_16bit = true;
1109 bool option_linear = false;
1113 bool option_pmode = false;
1114
1115 void SetupOptions(std::shared_ptr<Linker::OutputFormat> format) override;
1116
1118 void GenerateModule(Linker::Module& module) const override;
1119 void CalculateValues() override;
1120 };
1121
1127 class FatELFFormat : public virtual Linker::OutputFormat
1128 {
1129 public:
1130 struct Record
1131 {
1132 ELFFormat::cpu_type cpu = ELFFormat::EM_NONE;
1133 uint8_t osabi = 0;
1134 uint8_t abi_version = 0;
1135 uint8_t file_class = 0;
1136 uint8_t data_encoding = 0;
1137 uint64_t offset = 0;
1138 uint64_t size = 0;
1139 std::shared_ptr<Linker::Image> image;
1140
1141 static Record Read(Linker::Reader& rd);
1142 void Write(Linker::Writer& wr) const;
1143 };
1144 uint16_t version = ELFFormat::EV_CURRENT;
1145 std::vector<Record> records;
1146
1147 offset_t ImageSize() const override;
1148 void ReadFile(Linker::Reader& rd) override;
1149
1151 offset_t WriteFile(Linker::Writer& wr) const override;
1152
1153 void Dump(Dumper::Dumper& dump) const override;
1154 void CalculateValues() override;
1155 };
1156}
1157
1158#endif /* ELF_H */
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
Definition elf.h:544
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:155
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:150
Definition elf.h:1062
Definition elf.h:638
Definition elf.h:656
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:511
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:506
Definition elf.h:623
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:662
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:657
Definition elf.h:808
Definition elf.h:817
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:895
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:900
Definition elf.h:773
Definition elf.h:790
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:846
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:851
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:942
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:936
Definition elf.h:835
Definition elf.h:736
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:792
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:787
Definition elf.h:579
Definition elf.h:675
Definition elf.h:683
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:712
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:717
Definition elf.h:590
Definition elf.h:604
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:453
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:448
Definition elf.h:562
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:180
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:185
Definition elf.h:899
Definition elf.h:998
Definition elf.h:526
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:122
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:117
Definition elf.h:507
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:22
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:27
Definition elf.h:492
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:762
offset_t WriteFile(Linker::Writer &wr, offset_t count, offset_t offset) const override
Writes data of non-zero filled sections.
Definition elf.cc:768
ELF object and executable format.
Definition elf.h:22
void SetupOptions(std::shared_ptr< Linker::OutputFormat > format) override
Initializes the reader for linking purposes.
Definition elf.cc:2662
static constexpr offset_t R_386_SUB32
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup....
Definition elf.h:103
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition elf.cc:1582
static constexpr offset_t R_386_SUB16
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup....
Definition elf.h:101
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition elf.cc:2081
static constexpr offset_t R_386_OZRELSEG16
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup....
Definition elf.h:109
static constexpr offset_t R_386_SEGRELATIVE
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup....
Definition elf.h:105
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition elf.cc:2906
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition elf.cc:2192
bool IsOldOS2Format() const
Attempts to heuristically determine if it is in a beta OS/2 format.
Definition elf.cc:2626
bool option_pmode
Set when the generated format runs in protected mode.
Definition elf.h:1113
std::vector< Block > blocks
Collection of blocks of data that do not belong to any section.
Definition elf.h:1073
void GenerateModule(Linker::Module &module) const override
Loads the information into a module object, a convenience method when there is a single module genera...
Definition elf.cc:2669
static constexpr offset_t R_386_OZSEG16
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup....
Definition elf.h:107
static constexpr offset_t R_386_SEG16
Extension, see here: https://gitlab.com/tkchia/build-ia16/-/blob/master/elf16-writeup....
Definition elf.h:99
FatELF developed by icculus (Ryan C. Gordon) to contain multiple ELF binaries for different architect...
Definition elf.h:1128
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition elf.cc:3097
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition elf.cc:3072
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition elf.cc:3046
offset_t ImageSize() const override
Retrieves size of stored data.
Definition elf.cc:3033
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition elf.cc:3118
offset_t WriteFile(Writer &wr) const override=0
Stores data in memory to file.
Represents an abstract data image whose data can be written to a file.
Definition image.h:17
virtual offset_t WriteFile(Writer &wr, offset_t count, offset_t offset=0) const =0
Writes data of non-zero filled sections.
A class that provides a general interface to loading a module.
Definition format.h:193
virtual void GenerateModule(ModuleCollector &linker, std::string file_name, bool is_library=false) const
Loads the information into a module object.
Definition format.cc:215
Represents a single offset within a section, or an absolute location in memory if the section is null...
Definition location.h:17
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
A class that provides a general interface to setting up generation for a format.
Definition format.h:64
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
A helper class to collect sections into segments.
Definition segment_manager.h:32
Represents a symbol definition.
Definition symbol_definition.h:16
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15
Resources for the prototype BeOS Development Release for the AT&T Hobbit.
Definition elf.h:1082
Definition elf.h:1035
part_type
Definition elf.h:1038
Definition elf.h:1131