Recommit "rL366894: [yaml2obj] - Allow custom fields for the SHT_UNDEF sections."
[llvm-complete.git] / test / tools / llvm-readobj / Inputs / relocs.py
blob8e621cef5cd98ba37cb51a096f53fe915d3d22a0
1 #!/usr/bin/env python
3 from __future__ import print_function
5 # Generates ELF, COFF and MachO object files for different architectures
6 # containing all relocations:
8 # ELF: i386, x86_64, ppc64, aarch64, arm, mips, mips64el
9 # COFF: i386, x86_64
10 # MachO: i386, x86_64, arm
11 # (see end of file for triples)
13 # To simplify generation, object files are generated with just the proper
14 # number of relocations through repeated instructions. Afterwards, the
15 # relocations in the object file are patched to their proper value.
17 import operator
18 import shutil
19 import struct
20 import subprocess
21 import sys
23 class EnumType(type):
24 def __init__(self, name, bases = (), attributes = {}):
25 super(EnumType, self).__init__(name, bases, attributes)
27 type.__setattr__(self, '_map', {})
28 type.__setattr__(self, '_nameMap', {})
30 for symbol in attributes:
31 if symbol.startswith('__') or symbol.endswith('__'):
32 continue
34 value = attributes[symbol]
36 # MyEnum.symbol == value
37 type.__setattr__(self, symbol, value)
38 self._nameMap[symbol] = value
40 # The first symbol with the given value is authoritative.
41 if not (value in self._map):
42 # MyEnum[value] == symbol
43 self._map[value] = symbol
45 # Not supported (Enums are immutable).
46 def __setattr__(self, name, value):
47 raise NotSupportedException(self.__setattr__)
49 # Not supported (Enums are immutable).
50 def __delattr__(self, name):
51 raise NotSupportedException(self.__delattr__)
53 # Gets the enum symbol for the specified value.
54 def __getitem__(self, value):
55 symbol = self._map.get(value)
56 if symbol is None:
57 raise KeyError(value)
58 return symbol
60 # Gets the enum symbol for the specified value or none.
61 def lookup(self, value):
62 symbol = self._map.get(value)
63 return symbol
65 # Not supported (Enums are immutable).
66 def __setitem__(self, value, symbol):
67 raise NotSupportedException(self.__setitem__)
69 # Not supported (Enums are immutable).
70 def __delitem__(self, value):
71 raise NotSupportedException(self.__delitem__)
73 def entries(self):
74 # sort by (value, name)
75 def makeKey(item):
76 return (item[1], item[0])
77 e = []
78 for pair in sorted(self._nameMap.items(), key=makeKey):
79 e.append(pair)
80 return e
82 def __iter__(self):
83 for e in self.entries():
84 yield e
86 Enum = EnumType('Enum', (), {})
88 class BinaryReader:
89 def __init__(self, path):
90 self.file = open(path, "r+b", 0)
91 self.isLSB = None
92 self.is64Bit = None
93 self.isN64 = False
95 def tell(self):
96 return self.file.tell()
98 def seek(self, pos):
99 self.file.seek(pos)
101 def read(self, N):
102 data = self.file.read(N)
103 if len(data) != N:
104 raise ValueError("Out of data!")
105 return data
107 def int8(self):
108 return ord(self.read(1))
110 def uint8(self):
111 return ord(self.read(1))
113 def int16(self):
114 return struct.unpack('><'[self.isLSB] + 'h', self.read(2))[0]
116 def uint16(self):
117 return struct.unpack('><'[self.isLSB] + 'H', self.read(2))[0]
119 def int32(self):
120 return struct.unpack('><'[self.isLSB] + 'i', self.read(4))[0]
122 def uint32(self):
123 return struct.unpack('><'[self.isLSB] + 'I', self.read(4))[0]
125 def int64(self):
126 return struct.unpack('><'[self.isLSB] + 'q', self.read(8))[0]
128 def uint64(self):
129 return struct.unpack('><'[self.isLSB] + 'Q', self.read(8))[0]
131 def writeUInt8(self, value):
132 self.file.write(struct.pack('><'[self.isLSB] + 'B', value))
134 def writeUInt16(self, value):
135 self.file.write(struct.pack('><'[self.isLSB] + 'H', value))
137 def writeUInt32(self, value):
138 self.file.write(struct.pack('><'[self.isLSB] + 'I', value))
140 def writeUInt64(self, value):
141 self.file.write(struct.pack('><'[self.isLSB] + 'Q', value))
143 def word(self):
144 if self.is64Bit:
145 return self.uint64()
146 else:
147 return self.uint32()
149 def writeWord(self, value):
150 if self.is64Bit:
151 self.writeUInt64(value)
152 else:
153 self.writeUInt32(value)
155 class StringTable:
156 def __init__(self, strings):
157 self.string_table = strings
159 def __getitem__(self, index):
160 end = self.string_table.index('\x00', index)
161 return self.string_table[index:end]
163 class ElfSection:
164 def __init__(self, f):
165 self.sh_name = f.uint32()
166 self.sh_type = f.uint32()
167 self.sh_flags = f.word()
168 self.sh_addr = f.word()
169 self.sh_offset = f.word()
170 self.sh_size = f.word()
171 self.sh_link = f.uint32()
172 self.sh_info = f.uint32()
173 self.sh_addralign = f.word()
174 self.sh_entsize = f.word()
176 def patch(self, f, relocs):
177 if self.sh_type == 4 or self.sh_type == 9: # SHT_RELA / SHT_REL
178 self.patchRelocs(f, relocs)
180 def patchRelocs(self, f, relocs):
181 entries = self.sh_size // self.sh_entsize
183 for index in range(entries):
184 f.seek(self.sh_offset + index * self.sh_entsize)
185 r_offset = f.word()
187 if index < len(relocs):
188 ri = index
189 else:
190 ri = 0
192 if f.isN64:
193 r_sym = f.uint32()
194 r_ssym = f.uint8()
195 f.seek(f.tell())
196 f.writeUInt8(relocs[ri][1])
197 f.writeUInt8(relocs[ri][1])
198 f.writeUInt8(relocs[ri][1])
199 else:
200 pos = f.tell()
201 r_info = f.word()
203 r_type = relocs[ri][1]
204 if f.is64Bit:
205 r_info = (r_info & 0xFFFFFFFF00000000) | (r_type & 0xFFFFFFFF)
206 else:
207 r_info = (r_info & 0xFF00) | (r_type & 0xFF)
209 print(" %s" % relocs[ri][0])
210 f.seek(pos)
211 f.writeWord(r_info)
214 class CoffSection:
215 def __init__(self, f):
216 self.raw_name = f.read(8)
217 self.virtual_size = f.uint32()
218 self.virtual_address = f.uint32()
219 self.raw_data_size = f.uint32()
220 self.pointer_to_raw_data = f.uint32()
221 self.pointer_to_relocations = f.uint32()
222 self.pointer_to_line_numbers = f.uint32()
223 self.relocation_count = f.uint16()
224 self.line_number_count = f.uint16()
225 self.characteristics = f.uint32()
228 def compileAsm(filename, triple, src):
229 cmd = ["llvm-mc", "-triple=" + triple, "-filetype=obj", "-o", filename]
230 print(" Running: " + " ".join(cmd))
231 p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
232 p.communicate(input=src)
233 p.wait()
235 def compileIR(filename, triple, src):
236 cmd = ["llc", "-mtriple=" + triple, "-filetype=obj", "-o", filename]
237 print(" Running: " + " ".join(cmd))
238 p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
239 p.communicate(input=src)
240 p.wait()
243 def craftElf(filename, triple, relocs, dummyReloc):
244 print("Crafting " + filename + " for " + triple)
245 if type(dummyReloc) is tuple:
246 preSrc, dummyReloc, relocsPerDummy = dummyReloc
247 src = preSrc + "\n"
248 for i in range((len(relocs) + relocsPerDummy - 1) / relocsPerDummy):
249 src += dummyReloc.format(i) + "\n"
250 compileIR(filename, triple, src)
251 else:
252 src = (dummyReloc + "\n") * len(relocs)
253 compileAsm(filename, triple, src)
255 print(" Patching relocations...")
256 patchElf(filename, relocs)
258 def patchElf(path, relocs):
259 f = BinaryReader(path)
261 magic = f.read(4)
262 assert magic == '\x7FELF'
264 fileclass = f.uint8()
265 if fileclass == 1:
266 f.is64Bit = False
267 elif fileclass == 2:
268 f.is64Bit = True
269 else:
270 raise ValueError("Unknown file class %x" % fileclass)
272 byteordering = f.uint8()
273 if byteordering == 1:
274 f.isLSB = True
275 elif byteordering == 2:
276 f.isLSB = False
277 else:
278 raise ValueError("Unknown byte ordering %x" % byteordering)
280 f.seek(18)
281 e_machine = f.uint16()
282 if e_machine == 0x0008 and f.is64Bit: # EM_MIPS && 64 bit
283 f.isN64 = True
285 e_version = f.uint32()
286 e_entry = f.word()
287 e_phoff = f.word()
288 e_shoff = f.word()
289 e_flags = f.uint32()
290 e_ehsize = f.uint16()
291 e_phentsize = f.uint16()
292 e_phnum = f.uint16()
293 e_shentsize = f.uint16()
294 e_shnum = f.uint16()
295 e_shstrndx = f.uint16()
297 sections = []
298 for index in range(e_shnum):
299 f.seek(e_shoff + index * e_shentsize)
300 s = ElfSection(f)
301 sections.append(s)
303 f.seek(sections[e_shstrndx].sh_offset)
304 shstrtab = StringTable(f.read(sections[e_shstrndx].sh_size))
306 strtab = None
307 for section in sections:
308 if shstrtab[section.sh_name] == ".strtab":
309 f.seek(section.sh_offset)
310 strtab = StringTable(f.read(section.sh_size))
311 break
313 for index in range(e_shnum):
314 sections[index].patch(f, relocs)
317 def craftCoff(filename, triple, relocs, dummyReloc):
318 print("Crafting " + filename + " for " + triple)
319 src = (dummyReloc + "\n") * len(relocs)
320 compileAsm(filename, triple, src)
322 print(" Patching relocations...")
323 patchCoff(filename, relocs)
325 def patchCoff(path, relocs):
326 f = BinaryReader(path)
327 f.isLSB = True
329 machine_type = f.uint16()
330 section_count = f.uint16()
332 # Zero out timestamp to prevent churn when regenerating COFF files.
333 f.writeUInt32(0)
335 f.seek(20)
336 sections = [CoffSection(f) for idx in range(section_count)]
338 section = sections[0]
339 f.seek(section.pointer_to_relocations)
340 for i in range(section.relocation_count):
341 virtual_addr = f.uint32()
342 symtab_idx = f.uint32()
343 print(" %s" % relocs[i][0])
344 f.writeUInt16(relocs[i][1])
347 def craftMacho(filename, triple, relocs, dummyReloc):
348 print("Crafting " + filename + " for " + triple)
350 if type(dummyReloc) is tuple:
351 srcType, preSrc, dummyReloc, relocsPerDummy = dummyReloc
352 src = preSrc + "\n"
353 for i in range((len(relocs) + relocsPerDummy - 1) / relocsPerDummy):
354 src += dummyReloc.format(i) + "\n"
355 if srcType == "asm":
356 compileAsm(filename, triple, src)
357 elif srcType == "ir":
358 compileIR(filename, triple, src)
359 else:
360 src = (dummyReloc + "\n") * len(relocs)
361 compileAsm(filename, triple, src)
363 print(" Patching relocations...")
364 patchMacho(filename, relocs)
366 def patchMacho(filename, relocs):
367 f = BinaryReader(filename)
369 magic = f.read(4)
370 if magic == '\xFE\xED\xFA\xCE':
371 f.isLSB, f.is64Bit = False, False
372 elif magic == '\xCE\xFA\xED\xFE':
373 f.isLSB, f.is64Bit = True, False
374 elif magic == '\xFE\xED\xFA\xCF':
375 f.isLSB, f.is64Bit = False, True
376 elif magic == '\xCF\xFA\xED\xFE':
377 f.isLSB, f.is64Bit = True, True
378 else:
379 raise ValueError("Not a Mach-O object file: %r (bad magic)" % path)
381 cputype = f.uint32()
382 cpusubtype = f.uint32()
383 filetype = f.uint32()
384 numLoadCommands = f.uint32()
385 loadCommandsSize = f.uint32()
386 flag = f.uint32()
387 if f.is64Bit:
388 reserved = f.uint32()
390 start = f.tell()
392 for i in range(numLoadCommands):
393 patchMachoLoadCommand(f, relocs)
395 if f.tell() - start != loadCommandsSize:
396 raise ValueError("%s: warning: invalid load commands size: %r" % (
397 sys.argv[0], loadCommandsSize))
399 def patchMachoLoadCommand(f, relocs):
400 start = f.tell()
401 cmd = f.uint32()
402 cmdSize = f.uint32()
404 if cmd == 1:
405 patchMachoSegmentLoadCommand(f, relocs)
406 elif cmd == 25:
407 patchMachoSegmentLoadCommand(f, relocs)
408 else:
409 f.read(cmdSize - 8)
411 if f.tell() - start != cmdSize:
412 raise ValueError("%s: warning: invalid load command size: %r" % (
413 sys.argv[0], cmdSize))
415 def patchMachoSegmentLoadCommand(f, relocs):
416 segment_name = f.read(16)
417 vm_addr = f.word()
418 vm_size = f.word()
419 file_offset = f.word()
420 file_size = f.word()
421 maxprot = f.uint32()
422 initprot = f.uint32()
423 numSections = f.uint32()
424 flags = f.uint32()
425 for i in range(numSections):
426 patchMachoSection(f, relocs)
428 def patchMachoSection(f, relocs):
429 section_name = f.read(16)
430 segment_name = f.read(16)
431 address = f.word()
432 size = f.word()
433 offset = f.uint32()
434 alignment = f.uint32()
435 relocOffset = f.uint32()
436 numReloc = f.uint32()
437 flags = f.uint32()
438 reserved1 = f.uint32()
439 reserved2 = f.uint32()
440 if f.is64Bit:
441 reserved3 = f.uint32()
443 prev_pos = f.tell()
445 f.seek(relocOffset)
446 for i in range(numReloc):
447 ri = i < len(relocs) and i or 0
448 print(" %s" % relocs[ri][0])
449 word1 = f.uint32()
450 pos = f.tell()
451 value = f.uint32()
452 f.seek(pos)
453 value = (value & 0x0FFFFFFF) | ((relocs[ri][1] & 0xF) << 28)
454 f.writeUInt32(value)
455 f.seek(prev_pos)
458 class Relocs_Elf_X86_64(Enum):
459 R_X86_64_NONE = 0
460 R_X86_64_64 = 1
461 R_X86_64_PC32 = 2
462 R_X86_64_GOT32 = 3
463 R_X86_64_PLT32 = 4
464 R_X86_64_COPY = 5
465 R_X86_64_GLOB_DAT = 6
466 R_X86_64_JUMP_SLOT = 7
467 R_X86_64_RELATIVE = 8
468 R_X86_64_GOTPCREL = 9
469 R_X86_64_32 = 10
470 R_X86_64_32S = 11
471 R_X86_64_16 = 12
472 R_X86_64_PC16 = 13
473 R_X86_64_8 = 14
474 R_X86_64_PC8 = 15
475 R_X86_64_DTPMOD64 = 16
476 R_X86_64_DTPOFF64 = 17
477 R_X86_64_TPOFF64 = 18
478 R_X86_64_TLSGD = 19
479 R_X86_64_TLSLD = 20
480 R_X86_64_DTPOFF32 = 21
481 R_X86_64_GOTTPOFF = 22
482 R_X86_64_TPOFF32 = 23
483 R_X86_64_PC64 = 24
484 R_X86_64_GOTOFF64 = 25
485 R_X86_64_GOTPC32 = 26
486 R_X86_64_GOT64 = 27
487 R_X86_64_GOTPCREL64 = 28
488 R_X86_64_GOTPC64 = 29
489 R_X86_64_GOTPLT64 = 30
490 R_X86_64_PLTOFF64 = 31
491 R_X86_64_SIZE32 = 32
492 R_X86_64_SIZE64 = 33
493 R_X86_64_GOTPC32_TLSDESC = 34
494 R_X86_64_TLSDESC_CALL = 35
495 R_X86_64_TLSDESC = 36
496 R_X86_64_IRELATIVE = 37
498 class Relocs_Elf_i386(Enum):
499 R_386_NONE = 0
500 R_386_32 = 1
501 R_386_PC32 = 2
502 R_386_GOT32 = 3
503 R_386_PLT32 = 4
504 R_386_COPY = 5
505 R_386_GLOB_DAT = 6
506 R_386_JUMP_SLOT = 7
507 R_386_RELATIVE = 8
508 R_386_GOTOFF = 9
509 R_386_GOTPC = 10
510 R_386_32PLT = 11
511 R_386_TLS_TPOFF = 14
512 R_386_TLS_IE = 15
513 R_386_TLS_GOTIE = 16
514 R_386_TLS_LE = 17
515 R_386_TLS_GD = 18
516 R_386_TLS_LDM = 19
517 R_386_16 = 20
518 R_386_PC16 = 21
519 R_386_8 = 22
520 R_386_PC8 = 23
521 R_386_TLS_GD_32 = 24
522 R_386_TLS_GD_PUSH = 25
523 R_386_TLS_GD_CALL = 26
524 R_386_TLS_GD_POP = 27
525 R_386_TLS_LDM_32 = 28
526 R_386_TLS_LDM_PUSH = 29
527 R_386_TLS_LDM_CALL = 30
528 R_386_TLS_LDM_POP = 31
529 R_386_TLS_LDO_32 = 32
530 R_386_TLS_IE_32 = 33
531 R_386_TLS_LE_32 = 34
532 R_386_TLS_DTPMOD32 = 35
533 R_386_TLS_DTPOFF32 = 36
534 R_386_TLS_TPOFF32 = 37
535 R_386_TLS_GOTDESC = 39
536 R_386_TLS_DESC_CALL = 40
537 R_386_TLS_DESC = 41
538 R_386_IRELATIVE = 42
539 R_386_NUM = 43
541 class Relocs_Elf_PPC32(Enum):
542 R_PPC_NONE = 0
543 R_PPC_ADDR32 = 1
544 R_PPC_ADDR24 = 2
545 R_PPC_ADDR16 = 3
546 R_PPC_ADDR16_LO = 4
547 R_PPC_ADDR16_HI = 5
548 R_PPC_ADDR16_HA = 6
549 R_PPC_ADDR14 = 7
550 R_PPC_ADDR14_BRTAKEN = 8
551 R_PPC_ADDR14_BRNTAKEN = 9
552 R_PPC_REL24 = 10
553 R_PPC_REL14 = 11
554 R_PPC_REL14_BRTAKEN = 12
555 R_PPC_REL14_BRNTAKEN = 13
556 R_PPC_REL32 = 26
557 R_PPC_TPREL16_LO = 70
558 R_PPC_TPREL16_HA = 72
560 class Relocs_Elf_PPC64(Enum):
561 R_PPC64_NONE = 0
562 R_PPC64_ADDR32 = 1
563 R_PPC64_ADDR16_LO = 4
564 R_PPC64_ADDR16_HI = 5
565 R_PPC64_ADDR14 = 7
566 R_PPC64_REL24 = 10
567 R_PPC64_REL32 = 26
568 R_PPC64_ADDR64 = 38
569 R_PPC64_ADDR16_HIGHER = 39
570 R_PPC64_ADDR16_HIGHEST = 41
571 R_PPC64_REL64 = 44
572 R_PPC64_TOC16 = 47
573 R_PPC64_TOC16_LO = 48
574 R_PPC64_TOC16_HA = 50
575 R_PPC64_TOC = 51
576 R_PPC64_ADDR16_DS = 56
577 R_PPC64_ADDR16_LO_DS = 57
578 R_PPC64_TOC16_DS = 63
579 R_PPC64_TOC16_LO_DS = 64
580 R_PPC64_TLS = 67
581 R_PPC64_TPREL16_LO = 70
582 R_PPC64_TPREL16_HA = 72
583 R_PPC64_DTPREL16_LO = 75
584 R_PPC64_DTPREL16_HA = 77
585 R_PPC64_GOT_TLSGD16_LO = 80
586 R_PPC64_GOT_TLSGD16_HA = 82
587 R_PPC64_GOT_TLSLD16_LO = 84
588 R_PPC64_GOT_TLSLD16_HA = 86
589 R_PPC64_GOT_TPREL16_LO_DS = 88
590 R_PPC64_GOT_TPREL16_HA = 90
591 R_PPC64_TLSGD = 107
592 R_PPC64_TLSLD = 108
594 class Relocs_Elf_AArch64(Enum):
595 R_AARCH64_NONE = 0
596 R_AARCH64_ABS64 = 0x101
597 R_AARCH64_ABS32 = 0x102
598 R_AARCH64_ABS16 = 0x103
599 R_AARCH64_PREL64 = 0x104
600 R_AARCH64_PREL32 = 0x105
601 R_AARCH64_PREL16 = 0x106
602 R_AARCH64_MOVW_UABS_G0 = 0x107
603 R_AARCH64_MOVW_UABS_G0_NC = 0x108
604 R_AARCH64_MOVW_UABS_G1 = 0x109
605 R_AARCH64_MOVW_UABS_G1_NC = 0x10a
606 R_AARCH64_MOVW_UABS_G2 = 0x10b
607 R_AARCH64_MOVW_UABS_G2_NC = 0x10c
608 R_AARCH64_MOVW_UABS_G3 = 0x10d
609 R_AARCH64_MOVW_SABS_G0 = 0x10e
610 R_AARCH64_MOVW_SABS_G1 = 0x10f
611 R_AARCH64_MOVW_SABS_G2 = 0x110
612 R_AARCH64_LD_PREL_LO19 = 0x111
613 R_AARCH64_ADR_PREL_LO21 = 0x112
614 R_AARCH64_ADR_PREL_PG_HI21 = 0x113
615 R_AARCH64_ADR_PREL_PG_HI21_NC = 0x114
616 R_AARCH64_ADD_ABS_LO12_NC = 0x115
617 R_AARCH64_LDST8_ABS_LO12_NC = 0x116
618 R_AARCH64_TSTBR14 = 0x117
619 R_AARCH64_CONDBR19 = 0x118
620 R_AARCH64_JUMP26 = 0x11a
621 R_AARCH64_CALL26 = 0x11b
622 R_AARCH64_LDST16_ABS_LO12_NC = 0x11c
623 R_AARCH64_LDST32_ABS_LO12_NC = 0x11d
624 R_AARCH64_LDST64_ABS_LO12_NC = 0x11e
625 R_AARCH64_MOVW_PREL_G0 = 0x11f
626 R_AARCH64_MOVW_PREL_G0_NC = 0x120
627 R_AARCH64_MOVW_PREL_G1 = 0x121
628 R_AARCH64_MOVW_PREL_G1_NC = 0x122
629 R_AARCH64_MOVW_PREL_G2 = 0x123
630 R_AARCH64_MOVW_PREL_G2_NC = 0x124
631 R_AARCH64_MOVW_PREL_G3 = 0x125
632 R_AARCH64_LDST128_ABS_LO12_NC = 0x12b
633 R_AARCH64_MOVW_GOTOFF_G0 = 0x12c
634 R_AARCH64_MOVW_GOTOFF_G0_NC = 0x12d
635 R_AARCH64_MOVW_GOTOFF_G1 = 0x12e
636 R_AARCH64_MOVW_GOTOFF_G1_NC = 0x12f
637 R_AARCH64_MOVW_GOTOFF_G2 = 0x130
638 R_AARCH64_MOVW_GOTOFF_G2_NC = 0x131
639 R_AARCH64_MOVW_GOTOFF_G3 = 0x132
640 R_AARCH64_GOTREL64 = 0x133
641 R_AARCH64_GOTREL32 = 0x134
642 R_AARCH64_GOT_LD_PREL19 = 0x135
643 R_AARCH64_LD64_GOTOFF_LO15 = 0x136
644 R_AARCH64_ADR_GOT_PAGE = 0x137
645 R_AARCH64_LD64_GOT_LO12_NC = 0x138
646 R_AARCH64_LD64_GOTPAGE_LO15 = 0x139
647 R_AARCH64_TLSGD_ADR_PREL21 = 0x200
648 R_AARCH64_TLSGD_ADR_PAGE21 = 0x201
649 R_AARCH64_TLSGD_ADD_LO12_NC = 0x202
650 R_AARCH64_TLSGD_MOVW_G1 = 0x203
651 R_AARCH64_TLSGD_MOVW_G0_NC = 0x204
652 R_AARCH64_TLSLD_ADR_PREL21 = 0x205
653 R_AARCH64_TLSLD_ADR_PAGE21 = 0x206
654 R_AARCH64_TLSLD_ADD_LO12_NC = 0x207
655 R_AARCH64_TLSLD_MOVW_G1 = 0x208
656 R_AARCH64_TLSLD_MOVW_G0_NC = 0x209
657 R_AARCH64_TLSLD_LD_PREL19 = 0x20a
658 R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 0x20b
659 R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 0x20c
660 R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 0x20d
661 R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 0x20e
662 R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 0x20f
663 R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 0x210
664 R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 0x211
665 R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 0x212
666 R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 0x213
667 R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 0x214
668 R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 0x215
669 R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 0x216
670 R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 0x217
671 R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 0x218
672 R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 0x219
673 R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 0x21a
674 R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 0x21b
675 R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 0x21c
676 R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 0x21d
677 R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 0x21e
678 R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 0x21f
679 R_AARCH64_TLSLE_MOVW_TPREL_G2 = 0x220
680 R_AARCH64_TLSLE_MOVW_TPREL_G1 = 0x221
681 R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 0x222
682 R_AARCH64_TLSLE_MOVW_TPREL_G0 = 0x223
683 R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 0x224
684 R_AARCH64_TLSLE_ADD_TPREL_HI12 = 0x225
685 R_AARCH64_TLSLE_ADD_TPREL_LO12 = 0x226
686 R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 0x227
687 R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 0x228
688 R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 0x229
689 R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 0x22a
690 R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 0x22b
691 R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 0x22c
692 R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 0x22d
693 R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 0x22e
694 R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 0x22f
695 R_AARCH64_TLSDESC_LD_PREL19 = 0x230
696 R_AARCH64_TLSDESC_ADR_PREL21 = 0x231
697 R_AARCH64_TLSDESC_ADR_PAGE21 = 0x232
698 R_AARCH64_TLSDESC_LD64_LO12_NC = 0x233
699 R_AARCH64_TLSDESC_ADD_LO12_NC = 0x234
700 R_AARCH64_TLSDESC_OFF_G1 = 0x235
701 R_AARCH64_TLSDESC_OFF_G0_NC = 0x236
702 R_AARCH64_TLSDESC_LDR = 0x237
703 R_AARCH64_TLSDESC_ADD = 0x238
704 R_AARCH64_TLSDESC_CALL = 0x239
705 R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 0x23a
706 R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 0x23b
707 R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 0x23c
708 R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 0x23d
709 R_AARCH64_COPY = 0x400
710 R_AARCH64_GLOB_DAT = 0x401
711 R_AARCH64_JUMP_SLOT = 0x402
712 R_AARCH64_RELATIVE = 0x403
713 R_AARCH64_TLS_DTPREL64 = 0x404
714 R_AARCH64_TLS_DTPMOD64 = 0x405
715 R_AARCH64_TLS_TPREL64 = 0x406
716 R_AARCH64_TLSDESC = 0x407
717 R_AARCH64_IRELATIVE = 0x408
719 class Relocs_Elf_AArch64_ILP32(Enum):
720 R_AARCH64_P32_NONE = 0
721 R_AARCH64_P32_ABS32 = 1
722 R_AARCH64_P32_ABS16 = 2
723 R_AARCH64_P32_PREL32 = 3
724 R_AARCH64_P32_PREL16 = 4
725 R_AARCH64_P32_MOVW_UABS_G0 = 5
726 R_AARCH64_P32_MOVW_UABS_G0_NC = 6
727 R_AARCH64_P32_MOVW_UABS_G1 = 7
728 R_AARCH64_P32_MOVW_SABS_G0 = 8
729 R_AARCH64_P32_LD_PREL_LO19 = 9
730 R_AARCH64_P32_ADR_PREL_LO21 = 10
731 R_AARCH64_P32_ADR_PREL_PG_HI21 = 11
732 R_AARCH64_P32_ADD_ABS_LO12_NC = 12
733 R_AARCH64_P32_LDST8_ABS_LO12_NC = 13
734 R_AARCH64_P32_LDST16_ABS_LO12_NC = 14
735 R_AARCH64_P32_LDST32_ABS_LO12_NC = 15
736 R_AARCH64_P32_LDST64_ABS_LO12_NC = 16
737 R_AARCH64_P32_LDST128_ABS_LO12_NC = 17
738 R_AARCH64_P32_TSTBR14 = 18
739 R_AARCH64_P32_CONDBR19 = 19
740 R_AARCH64_P32_JUMP26 = 20
741 R_AARCH64_P32_CALL26 = 21
742 R_AARCH64_P32_MOVW_PREL_G0 = 22
743 R_AARCH64_P32_MOVW_PREL_G0_NC = 23
744 R_AARCH64_P32_MOVW_PREL_G1 = 24
745 R_AARCH64_P32_GOT_LD_PREL19 = 25
746 R_AARCH64_P32_ADR_GOT_PAGE = 26
747 R_AARCH64_P32_LD32_GOT_LO12_NC = 27
748 R_AARCH64_P32_LD32_GOTPAGE_LO14 = 28
749 R_AARCH64_P32_TLSGD_ADR_PREL21 = 80
750 R_AARCH64_P32_TLS_GD_ADR_PAGE21 = 81
751 R_AARCH64_P32_TLSGD_ADD_LO12_NC = 82
752 R_AARCH64_P32_TLSLD_ADR_PREL21 = 83
753 R_AARCH64_P32_TLDLD_ADR_PAGE21 = 84
754 R_AARCH64_P32_TLSLD_ADR_LO12_NC = 85
755 R_AARCH64_P32_TLSLD_LD_PREL19 = 86
756 R_AARCH64_P32_TLDLD_MOVW_DTPREL_G1 = 87
757 R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0 = 88
758 R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0_NC = 89
759 R_AARCH64_P32_TLSLD_MOVW_ADD_DTPREL_HI12 = 90
760 R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12 = 91
761 R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12_NC = 92
762 R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12 = 93
763 R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12_NC = 94
764 R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12 = 95
765 R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12_NC = 96
766 R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12 = 97
767 R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12_NC = 98
768 R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12 = 99
769 R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12_NC = 100
770 R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12 = 101
771 R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12_NC = 102
772 R_AARCH64_P32_TLSIE_MOVW_GOTTPREL_PAGE21 = 103
773 R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC = 104
774 R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19 = 105
775 R_AARCH64_P32_TLSLE_MOVEW_TPREL_G1 = 106
776 R_AARCH64_P32_TLSLE_MOVW_TPREL_G0 = 107
777 R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC = 108
778 R_AARCH64_P32_TLS_MOVW_TPREL_HI12 = 109
779 R_AARCH64_P32_TLSLE_ADD_TPREL_LO12 = 110
780 R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC = 111
781 R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12 = 112
782 R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12_NC = 113
783 R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12 = 114
784 R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12_NC = 115
785 R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12 = 116
786 R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC = 117
787 R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12 = 118
788 R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC = 119
789 R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12 = 120
790 R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12_NC = 121
791 R_AARCH64_P32_TLSDESC_LD_PRELL19 = 122
792 R_AARCH64_P32_TLSDESC_ADR_PREL21 = 123
793 R_AARCH64_P32_TLSDESC_ADR_PAGE21 = 124
794 R_AARCH64_P32_TLSDESSC_LD32_LO12 = 125
795 R_AARCH64_P32_TLSDESC_ADD_LO12 = 126
796 R_AARCH64_P32_TLSDESC_CALL = 127
797 R_AARCH64_P32_COPY = 180
798 R_AARCH64_P32_GLOB_DAT = 181
799 R_AARCH64_P32_JUMP_SLOT = 182
800 R_AARCH64_P32_RELATIVE = 183
801 R_AARCH64_P32_TLS_DTPREL = 184
802 R_AARCH64_P32_TLS_DTPMOD = 185
803 R_AARCH64_P32_TLS_TPREL = 186
804 R_AARCH64_P32_TLSDESC = 187
805 R_AARCH64_P32_IRELATIVE = 188
807 class Relocs_Elf_ARM(Enum):
808 R_ARM_NONE = 0x00
809 R_ARM_PC24 = 0x01
810 R_ARM_ABS32 = 0x02
811 R_ARM_REL32 = 0x03
812 R_ARM_LDR_PC_G0 = 0x04
813 R_ARM_ABS16 = 0x05
814 R_ARM_ABS12 = 0x06
815 R_ARM_THM_ABS5 = 0x07
816 R_ARM_ABS8 = 0x08
817 R_ARM_SBREL32 = 0x09
818 R_ARM_THM_CALL = 0x0a
819 R_ARM_THM_PC8 = 0x0b
820 R_ARM_BREL_ADJ = 0x0c
821 R_ARM_TLS_DESC = 0x0d
822 R_ARM_THM_SWI8 = 0x0e
823 R_ARM_XPC25 = 0x0f
824 R_ARM_THM_XPC22 = 0x10
825 R_ARM_TLS_DTPMOD32 = 0x11
826 R_ARM_TLS_DTPOFF32 = 0x12
827 R_ARM_TLS_TPOFF32 = 0x13
828 R_ARM_COPY = 0x14
829 R_ARM_GLOB_DAT = 0x15
830 R_ARM_JUMP_SLOT = 0x16
831 R_ARM_RELATIVE = 0x17
832 R_ARM_GOTOFF32 = 0x18
833 R_ARM_BASE_PREL = 0x19
834 R_ARM_GOT_BREL = 0x1a
835 R_ARM_PLT32 = 0x1b
836 R_ARM_CALL = 0x1c
837 R_ARM_JUMP24 = 0x1d
838 R_ARM_THM_JUMP24 = 0x1e
839 R_ARM_BASE_ABS = 0x1f
840 R_ARM_ALU_PCREL_7_0 = 0x20
841 R_ARM_ALU_PCREL_15_8 = 0x21
842 R_ARM_ALU_PCREL_23_15 = 0x22
843 R_ARM_LDR_SBREL_11_0_NC = 0x23
844 R_ARM_ALU_SBREL_19_12_NC = 0x24
845 R_ARM_ALU_SBREL_27_20_CK = 0x25
846 R_ARM_TARGET1 = 0x26
847 R_ARM_SBREL31 = 0x27
848 R_ARM_V4BX = 0x28
849 R_ARM_TARGET2 = 0x29
850 R_ARM_PREL31 = 0x2a
851 R_ARM_MOVW_ABS_NC = 0x2b
852 R_ARM_MOVT_ABS = 0x2c
853 R_ARM_MOVW_PREL_NC = 0x2d
854 R_ARM_MOVT_PREL = 0x2e
855 R_ARM_THM_MOVW_ABS_NC = 0x2f
856 R_ARM_THM_MOVT_ABS = 0x30
857 R_ARM_THM_MOVW_PREL_NC = 0x31
858 R_ARM_THM_MOVT_PREL = 0x32
859 R_ARM_THM_JUMP19 = 0x33
860 R_ARM_THM_JUMP6 = 0x34
861 R_ARM_THM_ALU_PREL_11_0 = 0x35
862 R_ARM_THM_PC12 = 0x36
863 R_ARM_ABS32_NOI = 0x37
864 R_ARM_REL32_NOI = 0x38
865 R_ARM_ALU_PC_G0_NC = 0x39
866 R_ARM_ALU_PC_G0 = 0x3a
867 R_ARM_ALU_PC_G1_NC = 0x3b
868 R_ARM_ALU_PC_G1 = 0x3c
869 R_ARM_ALU_PC_G2 = 0x3d
870 R_ARM_LDR_PC_G1 = 0x3e
871 R_ARM_LDR_PC_G2 = 0x3f
872 R_ARM_LDRS_PC_G0 = 0x40
873 R_ARM_LDRS_PC_G1 = 0x41
874 R_ARM_LDRS_PC_G2 = 0x42
875 R_ARM_LDC_PC_G0 = 0x43
876 R_ARM_LDC_PC_G1 = 0x44
877 R_ARM_LDC_PC_G2 = 0x45
878 R_ARM_ALU_SB_G0_NC = 0x46
879 R_ARM_ALU_SB_G0 = 0x47
880 R_ARM_ALU_SB_G1_NC = 0x48
881 R_ARM_ALU_SB_G1 = 0x49
882 R_ARM_ALU_SB_G2 = 0x4a
883 R_ARM_LDR_SB_G0 = 0x4b
884 R_ARM_LDR_SB_G1 = 0x4c
885 R_ARM_LDR_SB_G2 = 0x4d
886 R_ARM_LDRS_SB_G0 = 0x4e
887 R_ARM_LDRS_SB_G1 = 0x4f
888 R_ARM_LDRS_SB_G2 = 0x50
889 R_ARM_LDC_SB_G0 = 0x51
890 R_ARM_LDC_SB_G1 = 0x52
891 R_ARM_LDC_SB_G2 = 0x53
892 R_ARM_MOVW_BREL_NC = 0x54
893 R_ARM_MOVT_BREL = 0x55
894 R_ARM_MOVW_BREL = 0x56
895 R_ARM_THM_MOVW_BREL_NC = 0x57
896 R_ARM_THM_MOVT_BREL = 0x58
897 R_ARM_THM_MOVW_BREL = 0x59
898 R_ARM_TLS_GOTDESC = 0x5a
899 R_ARM_TLS_CALL = 0x5b
900 R_ARM_TLS_DESCSEQ = 0x5c
901 R_ARM_THM_TLS_CALL = 0x5d
902 R_ARM_PLT32_ABS = 0x5e
903 R_ARM_GOT_ABS = 0x5f
904 R_ARM_GOT_PREL = 0x60
905 R_ARM_GOT_BREL12 = 0x61
906 R_ARM_GOTOFF12 = 0x62
907 R_ARM_GOTRELAX = 0x63
908 R_ARM_GNU_VTENTRY = 0x64
909 R_ARM_GNU_VTINHERIT = 0x65
910 R_ARM_THM_JUMP11 = 0x66
911 R_ARM_THM_JUMP8 = 0x67
912 R_ARM_TLS_GD32 = 0x68
913 R_ARM_TLS_LDM32 = 0x69
914 R_ARM_TLS_LDO32 = 0x6a
915 R_ARM_TLS_IE32 = 0x6b
916 R_ARM_TLS_LE32 = 0x6c
917 R_ARM_TLS_LDO12 = 0x6d
918 R_ARM_TLS_LE12 = 0x6e
919 R_ARM_TLS_IE12GP = 0x6f
920 R_ARM_PRIVATE_0 = 0x70
921 R_ARM_PRIVATE_1 = 0x71
922 R_ARM_PRIVATE_2 = 0x72
923 R_ARM_PRIVATE_3 = 0x73
924 R_ARM_PRIVATE_4 = 0x74
925 R_ARM_PRIVATE_5 = 0x75
926 R_ARM_PRIVATE_6 = 0x76
927 R_ARM_PRIVATE_7 = 0x77
928 R_ARM_PRIVATE_8 = 0x78
929 R_ARM_PRIVATE_9 = 0x79
930 R_ARM_PRIVATE_10 = 0x7a
931 R_ARM_PRIVATE_11 = 0x7b
932 R_ARM_PRIVATE_12 = 0x7c
933 R_ARM_PRIVATE_13 = 0x7d
934 R_ARM_PRIVATE_14 = 0x7e
935 R_ARM_PRIVATE_15 = 0x7f
936 R_ARM_ME_TOO = 0x80
937 R_ARM_THM_TLS_DESCSEQ16 = 0x81
938 R_ARM_THM_TLS_DESCSEQ32 = 0x82
939 R_ARM_IRELATIVE = 0xa0
941 class Relocs_Elf_Mips(Enum):
942 R_MIPS_NONE = 0
943 R_MIPS_16 = 1
944 R_MIPS_32 = 2
945 R_MIPS_REL32 = 3
946 R_MIPS_26 = 4
947 R_MIPS_HI16 = 5
948 R_MIPS_LO16 = 6
949 R_MIPS_GPREL16 = 7
950 R_MIPS_LITERAL = 8
951 R_MIPS_GOT16 = 9
952 R_MIPS_PC16 = 10
953 R_MIPS_CALL16 = 11
954 R_MIPS_GPREL32 = 12
955 R_MIPS_SHIFT5 = 16
956 R_MIPS_SHIFT6 = 17
957 R_MIPS_64 = 18
958 R_MIPS_GOT_DISP = 19
959 R_MIPS_GOT_PAGE = 20
960 R_MIPS_GOT_OFST = 21
961 R_MIPS_GOT_HI16 = 22
962 R_MIPS_GOT_LO16 = 23
963 R_MIPS_SUB = 24
964 R_MIPS_INSERT_A = 25
965 R_MIPS_INSERT_B = 26
966 R_MIPS_DELETE = 27
967 R_MIPS_HIGHER = 28
968 R_MIPS_HIGHEST = 29
969 R_MIPS_CALL_HI16 = 30
970 R_MIPS_CALL_LO16 = 31
971 R_MIPS_SCN_DISP = 32
972 R_MIPS_REL16 = 33
973 R_MIPS_ADD_IMMEDIATE = 34
974 R_MIPS_PJUMP = 35
975 R_MIPS_RELGOT = 36
976 R_MIPS_JALR = 37
977 R_MIPS_TLS_DTPMOD32 = 38
978 R_MIPS_TLS_DTPREL32 = 39
979 R_MIPS_TLS_DTPMOD64 = 40
980 R_MIPS_TLS_DTPREL64 = 41
981 R_MIPS_TLS_GD = 42
982 R_MIPS_TLS_LDM = 43
983 R_MIPS_TLS_DTPREL_HI16 = 44
984 R_MIPS_TLS_DTPREL_LO16 = 45
985 R_MIPS_TLS_GOTTPREL = 46
986 R_MIPS_TLS_TPREL32 = 47
987 R_MIPS_TLS_TPREL64 = 48
988 R_MIPS_TLS_TPREL_HI16 = 49
989 R_MIPS_TLS_TPREL_LO16 = 50
990 R_MIPS_GLOB_DAT = 51
991 R_MIPS_COPY = 126
992 R_MIPS_JUMP_SLOT = 127
993 R_MIPS_NUM = 218
995 class Relocs_Elf_Hexagon(Enum):
996 R_HEX_NONE = 0
997 R_HEX_B22_PCREL = 1
998 R_HEX_B15_PCREL = 2
999 R_HEX_B7_PCREL = 3
1000 R_HEX_LO16 = 4
1001 R_HEX_HI16 = 5
1002 R_HEX_32 = 6
1003 R_HEX_16 = 7
1004 R_HEX_8 = 8
1005 R_HEX_GPREL16_0 = 9
1006 R_HEX_GPREL16_1 = 10
1007 R_HEX_GPREL16_2 = 11
1008 R_HEX_GPREL16_3 = 12
1009 R_HEX_HL16 = 13
1010 R_HEX_B13_PCREL = 14
1011 R_HEX_B9_PCREL = 15
1012 R_HEX_B32_PCREL_X = 16
1013 R_HEX_32_6_X = 17
1014 R_HEX_B22_PCREL_X = 18
1015 R_HEX_B15_PCREL_X = 19
1016 R_HEX_B13_PCREL_X = 20
1017 R_HEX_B9_PCREL_X = 21
1018 R_HEX_B7_PCREL_X = 22
1019 R_HEX_16_X = 23
1020 R_HEX_12_X = 24
1021 R_HEX_11_X = 25
1022 R_HEX_10_X = 26
1023 R_HEX_9_X = 27
1024 R_HEX_8_X = 28
1025 R_HEX_7_X = 29
1026 R_HEX_6_X = 30
1027 R_HEX_32_PCREL = 31
1028 R_HEX_COPY = 32
1029 R_HEX_GLOB_DAT = 33
1030 R_HEX_JMP_SLOT = 34
1031 R_HEX_RELATIVE = 35
1032 R_HEX_PLT_B22_PCREL = 36
1033 R_HEX_GOTREL_LO16 = 37
1034 R_HEX_GOTREL_HI16 = 38
1035 R_HEX_GOTREL_32 = 39
1036 R_HEX_GOT_LO16 = 40
1037 R_HEX_GOT_HI16 = 41
1038 R_HEX_GOT_32 = 42
1039 R_HEX_GOT_16 = 43
1040 R_HEX_DTPMOD_32 = 44
1041 R_HEX_DTPREL_LO16 = 45
1042 R_HEX_DTPREL_HI16 = 46
1043 R_HEX_DTPREL_32 = 47
1044 R_HEX_DTPREL_16 = 48
1045 R_HEX_GD_PLT_B22_PCREL = 49
1046 R_HEX_GD_GOT_LO16 = 50
1047 R_HEX_GD_GOT_HI16 = 51
1048 R_HEX_GD_GOT_32 = 52
1049 R_HEX_GD_GOT_16 = 53
1050 R_HEX_IE_LO16 = 54
1051 R_HEX_IE_HI16 = 55
1052 R_HEX_IE_32 = 56
1053 R_HEX_IE_GOT_LO16 = 57
1054 R_HEX_IE_GOT_HI16 = 58
1055 R_HEX_IE_GOT_32 = 59
1056 R_HEX_IE_GOT_16 = 60
1057 R_HEX_TPREL_LO16 = 61
1058 R_HEX_TPREL_HI16 = 62
1059 R_HEX_TPREL_32 = 63
1060 R_HEX_TPREL_16 = 64
1061 R_HEX_6_PCREL_X = 65
1062 R_HEX_GOTREL_32_6_X = 66
1063 R_HEX_GOTREL_16_X = 67
1064 R_HEX_GOTREL_11_X = 68
1065 R_HEX_GOT_32_6_X = 69
1066 R_HEX_GOT_16_X = 70
1067 R_HEX_GOT_11_X = 71
1068 R_HEX_DTPREL_32_6_X = 72
1069 R_HEX_DTPREL_16_X = 73
1070 R_HEX_DTPREL_11_X = 74
1071 R_HEX_GD_GOT_32_6_X = 75
1072 R_HEX_GD_GOT_16_X = 76
1073 R_HEX_GD_GOT_11_X = 77
1074 R_HEX_IE_32_6_X = 78
1075 R_HEX_IE_16_X = 79
1076 R_HEX_IE_GOT_32_6_X = 80
1077 R_HEX_IE_GOT_16_X = 81
1078 R_HEX_IE_GOT_11_X = 82
1079 R_HEX_TPREL_32_6_X = 83
1080 R_HEX_TPREL_16_X = 84
1081 R_HEX_TPREL_11_X = 85
1083 class Relocs_Elf_Lanai(Enum):
1084 R_LANAI_NONE = 0
1085 R_LANAI_21 = 1
1086 R_LANAI_21_F = 2
1087 R_LANAI_25 = 3
1088 R_LANAI_32 = 4
1089 R_LANAI_HI16 = 5
1090 R_LANAI_LO16 = 6
1092 class Relocs_Coff_i386(Enum):
1093 IMAGE_REL_I386_ABSOLUTE = 0x0000
1094 IMAGE_REL_I386_DIR16 = 0x0001
1095 IMAGE_REL_I386_REL16 = 0x0002
1096 IMAGE_REL_I386_DIR32 = 0x0006
1097 IMAGE_REL_I386_DIR32NB = 0x0007
1098 IMAGE_REL_I386_SEG12 = 0x0009
1099 IMAGE_REL_I386_SECTION = 0x000A
1100 IMAGE_REL_I386_SECREL = 0x000B
1101 IMAGE_REL_I386_TOKEN = 0x000C
1102 IMAGE_REL_I386_SECREL7 = 0x000D
1103 IMAGE_REL_I386_REL32 = 0x0014
1105 class Relocs_Coff_X86_64(Enum):
1106 IMAGE_REL_AMD64_ABSOLUTE = 0x0000
1107 IMAGE_REL_AMD64_ADDR64 = 0x0001
1108 IMAGE_REL_AMD64_ADDR32 = 0x0002
1109 IMAGE_REL_AMD64_ADDR32NB = 0x0003
1110 IMAGE_REL_AMD64_REL32 = 0x0004
1111 IMAGE_REL_AMD64_REL32_1 = 0x0005
1112 IMAGE_REL_AMD64_REL32_2 = 0x0006
1113 IMAGE_REL_AMD64_REL32_3 = 0x0007
1114 IMAGE_REL_AMD64_REL32_4 = 0x0008
1115 IMAGE_REL_AMD64_REL32_5 = 0x0009
1116 IMAGE_REL_AMD64_SECTION = 0x000A
1117 IMAGE_REL_AMD64_SECREL = 0x000B
1118 IMAGE_REL_AMD64_SECREL7 = 0x000C
1119 IMAGE_REL_AMD64_TOKEN = 0x000D
1120 IMAGE_REL_AMD64_SREL32 = 0x000E
1121 IMAGE_REL_AMD64_PAIR = 0x000F
1122 IMAGE_REL_AMD64_SSPAN32 = 0x0010
1124 class Relocs_Coff_ARM(Enum):
1125 IMAGE_REL_ARM_ABSOLUTE = 0x0000
1126 IMAGE_REL_ARM_ADDR32 = 0x0001
1127 IMAGE_REL_ARM_ADDR32NB = 0x0002
1128 IMAGE_REL_ARM_BRANCH24 = 0x0003
1129 IMAGE_REL_ARM_BRANCH11 = 0x0004
1130 IMAGE_REL_ARM_TOKEN = 0x0005
1131 IMAGE_REL_ARM_BLX24 = 0x0008
1132 IMAGE_REL_ARM_BLX11 = 0x0009
1133 IMAGE_REL_ARM_SECTION = 0x000E
1134 IMAGE_REL_ARM_SECREL = 0x000F
1135 IMAGE_REL_ARM_MOV32A = 0x0010
1136 IMAGE_REL_ARM_MOV32T = 0x0011
1137 IMAGE_REL_ARM_BRANCH20T = 0x0012
1138 IMAGE_REL_ARM_BRANCH24T = 0x0014
1139 IMAGE_REL_ARM_BLX23T = 0x0015
1142 class Relocs_Macho_i386(Enum):
1143 RIT_Vanilla = 0
1144 RIT_Pair = 1
1145 RIT_Difference = 2
1146 RIT_Generic_PreboundLazyPointer = 3
1147 RIT_Generic_LocalDifference = 4
1148 RIT_Generic_TLV = 5
1150 class Relocs_Macho_X86_64(Enum):
1151 RIT_X86_64_Unsigned = 0
1152 RIT_X86_64_Signed = 1
1153 RIT_X86_64_Branch = 2
1154 RIT_X86_64_GOTLoad = 3
1155 RIT_X86_64_GOT = 4
1156 RIT_X86_64_Subtractor = 5
1157 RIT_X86_64_Signed1 = 6
1158 RIT_X86_64_Signed2 = 7
1159 RIT_X86_64_Signed4 = 8
1160 RIT_X86_64_TLV = 9
1162 class Relocs_Macho_ARM(Enum):
1163 RIT_Vanilla = 0
1164 RIT_Pair = 1
1165 RIT_Difference = 2
1166 RIT_ARM_LocalDifference = 3
1167 RIT_ARM_PreboundLazyPointer = 4
1168 RIT_ARM_Branch24Bit = 5
1169 RIT_ARM_ThumbBranch22Bit = 6
1170 RIT_ARM_ThumbBranch32Bit = 7
1171 RIT_ARM_Half = 8
1172 RIT_ARM_HalfDifference = 9
1174 class Relocs_Macho_PPC(Enum):
1175 PPC_RELOC_VANILLA = 0
1176 PPC_RELOC_PAIR = 1
1177 PPC_RELOC_BR14 = 2
1178 PPC_RELOC_BR24 = 3
1179 PPC_RELOC_HI16 = 4
1180 PPC_RELOC_LO16 = 5
1181 PPC_RELOC_HA16 = 6
1182 PPC_RELOC_LO14 = 7
1183 PPC_RELOC_SECTDIFF = 8
1184 PPC_RELOC_PB_LA_PTR = 9
1185 PPC_RELOC_HI16_SECTDIFF = 10
1186 PPC_RELOC_LO16_SECTDIFF = 11
1187 PPC_RELOC_HA16_SECTDIFF = 12
1188 PPC_RELOC_JBSR = 13
1189 PPC_RELOC_LO14_SECTDIFF = 14
1190 PPC_RELOC_LOCAL_SECTDIFF = 15
1193 craftElf("relocs.obj.elf-x86_64", "x86_64-pc-linux-gnu", Relocs_Elf_X86_64.entries(), "leaq sym@GOTTPOFF(%rip), %rax")
1194 craftElf("relocs.obj.elf-i386", "i386-pc-linux-gnu", Relocs_Elf_i386.entries(), "mov sym@GOTOFF(%ebx), %eax")
1195 #craftElf("relocs-elf-ppc32", "powerpc-unknown-linux-gnu", Relocs_Elf_PPC32.entries(), ...)
1196 craftElf("relocs.obj.elf-ppc64", "powerpc64-unknown-linux-gnu", Relocs_Elf_PPC64.entries(),
1197 ("@t = thread_local global i32 0, align 4", "define i32* @f{0}() nounwind {{ ret i32* @t }}", 2))
1198 craftElf("relocs.obj.elf-aarch64", "aarch64", Relocs_Elf_AArch64.entries(), "movz x0, #:abs_g0:sym")
1199 craftElf("relocs.obj.elf-aarch64-ilp32", "aarch64",
1200 Relocs_Elf_AArch64_ILP32.entries(), "movz x0, #:abs_g0:sym")
1201 Relocs_Elf_AArch64_ILP32
1202 craftElf("relocs.obj.elf-arm", "arm-unknown-unknown", Relocs_Elf_ARM.entries(), "b sym")
1203 craftElf("relocs.obj.elf-mips", "mips-unknown-linux", Relocs_Elf_Mips.entries(), "lui $2, %hi(sym)")
1204 craftElf("relocs.obj.elf-mips64el", "mips64el-unknown-linux", Relocs_Elf_Mips.entries(), "lui $2, %hi(sym)")
1205 #craftElf("relocs.obj.elf-hexagon", "hexagon-unknown-unknown", Relocs_Elf_Hexagon.entries(), ...)
1206 #craftElf("relocs.obj.elf-lanai", "lanai-unknown-unknown", Relocs_Elf_Lanai.entries(), "mov hi(x), %r4")
1208 craftCoff("relocs.obj.coff-i386", "i386-pc-win32", Relocs_Coff_i386.entries(), "mov foo@imgrel(%ebx, %ecx, 4), %eax")
1209 craftCoff("relocs.obj.coff-x86_64", "x86_64-pc-win32", Relocs_Coff_X86_64.entries(), "mov foo@imgrel(%ebx, %ecx, 4), %eax")
1210 #craftCoff("relocs.obj.coff-arm", "arm-pc-win32", Relocs_Coff_ARM.entries(), "...")
1212 craftMacho("relocs.obj.macho-i386", "i386-apple-darwin9", Relocs_Macho_i386.entries(),
1213 ("asm", ".subsections_via_symbols; .text; a: ; b:", "call a", 1))
1214 craftMacho("relocs.obj.macho-x86_64", "x86_64-apple-darwin9", Relocs_Macho_X86_64.entries(),
1215 ("asm", ".subsections_via_symbols; .text; a: ; b:", "call a", 1))
1216 craftMacho("relocs.obj.macho-arm", "armv7-apple-darwin10", Relocs_Macho_ARM.entries(), "bl sym")
1217 #craftMacho("relocs.obj.macho-ppc", "powerpc-apple-darwin10", Relocs_Macho_PPC.entries(), ...)