34 report_fatal_error(Twine(EI.message()));
41 case ELF::R_X86_64_NONE:
42 case ELF::R_X86_64_64:
43 case ELF::R_X86_64_DTPOFF32:
44 case ELF::R_X86_64_DTPOFF64:
45 case ELF::R_X86_64_PC32:
46 case ELF::R_X86_64_PC64:
47 case ELF::R_X86_64_32:
48 case ELF::R_X86_64_32S:
58 case ELF::R_X86_64_NONE:
60 case ELF::R_X86_64_64:
61 case ELF::R_X86_64_DTPOFF32:
62 case ELF::R_X86_64_DTPOFF64:
64 case ELF::R_X86_64_PC32:
65 case ELF::R_X86_64_PC64:
66 return S + Addend -
Offset;
67 case ELF::R_X86_64_32:
68 case ELF::R_X86_64_32S:
69 return (S + Addend) & 0xFFFFFFFF;
77 case ELF::R_AARCH64_ABS32:
78 case ELF::R_AARCH64_ABS64:
79 case ELF::R_AARCH64_PREL16:
80 case ELF::R_AARCH64_PREL32:
81 case ELF::R_AARCH64_PREL64:
82 case ELF::R_AARCH64_TLS_DTPREL64:
92 case ELF::R_AARCH64_ABS32:
93 return (S + Addend) & 0xFFFFFFFF;
94 case ELF::R_AARCH64_ABS64:
95 case ELF::R_AARCH64_TLS_DTPREL64:
97 case ELF::R_AARCH64_PREL16:
98 return (S + Addend -
Offset) & 0xFFFF;
99 case ELF::R_AARCH64_PREL32:
100 return (S + Addend -
Offset) & 0xFFFFFFFF;
101 case ELF::R_AARCH64_PREL64:
102 return S + Addend -
Offset;
110 case ELF::R_BPF_64_ABS32:
111 case ELF::R_BPF_64_ABS64:
121 case ELF::R_BPF_64_ABS32:
122 return (S + LocData) & 0xFFFFFFFF;
123 case ELF::R_BPF_64_ABS64:
134 case ELF::R_MIPS_TLS_DTPREL64:
135 case ELF::R_MIPS_PC32:
146 return (S + Addend) & 0xFFFFFFFF;
149 case ELF::R_MIPS_TLS_DTPREL64:
150 return S + Addend - 0x8000;
151 case ELF::R_MIPS_PC32:
152 return S + Addend -
Offset;
160 case ELF::R_MSP430_32:
161 case ELF::R_MSP430_16_BYTE:
171 case ELF::R_MSP430_32:
172 return (S + Addend) & 0xFFFFFFFF;
173 case ELF::R_MSP430_16_BYTE:
174 return (S + Addend) & 0xFFFF;
182 case ELF::R_PPC64_ADDR32:
183 case ELF::R_PPC64_ADDR64:
184 case ELF::R_PPC64_REL32:
185 case ELF::R_PPC64_REL64:
195 case ELF::R_PPC64_ADDR32:
196 return (S + Addend) & 0xFFFFFFFF;
197 case ELF::R_PPC64_ADDR64:
199 case ELF::R_PPC64_REL32:
200 return (S + Addend -
Offset) & 0xFFFFFFFF;
201 case ELF::R_PPC64_REL64:
202 return S + Addend -
Offset;
222 return (S + Addend) & 0xFFFFFFFF;
232 case ELF::R_SPARC_32:
233 case ELF::R_SPARC_64:
234 case ELF::R_SPARC_UA32:
235 case ELF::R_SPARC_UA64:
236 case ELF::R_SPARC_TLS_DTPOFF32:
237 case ELF::R_SPARC_TLS_DTPOFF64:
247 case ELF::R_SPARC_32:
248 case ELF::R_SPARC_64:
249 case ELF::R_SPARC_UA32:
250 case ELF::R_SPARC_UA64:
251 case ELF::R_SPARC_TLS_DTPOFF32:
252 case ELF::R_SPARC_TLS_DTPOFF64:
268 return ELFObj->getEMachine() == ELF::EM_AMDGPU;
274 case ELF::R_AMDGPU_ABS32:
275 case ELF::R_AMDGPU_ABS64:
284 assert((LocData == 0 || Addend == 0) &&
285 "one of LocData and Addend must be 0");
287 case ELF::R_AMDGPU_ABS32:
288 case ELF::R_AMDGPU_ABS64:
289 return S + LocData + Addend;
297 case ELF::R_386_NONE:
299 case ELF::R_386_PC32:
309 case ELF::R_386_NONE:
313 case ELF::R_386_PC32:
314 return S -
Offset + LocData;
322 case ELF::R_PPC_ADDR32:
323 case ELF::R_PPC_REL32:
333 case ELF::R_PPC_ADDR32:
334 return (S + Addend) & 0xFFFFFFFF;
335 case ELF::R_PPC_REL32:
336 return (S + Addend -
Offset) & 0xFFFFFFFF;
343 case ELF::R_ARM_ABS32:
344 case ELF::R_ARM_REL32:
356 assert((LocData == 0 || Addend == 0) &&
357 "one of LocData and Addend must be 0");
359 case ELF::R_ARM_ABS32:
360 return (S + LocData + Addend) & 0xFFFFFFFF;
361 case ELF::R_ARM_REL32:
362 return (S + LocData + Addend -
Offset) & 0xFFFFFFFF;
381 return (S + Addend) & 0xFFFF;
383 return (S + Addend) & 0xFFFFFFFF;
390 return Type == ELF::R_LANAI_32;
395 if (
Type == ELF::R_LANAI_32)
396 return (S + Addend) & 0xFFFFFFFF;
403 case ELF::R_MIPS_TLS_DTPREL32:
413 if (
Type == ELF::R_MIPS_32)
414 return (S + LocData) & 0xFFFFFFFF;
415 if (
Type == ELF::R_MIPS_TLS_DTPREL32)
416 return (S + LocData) & 0xFFFFFFFF;
422 case ELF::R_SPARC_32:
423 case ELF::R_SPARC_UA32:
424 case ELF::R_SPARC_TLS_DTPOFF32:
433 if (
Type == ELF::R_SPARC_32 ||
Type == ELF::R_SPARC_UA32 ||
434 Type == ELF::R_SPARC_TLS_DTPOFF32)
440 return Type == ELF::R_HEX_32;
445 if (
Type == ELF::R_HEX_32)
452 case ELF::R_RISCV_NONE:
453 case ELF::R_RISCV_32:
454 case ELF::R_RISCV_32_PCREL:
455 case ELF::R_RISCV_64:
456 case ELF::R_RISCV_SET6:
457 case ELF::R_RISCV_SET8:
458 case ELF::R_RISCV_SUB6:
459 case ELF::R_RISCV_ADD8:
460 case ELF::R_RISCV_SUB8:
461 case ELF::R_RISCV_SET16:
462 case ELF::R_RISCV_ADD16:
463 case ELF::R_RISCV_SUB16:
464 case ELF::R_RISCV_SET32:
465 case ELF::R_RISCV_ADD32:
466 case ELF::R_RISCV_SUB32:
467 case ELF::R_RISCV_ADD64:
468 case ELF::R_RISCV_SUB64:
473 case ELF::R_RISCV_SET_ULEB128:
474 case ELF::R_RISCV_SUB_ULEB128:
486 case ELF::R_RISCV_NONE:
488 case ELF::R_RISCV_32:
489 return (S +
RA) & 0xFFFFFFFF;
490 case ELF::R_RISCV_32_PCREL:
491 return (S +
RA -
Offset) & 0xFFFFFFFF;
492 case ELF::R_RISCV_64:
494 case ELF::R_RISCV_SET6:
495 return (
A & 0xC0) | ((S +
RA) & 0x3F);
496 case ELF::R_RISCV_SUB6:
497 return (
A & 0xC0) | (((
A & 0x3F) - (S +
RA)) & 0x3F);
498 case ELF::R_RISCV_SET8:
499 return (S +
RA) & 0xFF;
500 case ELF::R_RISCV_ADD8:
501 return (
A + (S +
RA)) & 0xFF;
502 case ELF::R_RISCV_SUB8:
503 return (
A - (S +
RA)) & 0xFF;
504 case ELF::R_RISCV_SET16:
505 return (S +
RA) & 0xFFFF;
506 case ELF::R_RISCV_ADD16:
507 return (
A + (S +
RA)) & 0xFFFF;
508 case ELF::R_RISCV_SUB16:
509 return (
A - (S +
RA)) & 0xFFFF;
510 case ELF::R_RISCV_SET32:
511 return (S +
RA) & 0xFFFFFFFF;
512 case ELF::R_RISCV_ADD32:
513 return (
A + (S +
RA)) & 0xFFFFFFFF;
514 case ELF::R_RISCV_SUB32:
515 return (
A - (S +
RA)) & 0xFFFFFFFF;
516 case ELF::R_RISCV_ADD64:
517 return (
A + (S +
RA));
518 case ELF::R_RISCV_SUB64:
519 return (
A - (S +
RA));
527 case ELF::R_CKCORE_NONE:
528 case ELF::R_CKCORE_ADDR32:
529 case ELF::R_CKCORE_PCREL32:
539 case ELF::R_CKCORE_NONE:
541 case ELF::R_CKCORE_ADDR32:
542 return (S + Addend) & 0xFFFFFFFF;
543 case ELF::R_CKCORE_PCREL32:
544 return (S + Addend -
Offset) & 0xFFFFFFFF;
552 case ELF::R_LARCH_NONE:
553 case ELF::R_LARCH_32:
554 case ELF::R_LARCH_32_PCREL:
555 case ELF::R_LARCH_64:
556 case ELF::R_LARCH_ADD6:
557 case ELF::R_LARCH_SUB6:
558 case ELF::R_LARCH_ADD8:
559 case ELF::R_LARCH_SUB8:
560 case ELF::R_LARCH_ADD16:
561 case ELF::R_LARCH_SUB16:
562 case ELF::R_LARCH_ADD32:
563 case ELF::R_LARCH_SUB32:
564 case ELF::R_LARCH_ADD64:
565 case ELF::R_LARCH_SUB64:
575 case ELF::R_LARCH_NONE:
577 case ELF::R_LARCH_32:
578 return (S + Addend) & 0xFFFFFFFF;
579 case ELF::R_LARCH_32_PCREL:
580 return (S + Addend -
Offset) & 0xFFFFFFFF;
581 case ELF::R_LARCH_64:
583 case ELF::R_LARCH_ADD6:
584 return (LocData & 0xC0) | ((LocData + S + Addend) & 0x3F);
585 case ELF::R_LARCH_SUB6:
586 return (LocData & 0xC0) | ((LocData - (S + Addend)) & 0x3F);
587 case ELF::R_LARCH_ADD8:
588 return (LocData + (S + Addend)) & 0xFF;
589 case ELF::R_LARCH_SUB8:
590 return (LocData - (S + Addend)) & 0xFF;
591 case ELF::R_LARCH_ADD16:
592 return (LocData + (S + Addend)) & 0xFFFF;
593 case ELF::R_LARCH_SUB16:
594 return (LocData - (S + Addend)) & 0xFFFF;
595 case ELF::R_LARCH_ADD32:
596 return (LocData + (S + Addend)) & 0xFFFFFFFF;
597 case ELF::R_LARCH_SUB32:
598 return (LocData - (S + Addend)) & 0xFFFFFFFF;
599 case ELF::R_LARCH_ADD64:
600 return (LocData + (S + Addend));
601 case ELF::R_LARCH_SUB64:
602 return (LocData - (S + Addend));
623 return (S + LocData) & 0xFFFFFFFF;
643 return (S + LocData) & 0xFFFFFFFF;
666 return (S + LocData) & 0xFFFFFFFF;
686 return (S + LocData) & 0xFFFFFFFF;
709 return (S + LocData) & 0xFFFFFFFF;
728 case wasm::R_WASM_FUNCTION_INDEX_LEB:
729 case wasm::R_WASM_TABLE_INDEX_SLEB:
730 case wasm::R_WASM_TABLE_INDEX_I32:
731 case wasm::R_WASM_MEMORY_ADDR_LEB:
732 case wasm::R_WASM_MEMORY_ADDR_SLEB:
733 case wasm::R_WASM_MEMORY_ADDR_I32:
734 case wasm::R_WASM_TYPE_INDEX_LEB:
735 case wasm::R_WASM_GLOBAL_INDEX_LEB:
736 case wasm::R_WASM_FUNCTION_OFFSET_I32:
737 case wasm::R_WASM_SECTION_OFFSET_I32:
738 case wasm::R_WASM_TAG_INDEX_LEB:
739 case wasm::R_WASM_GLOBAL_INDEX_I32:
740 case wasm::R_WASM_TABLE_NUMBER_LEB:
741 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
750 case wasm::R_WASM_MEMORY_ADDR_LEB64:
751 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
752 case wasm::R_WASM_MEMORY_ADDR_I64:
753 case wasm::R_WASM_TABLE_INDEX_SLEB64:
754 case wasm::R_WASM_TABLE_INDEX_I64:
755 case wasm::R_WASM_FUNCTION_OFFSET_I64:
756 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I64:
766 case wasm::R_WASM_FUNCTION_INDEX_LEB:
767 case wasm::R_WASM_TABLE_INDEX_SLEB:
768 case wasm::R_WASM_TABLE_INDEX_I32:
769 case wasm::R_WASM_MEMORY_ADDR_LEB:
770 case wasm::R_WASM_MEMORY_ADDR_SLEB:
771 case wasm::R_WASM_MEMORY_ADDR_I32:
772 case wasm::R_WASM_TYPE_INDEX_LEB:
773 case wasm::R_WASM_GLOBAL_INDEX_LEB:
774 case wasm::R_WASM_FUNCTION_OFFSET_I32:
775 case wasm::R_WASM_SECTION_OFFSET_I32:
776 case wasm::R_WASM_TAG_INDEX_LEB:
777 case wasm::R_WASM_GLOBAL_INDEX_I32:
778 case wasm::R_WASM_TABLE_NUMBER_LEB:
779 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
790 case wasm::R_WASM_MEMORY_ADDR_LEB64:
791 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
792 case wasm::R_WASM_MEMORY_ADDR_I64:
793 case wasm::R_WASM_TABLE_INDEX_SLEB64:
794 case wasm::R_WASM_TABLE_INDEX_I64:
795 case wasm::R_WASM_FUNCTION_OFFSET_I64:
796 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I64:
804std::pair<SupportsRelocation, RelocationResolver>
807 switch (Obj.getArch()) {
820 return {
nullptr,
nullptr};
822 }
else if (Obj.isELF()) {
823 if (Obj.getBytesInAddress() == 8) {
824 switch (Obj.getArch()) {
853 return {
nullptr,
nullptr};
858 assert(Obj.getBytesInAddress() == 4 &&
859 "Invalid word size in object file");
861 switch (Obj.getArch()) {
895 return {
nullptr,
nullptr};
897 }
else if (Obj.isMachO()) {
900 return {
nullptr,
nullptr};
901 }
else if (Obj.isWasm()) {
906 return {
nullptr,
nullptr};
917 auto GetRelSectionType = [&]() ->
unsigned {
919 return Elf32LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
921 return Elf64LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
923 return Elf32BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
925 return Elf64BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
942 return Resolver(R.getType(), R.getOffset(), S, LocData, Addend);
952 R.getRawDataRefImpl().p);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
SI optimize exec mask operations pre RA
Base class for error info classes.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
The instances of the Type class are immutable: once they are created, they are never changed.
Expected< int64_t > getAddend() const
This class is the base class for all object file types.
This is a value type class that represents a single relocation in the list of relocations in the obje...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static uint64_t resolveCOFFARM(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static bool supportsRISCV(uint64_t Type)
static bool supportsCOFFARM(uint64_t Type)
static uint64_t resolveCOFFARM64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static uint64_t resolveMips64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsCSKY(uint64_t Type)
static bool supportsLanai(uint64_t Type)
static uint64_t resolvePPC64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsMSP430(uint64_t Type)
static bool supportsLoongArch(uint64_t Type)
static uint64_t resolveCSKY(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static int64_t getELFAddend(RelocationRef R)
static uint64_t resolveAArch64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsWasm32(uint64_t Type)
LLVM_ABI uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, uint64_t S, uint64_t LocData)
static uint64_t resolveX86(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static uint64_t resolveWasm64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static bool supportsSystemZ(uint64_t Type)
static uint64_t resolveARM(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static bool supportsWasm64(uint64_t Type)
static bool supportsSparc64(uint64_t Type)
static bool supportsMips64(uint64_t Type)
uint64_t(*)(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend) RelocationResolver
static bool supportsMachOX86_64(uint64_t Type)
static uint64_t resolveLanai(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static uint64_t resolveCOFFX86(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static uint64_t resolveX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static uint64_t resolveMSP430(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsAmdgpu(uint64_t Type)
static bool supportsMips32(uint64_t Type)
static bool isAMDGPU(const ObjectFile &Obj)
Returns true if Obj is an AMDGPU code object based solely on the value of e_machine.
static bool supportsBPF(uint64_t Type)
static uint64_t resolvePPC32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static uint64_t resolveLoongArch(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static uint64_t resolveAmdgpu(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static uint64_t resolveHexagon(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
LLVM_ABI std::pair< SupportsRelocation, RelocationResolver > getRelocationResolver(const ObjectFile &Obj)
static bool supportsPPC32(uint64_t Type)
static uint64_t resolveSparc64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static uint64_t resolveAVR(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsCOFFX86_64(uint64_t Type)
static bool supportsARM(uint64_t Type)
static uint64_t resolveBPF(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static bool supportsAVR(uint64_t Type)
static uint64_t resolveWasm32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static bool supportsX86(uint64_t Type)
static uint64_t resolveCOFFX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static uint64_t resolveCOFFMIPS(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static uint64_t resolveRISCV(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static bool supportsHexagon(uint64_t Type)
static uint64_t resolveMachOX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static bool supportsAArch64(uint64_t Type)
static bool supportsX86_64(uint64_t Type)
static uint64_t resolveSparc32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static bool supportsPPC64(uint64_t Type)
static bool supportsCOFFMIPS(uint64_t Type)
static bool supportsCOFFARM64(uint64_t Type)
static bool supportsCOFFX86(uint64_t Type)
static uint64_t resolveMips32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static bool supportsSparc32(uint64_t Type)
static uint64_t resolveSystemZ(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.