LLVM  14.0.0git
RelocationResolver.cpp
Go to the documentation of this file.
1 //===- RelocationResolver.cpp ------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines utilities to resolve relocations in object files.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 
15 namespace llvm {
16 namespace object {
17 
18 static int64_t getELFAddend(RelocationRef R) {
19  Expected<int64_t> AddendOrErr = ELFRelocationRef(R).getAddend();
20  handleAllErrors(AddendOrErr.takeError(), [](const ErrorInfoBase &EI) {
21  report_fatal_error(Twine(EI.message()));
22  });
23  return *AddendOrErr;
24 }
25 
27  switch (Type) {
28  case ELF::R_X86_64_NONE:
29  case ELF::R_X86_64_64:
30  case ELF::R_X86_64_DTPOFF32:
31  case ELF::R_X86_64_DTPOFF64:
32  case ELF::R_X86_64_PC32:
33  case ELF::R_X86_64_PC64:
34  case ELF::R_X86_64_32:
35  case ELF::R_X86_64_32S:
36  return true;
37  default:
38  return false;
39  }
40 }
41 
43  uint64_t LocData, int64_t Addend) {
44  switch (Type) {
45  case ELF::R_X86_64_NONE:
46  return LocData;
47  case ELF::R_X86_64_64:
48  case ELF::R_X86_64_DTPOFF32:
49  case ELF::R_X86_64_DTPOFF64:
50  return S + Addend;
51  case ELF::R_X86_64_PC32:
52  case ELF::R_X86_64_PC64:
53  return S + Addend - Offset;
54  case ELF::R_X86_64_32:
55  case ELF::R_X86_64_32S:
56  return (S + Addend) & 0xFFFFFFFF;
57  default:
58  llvm_unreachable("Invalid relocation type");
59  }
60 }
61 
63  switch (Type) {
64  case ELF::R_AARCH64_ABS32:
65  case ELF::R_AARCH64_ABS64:
66  case ELF::R_AARCH64_PREL32:
67  case ELF::R_AARCH64_PREL64:
68  return true;
69  default:
70  return false;
71  }
72 }
73 
75  uint64_t /*LocData*/, int64_t Addend) {
76  switch (Type) {
77  case ELF::R_AARCH64_ABS32:
78  return (S + Addend) & 0xFFFFFFFF;
79  case ELF::R_AARCH64_ABS64:
80  return S + Addend;
81  case ELF::R_AARCH64_PREL32:
82  return (S + Addend - Offset) & 0xFFFFFFFF;
83  case ELF::R_AARCH64_PREL64:
84  return S + Addend - Offset;
85  default:
86  llvm_unreachable("Invalid relocation type");
87  }
88 }
89 
90 static bool supportsBPF(uint64_t Type) {
91  switch (Type) {
92  case ELF::R_BPF_64_ABS32:
93  case ELF::R_BPF_64_ABS64:
94  return true;
95  default:
96  return false;
97  }
98 }
99 
101  uint64_t LocData, int64_t /*Addend*/) {
102  switch (Type) {
103  case ELF::R_BPF_64_ABS32:
104  return (S + LocData) & 0xFFFFFFFF;
105  case ELF::R_BPF_64_ABS64:
106  return S + LocData;
107  default:
108  llvm_unreachable("Invalid relocation type");
109  }
110 }
111 
113  switch (Type) {
114  case ELF::R_MIPS_32:
115  case ELF::R_MIPS_64:
116  case ELF::R_MIPS_TLS_DTPREL64:
117  case ELF::R_MIPS_PC32:
118  return true;
119  default:
120  return false;
121  }
122 }
123 
125  uint64_t /*LocData*/, int64_t Addend) {
126  switch (Type) {
127  case ELF::R_MIPS_32:
128  return (S + Addend) & 0xFFFFFFFF;
129  case ELF::R_MIPS_64:
130  return S + Addend;
131  case ELF::R_MIPS_TLS_DTPREL64:
132  return S + Addend - 0x8000;
133  case ELF::R_MIPS_PC32:
134  return S + Addend - Offset;
135  default:
136  llvm_unreachable("Invalid relocation type");
137  }
138 }
139 
141  switch (Type) {
142  case ELF::R_MSP430_32:
143  case ELF::R_MSP430_16_BYTE:
144  return true;
145  default:
146  return false;
147  }
148 }
149 
151  uint64_t /*LocData*/, int64_t Addend) {
152  switch (Type) {
153  case ELF::R_MSP430_32:
154  return (S + Addend) & 0xFFFFFFFF;
155  case ELF::R_MSP430_16_BYTE:
156  return (S + Addend) & 0xFFFF;
157  default:
158  llvm_unreachable("Invalid relocation type");
159  }
160 }
161 
163  switch (Type) {
164  case ELF::R_PPC64_ADDR32:
165  case ELF::R_PPC64_ADDR64:
166  case ELF::R_PPC64_REL32:
167  case ELF::R_PPC64_REL64:
168  return true;
169  default:
170  return false;
171  }
172 }
173 
175  uint64_t /*LocData*/, int64_t Addend) {
176  switch (Type) {
177  case ELF::R_PPC64_ADDR32:
178  return (S + Addend) & 0xFFFFFFFF;
179  case ELF::R_PPC64_ADDR64:
180  return S + Addend;
181  case ELF::R_PPC64_REL32:
182  return (S + Addend - Offset) & 0xFFFFFFFF;
183  case ELF::R_PPC64_REL64:
184  return S + Addend - Offset;
185  default:
186  llvm_unreachable("Invalid relocation type");
187  }
188 }
189 
191  switch (Type) {
192  case ELF::R_390_32:
193  case ELF::R_390_64:
194  return true;
195  default:
196  return false;
197  }
198 }
199 
201  uint64_t /*LocData*/, int64_t Addend) {
202  switch (Type) {
203  case ELF::R_390_32:
204  return (S + Addend) & 0xFFFFFFFF;
205  case ELF::R_390_64:
206  return S + Addend;
207  default:
208  llvm_unreachable("Invalid relocation type");
209  }
210 }
211 
213  switch (Type) {
214  case ELF::R_SPARC_32:
215  case ELF::R_SPARC_64:
216  case ELF::R_SPARC_UA32:
217  case ELF::R_SPARC_UA64:
218  return true;
219  default:
220  return false;
221  }
222 }
223 
225  uint64_t /*LocData*/, int64_t Addend) {
226  switch (Type) {
227  case ELF::R_SPARC_32:
228  case ELF::R_SPARC_64:
229  case ELF::R_SPARC_UA32:
230  case ELF::R_SPARC_UA64:
231  return S + Addend;
232  default:
233  llvm_unreachable("Invalid relocation type");
234  }
235 }
236 
238  switch (Type) {
239  case ELF::R_AMDGPU_ABS32:
240  case ELF::R_AMDGPU_ABS64:
241  return true;
242  default:
243  return false;
244  }
245 }
246 
248  uint64_t /*LocData*/, int64_t Addend) {
249  switch (Type) {
250  case ELF::R_AMDGPU_ABS32:
251  case ELF::R_AMDGPU_ABS64:
252  return S + Addend;
253  default:
254  llvm_unreachable("Invalid relocation type");
255  }
256 }
257 
258 static bool supportsX86(uint64_t Type) {
259  switch (Type) {
260  case ELF::R_386_NONE:
261  case ELF::R_386_32:
262  case ELF::R_386_PC32:
263  return true;
264  default:
265  return false;
266  }
267 }
268 
270  uint64_t LocData, int64_t /*Addend*/) {
271  switch (Type) {
272  case ELF::R_386_NONE:
273  return LocData;
274  case ELF::R_386_32:
275  return S + LocData;
276  case ELF::R_386_PC32:
277  return S - Offset + LocData;
278  default:
279  llvm_unreachable("Invalid relocation type");
280  }
281 }
282 
284  switch (Type) {
285  case ELF::R_PPC_ADDR32:
286  case ELF::R_PPC_REL32:
287  return true;
288  default:
289  return false;
290  }
291 }
292 
294  uint64_t /*LocData*/, int64_t Addend) {
295  switch (Type) {
296  case ELF::R_PPC_ADDR32:
297  return (S + Addend) & 0xFFFFFFFF;
298  case ELF::R_PPC_REL32:
299  return (S + Addend - Offset) & 0xFFFFFFFF;
300  }
301  llvm_unreachable("Invalid relocation type");
302 }
303 
304 static bool supportsARM(uint64_t Type) {
305  switch (Type) {
306  case ELF::R_ARM_ABS32:
307  case ELF::R_ARM_REL32:
308  return true;
309  default:
310  return false;
311  }
312 }
313 
315  uint64_t LocData, int64_t Addend) {
316  // Support both RELA and REL relocations. The caller is responsible
317  // for supplying the correct values for LocData and Addend, i.e.
318  // Addend == 0 for REL and LocData == 0 for RELA.
319  assert((LocData == 0 || Addend == 0) &&
320  "one of LocData and Addend must be 0");
321  switch (Type) {
322  case ELF::R_ARM_ABS32:
323  return (S + LocData + Addend) & 0xFFFFFFFF;
324  case ELF::R_ARM_REL32:
325  return (S + LocData + Addend - Offset) & 0xFFFFFFFF;
326  }
327  llvm_unreachable("Invalid relocation type");
328 }
329 
330 static bool supportsAVR(uint64_t Type) {
331  switch (Type) {
332  case ELF::R_AVR_16:
333  case ELF::R_AVR_32:
334  return true;
335  default:
336  return false;
337  }
338 }
339 
341  uint64_t /*LocData*/, int64_t Addend) {
342  switch (Type) {
343  case ELF::R_AVR_16:
344  return (S + Addend) & 0xFFFF;
345  case ELF::R_AVR_32:
346  return (S + Addend) & 0xFFFFFFFF;
347  default:
348  llvm_unreachable("Invalid relocation type");
349  }
350 }
351 
353  return Type == ELF::R_LANAI_32;
354 }
355 
357  uint64_t /*LocData*/, int64_t Addend) {
358  if (Type == ELF::R_LANAI_32)
359  return (S + Addend) & 0xFFFFFFFF;
360  llvm_unreachable("Invalid relocation type");
361 }
362 
364  switch (Type) {
365  case ELF::R_MIPS_32:
366  case ELF::R_MIPS_TLS_DTPREL32:
367  return true;
368  default:
369  return false;
370  }
371 }
372 
374  uint64_t LocData, int64_t /*Addend*/) {
375  // FIXME: Take in account implicit addends to get correct results.
376  if (Type == ELF::R_MIPS_32)
377  return (S + LocData) & 0xFFFFFFFF;
378  if (Type == ELF::R_MIPS_TLS_DTPREL32)
379  return (S + LocData) & 0xFFFFFFFF;
380  llvm_unreachable("Invalid relocation type");
381 }
382 
384  switch (Type) {
385  case ELF::R_SPARC_32:
386  case ELF::R_SPARC_UA32:
387  return true;
388  default:
389  return false;
390  }
391 }
392 
394  uint64_t LocData, int64_t Addend) {
395  if (Type == ELF::R_SPARC_32 || Type == ELF::R_SPARC_UA32)
396  return S + Addend;
397  return LocData;
398 }
399 
401  return Type == ELF::R_HEX_32;
402 }
403 
405  uint64_t /*LocData*/, int64_t Addend) {
406  if (Type == ELF::R_HEX_32)
407  return S + Addend;
408  llvm_unreachable("Invalid relocation type");
409 }
410 
412  switch (Type) {
413  case ELF::R_RISCV_NONE:
414  case ELF::R_RISCV_32:
415  case ELF::R_RISCV_32_PCREL:
416  case ELF::R_RISCV_64:
417  case ELF::R_RISCV_SET6:
418  case ELF::R_RISCV_SUB6:
419  case ELF::R_RISCV_ADD8:
420  case ELF::R_RISCV_SUB8:
421  case ELF::R_RISCV_ADD16:
422  case ELF::R_RISCV_SUB16:
423  case ELF::R_RISCV_ADD32:
424  case ELF::R_RISCV_SUB32:
425  case ELF::R_RISCV_ADD64:
426  case ELF::R_RISCV_SUB64:
427  return true;
428  default:
429  return false;
430  }
431 }
432 
434  uint64_t LocData, int64_t Addend) {
435  int64_t RA = Addend;
436  uint64_t A = LocData;
437  switch (Type) {
438  case ELF::R_RISCV_NONE:
439  return LocData;
440  case ELF::R_RISCV_32:
441  return (S + RA) & 0xFFFFFFFF;
442  case ELF::R_RISCV_32_PCREL:
443  return (S + RA - Offset) & 0xFFFFFFFF;
444  case ELF::R_RISCV_64:
445  return S + RA;
446  case ELF::R_RISCV_SET6:
447  return (A & 0xC0) | ((S + RA) & 0x3F);
448  case ELF::R_RISCV_SUB6:
449  return (A & 0xC0) | (((A & 0x3F) - (S + RA)) & 0x3F);
450  case ELF::R_RISCV_ADD8:
451  return (A + (S + RA)) & 0xFF;
452  case ELF::R_RISCV_SUB8:
453  return (A - (S + RA)) & 0xFF;
454  case ELF::R_RISCV_ADD16:
455  return (A + (S + RA)) & 0xFFFF;
456  case ELF::R_RISCV_SUB16:
457  return (A - (S + RA)) & 0xFFFF;
458  case ELF::R_RISCV_ADD32:
459  return (A + (S + RA)) & 0xFFFFFFFF;
460  case ELF::R_RISCV_SUB32:
461  return (A - (S + RA)) & 0xFFFFFFFF;
462  case ELF::R_RISCV_ADD64:
463  return (A + (S + RA));
464  case ELF::R_RISCV_SUB64:
465  return (A - (S + RA));
466  default:
467  llvm_unreachable("Invalid relocation type");
468  }
469 }
470 
472  switch (Type) {
475  return true;
476  default:
477  return false;
478  }
479 }
480 
482  uint64_t LocData, int64_t /*Addend*/) {
483  switch (Type) {
486  return (S + LocData) & 0xFFFFFFFF;
487  default:
488  llvm_unreachable("Invalid relocation type");
489  }
490 }
491 
493  switch (Type) {
496  return true;
497  default:
498  return false;
499  }
500 }
501 
503  uint64_t LocData, int64_t /*Addend*/) {
504  switch (Type) {
506  return (S + LocData) & 0xFFFFFFFF;
508  return S + LocData;
509  default:
510  llvm_unreachable("Invalid relocation type");
511  }
512 }
513 
515  switch (Type) {
518  return true;
519  default:
520  return false;
521  }
522 }
523 
525  uint64_t LocData, int64_t /*Addend*/) {
526  switch (Type) {
529  return (S + LocData) & 0xFFFFFFFF;
530  default:
531  llvm_unreachable("Invalid relocation type");
532  }
533 }
534 
536  switch (Type) {
539  return true;
540  default:
541  return false;
542  }
543 }
544 
546  uint64_t LocData, int64_t /*Addend*/) {
547  switch (Type) {
549  return (S + LocData) & 0xFFFFFFFF;
551  return S + LocData;
552  default:
553  llvm_unreachable("Invalid relocation type");
554  }
555 }
556 
559 }
560 
562  uint64_t LocData, int64_t /*Addend*/) {
564  return S;
565  llvm_unreachable("Invalid relocation type");
566 }
567 
569  switch (Type) {
570  case wasm::R_WASM_FUNCTION_INDEX_LEB:
571  case wasm::R_WASM_TABLE_INDEX_SLEB:
572  case wasm::R_WASM_TABLE_INDEX_I32:
573  case wasm::R_WASM_MEMORY_ADDR_LEB:
574  case wasm::R_WASM_MEMORY_ADDR_SLEB:
575  case wasm::R_WASM_MEMORY_ADDR_I32:
576  case wasm::R_WASM_TYPE_INDEX_LEB:
577  case wasm::R_WASM_GLOBAL_INDEX_LEB:
578  case wasm::R_WASM_FUNCTION_OFFSET_I32:
579  case wasm::R_WASM_SECTION_OFFSET_I32:
580  case wasm::R_WASM_TAG_INDEX_LEB:
581  case wasm::R_WASM_GLOBAL_INDEX_I32:
582  case wasm::R_WASM_TABLE_NUMBER_LEB:
583  case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
584  return true;
585  default:
586  return false;
587  }
588 }
589 
591  switch (Type) {
592  case wasm::R_WASM_MEMORY_ADDR_LEB64:
593  case wasm::R_WASM_MEMORY_ADDR_SLEB64:
594  case wasm::R_WASM_MEMORY_ADDR_I64:
595  case wasm::R_WASM_TABLE_INDEX_SLEB64:
596  case wasm::R_WASM_TABLE_INDEX_I64:
597  case wasm::R_WASM_FUNCTION_OFFSET_I64:
598  return true;
599  default:
600  return supportsWasm32(Type);
601  }
602 }
603 
605  uint64_t LocData, int64_t /*Addend*/) {
606  switch (Type) {
607  case wasm::R_WASM_FUNCTION_INDEX_LEB:
608  case wasm::R_WASM_TABLE_INDEX_SLEB:
609  case wasm::R_WASM_TABLE_INDEX_I32:
610  case wasm::R_WASM_MEMORY_ADDR_LEB:
611  case wasm::R_WASM_MEMORY_ADDR_SLEB:
612  case wasm::R_WASM_MEMORY_ADDR_I32:
613  case wasm::R_WASM_TYPE_INDEX_LEB:
614  case wasm::R_WASM_GLOBAL_INDEX_LEB:
615  case wasm::R_WASM_FUNCTION_OFFSET_I32:
616  case wasm::R_WASM_SECTION_OFFSET_I32:
617  case wasm::R_WASM_TAG_INDEX_LEB:
618  case wasm::R_WASM_GLOBAL_INDEX_I32:
619  case wasm::R_WASM_TABLE_NUMBER_LEB:
620  case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
621  // For wasm section, its offset at 0 -- ignoring Value
622  return LocData;
623  default:
624  llvm_unreachable("Invalid relocation type");
625  }
626 }
627 
629  uint64_t LocData, int64_t Addend) {
630  switch (Type) {
631  case wasm::R_WASM_MEMORY_ADDR_LEB64:
632  case wasm::R_WASM_MEMORY_ADDR_SLEB64:
633  case wasm::R_WASM_MEMORY_ADDR_I64:
634  case wasm::R_WASM_TABLE_INDEX_SLEB64:
635  case wasm::R_WASM_TABLE_INDEX_I64:
636  case wasm::R_WASM_FUNCTION_OFFSET_I64:
637  // For wasm section, its offset at 0 -- ignoring Value
638  return LocData;
639  default:
640  return resolveWasm32(Type, Offset, S, LocData, Addend);
641  }
642 }
643 
644 std::pair<SupportsRelocation, RelocationResolver>
646  if (Obj.isCOFF()) {
647  switch (Obj.getArch()) {
648  case Triple::x86_64:
650  case Triple::x86:
652  case Triple::arm:
653  case Triple::thumb:
655  case Triple::aarch64:
657  default:
658  return {nullptr, nullptr};
659  }
660  } else if (Obj.isELF()) {
661  if (Obj.getBytesInAddress() == 8) {
662  switch (Obj.getArch()) {
663  case Triple::x86_64:
664  return {supportsX86_64, resolveX86_64};
665  case Triple::aarch64:
666  case Triple::aarch64_be:
668  case Triple::bpfel:
669  case Triple::bpfeb:
670  return {supportsBPF, resolveBPF};
671  case Triple::mips64el:
672  case Triple::mips64:
673  return {supportsMips64, resolveMips64};
674  case Triple::ppc64le:
675  case Triple::ppc64:
676  return {supportsPPC64, resolvePPC64};
677  case Triple::systemz:
679  case Triple::sparcv9:
681  case Triple::amdgcn:
682  return {supportsAmdgpu, resolveAmdgpu};
683  case Triple::riscv64:
684  return {supportsRISCV, resolveRISCV};
685  default:
686  return {nullptr, nullptr};
687  }
688  }
689 
690  // 32-bit object file
691  assert(Obj.getBytesInAddress() == 4 &&
692  "Invalid word size in object file");
693 
694  switch (Obj.getArch()) {
695  case Triple::x86:
696  return {supportsX86, resolveX86};
697  case Triple::ppcle:
698  case Triple::ppc:
699  return {supportsPPC32, resolvePPC32};
700  case Triple::arm:
701  case Triple::armeb:
702  return {supportsARM, resolveARM};
703  case Triple::avr:
704  return {supportsAVR, resolveAVR};
705  case Triple::lanai:
706  return {supportsLanai, resolveLanai};
707  case Triple::mipsel:
708  case Triple::mips:
709  return {supportsMips32, resolveMips32};
710  case Triple::msp430:
711  return {supportsMSP430, resolveMSP430};
712  case Triple::sparc:
714  case Triple::hexagon:
716  case Triple::riscv32:
717  return {supportsRISCV, resolveRISCV};
718  default:
719  return {nullptr, nullptr};
720  }
721  } else if (Obj.isMachO()) {
722  if (Obj.getArch() == Triple::x86_64)
724  return {nullptr, nullptr};
725  } else if (Obj.isWasm()) {
726  if (Obj.getArch() == Triple::wasm32)
727  return {supportsWasm32, resolveWasm32};
728  if (Obj.getArch() == Triple::wasm64)
729  return {supportsWasm64, resolveWasm64};
730  return {nullptr, nullptr};
731  }
732 
733  llvm_unreachable("Invalid object file");
734 }
735 
737  uint64_t S, uint64_t LocData) {
738  if (const ObjectFile *Obj = R.getObject()) {
739  int64_t Addend = 0;
740  if (Obj->isELF()) {
741  auto GetRelSectionType = [&]() -> unsigned {
742  if (auto *Elf32LEObj = dyn_cast<ELF32LEObjectFile>(Obj))
743  return Elf32LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
744  if (auto *Elf64LEObj = dyn_cast<ELF64LEObjectFile>(Obj))
745  return Elf64LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
746  if (auto *Elf32BEObj = dyn_cast<ELF32BEObjectFile>(Obj))
747  return Elf32BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
748  auto *Elf64BEObj = cast<ELF64BEObjectFile>(Obj);
749  return Elf64BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
750  };
751 
752  if (GetRelSectionType() == ELF::SHT_RELA) {
753  Addend = getELFAddend(R);
754  // RISCV relocations use both LocData and Addend.
755  if (Obj->getArch() != Triple::riscv32 &&
756  Obj->getArch() != Triple::riscv64)
757  LocData = 0;
758  }
759  }
760 
761  return Resolver(R.getType(), R.getOffset(), S, LocData, Addend);
762  }
763 
764  // Sometimes the caller might want to use its own specific implementation of
765  // the resolver function. E.g. this is used by LLD when it resolves debug
766  // relocations and assumes that all of them have the same computation (S + A).
767  // The relocation R has no owner object in this case and we don't need to
768  // provide Type and Offset fields. It is also assumed the DataRefImpl.p
769  // contains the addend, provided by the caller.
770  return Resolver(/*Type=*/0, /*Offset=*/0, S, LocData,
771  R.getRawDataRefImpl().p);
772 }
773 
774 } // namespace object
775 } // namespace llvm
llvm::object::resolveSystemZ
static uint64_t resolveSystemZ(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:200
llvm::Triple::riscv64
@ riscv64
Definition: Triple.h:74
llvm::object::resolveAmdgpu
static uint64_t resolveAmdgpu(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:247
llvm::object::supportsRISCV
static bool supportsRISCV(uint64_t Type)
Definition: RelocationResolver.cpp:411
llvm::ELF::SHT_RELA
@ SHT_RELA
Definition: ELF.h:919
llvm::COFF::IMAGE_REL_ARM64_SECREL
@ IMAGE_REL_ARM64_SECREL
Definition: COFF.h:394
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::object::supportsAVR
static bool supportsAVR(uint64_t Type)
Definition: RelocationResolver.cpp:330
llvm::object::ObjectFile::getBytesInAddress
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
llvm::Triple::bpfeb
@ bpfeb
Definition: Triple.h:58
llvm::object::resolveAArch64
static uint64_t resolveAArch64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:74
llvm::object::RelocationResolver
uint64_t(*)(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend) RelocationResolver
Definition: RelocationResolver.h:37
llvm::Triple::wasm32
@ wasm32
Definition: Triple.h:99
llvm::Triple::x86
@ x86
Definition: Triple.h:83
llvm::Triple::amdgcn
@ amdgcn
Definition: Triple.h:72
llvm::object::supportsMSP430
static bool supportsMSP430(uint64_t Type)
Definition: RelocationResolver.cpp:140
llvm::object::getELFAddend
static int64_t getELFAddend(RelocationRef R)
Definition: RelocationResolver.cpp:18
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:84
llvm::object::resolveARM
static uint64_t resolveARM(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
Definition: RelocationResolver.cpp:314
llvm::object::resolveCOFFX86_64
static uint64_t resolveCOFFX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:502
llvm::Triple::ppc
@ ppc
Definition: Triple.h:67
llvm::object::ObjectFile::getArch
virtual Triple::ArchType getArch() const =0
llvm::Triple::hexagon
@ hexagon
Definition: Triple.h:60
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::object::resolveX86_64
static uint64_t resolveX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
Definition: RelocationResolver.cpp:42
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::object::supportsCOFFARM64
static bool supportsCOFFARM64(uint64_t Type)
Definition: RelocationResolver.cpp:535
llvm::Triple::avr
@ avr
Definition: Triple.h:56
llvm::Triple::mips64
@ mips64
Definition: Triple.h:64
llvm::object::supportsMachOX86_64
static bool supportsMachOX86_64(uint64_t Type)
Definition: RelocationResolver.cpp:557
llvm::object::resolveSparc64
static uint64_t resolveSparc64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:224
llvm::object::supportsBPF
static bool supportsBPF(uint64_t Type)
Definition: RelocationResolver.cpp:90
llvm::Resolver
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2000
llvm::COFF::IMAGE_REL_ARM_SECREL
@ IMAGE_REL_ARM_SECREL
Definition: COFF.h:376
llvm::Triple::sparc
@ sparc
Definition: Triple.h:75
llvm::object::ELFRelocationRef
Definition: ELFObjectFile.h:195
llvm::object::supportsMips32
static bool supportsMips32(uint64_t Type)
Definition: RelocationResolver.cpp:363
llvm::Triple::sparcv9
@ sparcv9
Definition: Triple.h:76
llvm::object::resolveBPF
static uint64_t resolveBPF(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:100
llvm::object::supportsCOFFARM
static bool supportsCOFFARM(uint64_t Type)
Definition: RelocationResolver.cpp:514
llvm::object::supportsSparc64
static bool supportsSparc64(uint64_t Type)
Definition: RelocationResolver.cpp:212
llvm::Triple::mips64el
@ mips64el
Definition: Triple.h:65
llvm::object::resolvePPC32
static uint64_t resolvePPC32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:293
llvm::object::supportsWasm64
static bool supportsWasm64(uint64_t Type)
Definition: RelocationResolver.cpp:590
llvm::object::resolveWasm32
static uint64_t resolveWasm32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:604
llvm::Triple::ppc64
@ ppc64
Definition: Triple.h:69
llvm::object::supportsX86_64
static bool supportsX86_64(uint64_t Type)
Definition: RelocationResolver.cpp:26
llvm::COFF::IMAGE_REL_I386_DIR32
@ IMAGE_REL_I386_DIR32
Definition: COFF.h:335
llvm::Triple::lanai
@ lanai
Definition: Triple.h:98
llvm::object::resolveAVR
static uint64_t resolveAVR(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:340
llvm::ErrorInfoBase
Base class for error info classes.
Definition: Error.h:48
llvm::object::resolveMips64
static uint64_t resolveMips64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:124
llvm::object::supportsARM
static bool supportsARM(uint64_t Type)
Definition: RelocationResolver.cpp:304
llvm::object::resolveHexagon
static uint64_t resolveHexagon(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:404
llvm::Triple::ppc64le
@ ppc64le
Definition: Triple.h:70
llvm::MachO::X86_64_RELOC_UNSIGNED
@ X86_64_RELOC_UNSIGNED
Definition: MachO.h:474
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::object::resolveRISCV
static uint64_t resolveRISCV(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
Definition: RelocationResolver.cpp:433
uint64_t
llvm::object::supportsCOFFX86_64
static bool supportsCOFFX86_64(uint64_t Type)
Definition: RelocationResolver.cpp:492
llvm::object::supportsSparc32
static bool supportsSparc32(uint64_t Type)
Definition: RelocationResolver.cpp:383
llvm::COFF::IMAGE_REL_AMD64_ADDR64
@ IMAGE_REL_AMD64_ADDR64
Definition: COFF.h:347
llvm::object::supportsSystemZ
static bool supportsSystemZ(uint64_t Type)
Definition: RelocationResolver.cpp:190
llvm::object::supportsLanai
static bool supportsLanai(uint64_t Type)
Definition: RelocationResolver.cpp:352
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::object::Binary::isELF
bool isELF() const
Definition: Binary.h:120
llvm::object::supportsX86
static bool supportsX86(uint64_t Type)
Definition: RelocationResolver.cpp:258
llvm::Triple::bpfel
@ bpfel
Definition: Triple.h:57
RA
SI optimize exec mask operations pre RA
Definition: SIOptimizeExecMaskingPreRA.cpp:71
llvm::object::getRelocationResolver
std::pair< SupportsRelocation, RelocationResolver > getRelocationResolver(const ObjectFile &Obj)
Definition: RelocationResolver.cpp:645
llvm::Triple::armeb
@ armeb
Definition: Triple.h:51
llvm::object::supportsPPC64
static bool supportsPPC64(uint64_t Type)
Definition: RelocationResolver.cpp:162
RelocationResolver.h
llvm::object::Binary::isCOFF
bool isCOFF() const
Definition: Binary.h:128
llvm::object::resolveMSP430
static uint64_t resolveMSP430(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:150
llvm::Triple::arm
@ arm
Definition: Triple.h:50
llvm::object::resolveMips32
static uint64_t resolveMips32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:373
llvm::object::resolveX86
static uint64_t resolveX86(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:269
llvm::Triple::aarch64_be
@ aarch64_be
Definition: Triple.h:53
llvm::Triple::msp430
@ msp430
Definition: Triple.h:66
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
llvm::object::Binary::isWasm
bool isWasm() const
Definition: Binary.h:134
llvm::object::supportsPPC32
static bool supportsPPC32(uint64_t Type)
Definition: RelocationResolver.cpp:283
llvm::Triple::ppcle
@ ppcle
Definition: Triple.h:68
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
llvm::Triple::thumb
@ thumb
Definition: Triple.h:81
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::COFF::IMAGE_REL_AMD64_SECREL
@ IMAGE_REL_AMD64_SECREL
Definition: COFF.h:357
llvm::object::supportsMips64
static bool supportsMips64(uint64_t Type)
Definition: RelocationResolver.cpp:112
llvm::object::resolveCOFFARM64
static uint64_t resolveCOFFARM64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:545
llvm::object::resolveMachOX86_64
static uint64_t resolveMachOX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:561
llvm::object::resolveWasm64
static uint64_t resolveWasm64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
Definition: RelocationResolver.cpp:628
llvm::object::supportsWasm32
static bool supportsWasm32(uint64_t Type)
Definition: RelocationResolver.cpp:568
llvm::Triple::riscv32
@ riscv32
Definition: Triple.h:73
llvm::object::resolveLanai
static uint64_t resolveLanai(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:356
llvm::Triple::mipsel
@ mipsel
Definition: Triple.h:63
llvm::object::resolveCOFFX86
static uint64_t resolveCOFFX86(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:481
llvm::object::Binary::isMachO
bool isMachO() const
Definition: Binary.h:124
llvm::Triple::systemz
@ systemz
Definition: Triple.h:78
llvm::object::resolvePPC64
static uint64_t resolvePPC64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Definition: RelocationResolver.cpp:174
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:599
llvm::object::supportsAArch64
static bool supportsAArch64(uint64_t Type)
Definition: RelocationResolver.cpp:62
llvm::COFF::IMAGE_REL_I386_SECREL
@ IMAGE_REL_I386_SECREL
Definition: COFF.h:339
llvm::object::resolveSparc32
static uint64_t resolveSparc32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
Definition: RelocationResolver.cpp:393
llvm::object::resolveCOFFARM
static uint64_t resolveCOFFARM(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
Definition: RelocationResolver.cpp:524
llvm::object::RelocationRef
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:51
llvm::object::supportsHexagon
static bool supportsHexagon(uint64_t Type)
Definition: RelocationResolver.cpp:400
llvm::COFF::IMAGE_REL_ARM64_ADDR64
@ IMAGE_REL_ARM64_ADDR64
Definition: COFF.h:400
llvm::object::ELFRelocationRef::getAddend
Expected< int64_t > getAddend() const
Definition: ELFObjectFile.h:205
llvm::object::supportsAmdgpu
static bool supportsAmdgpu(uint64_t Type)
Definition: RelocationResolver.cpp:237
llvm::COFF::IMAGE_REL_ARM_ADDR32
@ IMAGE_REL_ARM_ADDR32
Definition: COFF.h:367
llvm::Triple::wasm64
@ wasm64
Definition: Triple.h:100
llvm::handleAllErrors
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition: Error.h:968
llvm::Triple::mips
@ mips
Definition: Triple.h:62
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:52
llvm::object::supportsCOFFX86
static bool supportsCOFFX86(uint64_t Type)
Definition: RelocationResolver.cpp:471
llvm::object::resolveRelocation
uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, uint64_t S, uint64_t LocData)
Definition: RelocationResolver.cpp:736