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