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