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:
91 case ELF::R_AARCH64_ABS32:
92 return (S + Addend) & 0xFFFFFFFF;
93 case ELF::R_AARCH64_ABS64:
95 case ELF::R_AARCH64_PREL16:
96 return (S + Addend -
Offset) & 0xFFFF;
97 case ELF::R_AARCH64_PREL32:
98 return (S + Addend -
Offset) & 0xFFFFFFFF;
99 case ELF::R_AARCH64_PREL64:
100 return S + Addend -
Offset;
108 case ELF::R_BPF_64_ABS32:
109 case ELF::R_BPF_64_ABS64:
119 case ELF::R_BPF_64_ABS32:
120 return (S + LocData) & 0xFFFFFFFF;
121 case ELF::R_BPF_64_ABS64:
132 case ELF::R_MIPS_TLS_DTPREL64:
133 case ELF::R_MIPS_PC32:
144 return (S + Addend) & 0xFFFFFFFF;
147 case ELF::R_MIPS_TLS_DTPREL64:
148 return S + Addend - 0x8000;
149 case ELF::R_MIPS_PC32:
150 return S + Addend -
Offset;
158 case ELF::R_MSP430_32:
159 case ELF::R_MSP430_16_BYTE:
169 case ELF::R_MSP430_32:
170 return (S + Addend) & 0xFFFFFFFF;
171 case ELF::R_MSP430_16_BYTE:
172 return (S + Addend) & 0xFFFF;
180 case ELF::R_PPC64_ADDR32:
181 case ELF::R_PPC64_ADDR64:
182 case ELF::R_PPC64_REL32:
183 case ELF::R_PPC64_REL64:
193 case ELF::R_PPC64_ADDR32:
194 return (S + Addend) & 0xFFFFFFFF;
195 case ELF::R_PPC64_ADDR64:
197 case ELF::R_PPC64_REL32:
198 return (S + Addend -
Offset) & 0xFFFFFFFF;
199 case ELF::R_PPC64_REL64:
200 return S + Addend -
Offset;
220 return (S + Addend) & 0xFFFFFFFF;
230 case ELF::R_SPARC_32:
231 case ELF::R_SPARC_64:
232 case ELF::R_SPARC_UA32:
233 case ELF::R_SPARC_UA64:
243 case ELF::R_SPARC_32:
244 case ELF::R_SPARC_64:
245 case ELF::R_SPARC_UA32:
246 case ELF::R_SPARC_UA64:
261 if (
const auto *ELFObj = dyn_cast<ELFObjectFileBase>(&Obj))
268 case ELF::R_AMDGPU_ABS32:
269 case ELF::R_AMDGPU_ABS64:
278 assert((LocData == 0 || Addend == 0) &&
279 "one of LocData and Addend must be 0");
281 case ELF::R_AMDGPU_ABS32:
282 case ELF::R_AMDGPU_ABS64:
283 return S + LocData + Addend;
291 case ELF::R_386_NONE:
293 case ELF::R_386_PC32:
303 case ELF::R_386_NONE:
307 case ELF::R_386_PC32:
308 return S -
Offset + LocData;
316 case ELF::R_PPC_ADDR32:
317 case ELF::R_PPC_REL32:
327 case ELF::R_PPC_ADDR32:
328 return (S + Addend) & 0xFFFFFFFF;
329 case ELF::R_PPC_REL32:
330 return (S + Addend -
Offset) & 0xFFFFFFFF;
337 case ELF::R_ARM_ABS32:
338 case ELF::R_ARM_REL32:
350 assert((LocData == 0 || Addend == 0) &&
351 "one of LocData and Addend must be 0");
353 case ELF::R_ARM_ABS32:
354 return (S + LocData + Addend) & 0xFFFFFFFF;
355 case ELF::R_ARM_REL32:
356 return (S + LocData + Addend -
Offset) & 0xFFFFFFFF;
375 return (S + Addend) & 0xFFFF;
377 return (S + Addend) & 0xFFFFFFFF;
384 return Type == ELF::R_LANAI_32;
389 if (
Type == ELF::R_LANAI_32)
390 return (S + Addend) & 0xFFFFFFFF;
397 case ELF::R_MIPS_TLS_DTPREL32:
407 if (
Type == ELF::R_MIPS_32)
408 return (S + LocData) & 0xFFFFFFFF;
409 if (
Type == ELF::R_MIPS_TLS_DTPREL32)
410 return (S + LocData) & 0xFFFFFFFF;
416 case ELF::R_SPARC_32:
417 case ELF::R_SPARC_UA32:
426 if (
Type == ELF::R_SPARC_32 ||
Type == ELF::R_SPARC_UA32)
432 return Type == ELF::R_HEX_32;
437 if (
Type == ELF::R_HEX_32)
444 case ELF::R_RISCV_NONE:
445 case ELF::R_RISCV_32:
446 case ELF::R_RISCV_32_PCREL:
447 case ELF::R_RISCV_64:
448 case ELF::R_RISCV_SET6:
449 case ELF::R_RISCV_SET8:
450 case ELF::R_RISCV_SUB6:
451 case ELF::R_RISCV_ADD8:
452 case ELF::R_RISCV_SUB8:
453 case ELF::R_RISCV_SET16:
454 case ELF::R_RISCV_ADD16:
455 case ELF::R_RISCV_SUB16:
456 case ELF::R_RISCV_SET32:
457 case ELF::R_RISCV_ADD32:
458 case ELF::R_RISCV_SUB32:
459 case ELF::R_RISCV_ADD64:
460 case ELF::R_RISCV_SUB64:
465 case ELF::R_RISCV_SET_ULEB128:
466 case ELF::R_RISCV_SUB_ULEB128:
478 case ELF::R_RISCV_NONE:
480 case ELF::R_RISCV_32:
481 return (S +
RA) & 0xFFFFFFFF;
482 case ELF::R_RISCV_32_PCREL:
483 return (S +
RA -
Offset) & 0xFFFFFFFF;
484 case ELF::R_RISCV_64:
486 case ELF::R_RISCV_SET6:
487 return (
A & 0xC0) | ((S +
RA) & 0x3F);
488 case ELF::R_RISCV_SUB6:
489 return (
A & 0xC0) | (((
A & 0x3F) - (S +
RA)) & 0x3F);
490 case ELF::R_RISCV_SET8:
491 return (S +
RA) & 0xFF;
492 case ELF::R_RISCV_ADD8:
493 return (
A + (S +
RA)) & 0xFF;
494 case ELF::R_RISCV_SUB8:
495 return (
A - (S +
RA)) & 0xFF;
496 case ELF::R_RISCV_SET16:
497 return (S +
RA) & 0xFFFF;
498 case ELF::R_RISCV_ADD16:
499 return (
A + (S +
RA)) & 0xFFFF;
500 case ELF::R_RISCV_SUB16:
501 return (
A - (S +
RA)) & 0xFFFF;
502 case ELF::R_RISCV_SET32:
503 return (S +
RA) & 0xFFFFFFFF;
504 case ELF::R_RISCV_ADD32:
505 return (
A + (S +
RA)) & 0xFFFFFFFF;
506 case ELF::R_RISCV_SUB32:
507 return (
A - (S +
RA)) & 0xFFFFFFFF;
508 case ELF::R_RISCV_ADD64:
509 return (
A + (S +
RA));
510 case ELF::R_RISCV_SUB64:
511 return (
A - (S +
RA));
519 case ELF::R_CKCORE_NONE:
520 case ELF::R_CKCORE_ADDR32:
521 case ELF::R_CKCORE_PCREL32:
531 case ELF::R_CKCORE_NONE:
533 case ELF::R_CKCORE_ADDR32:
534 return (S + Addend) & 0xFFFFFFFF;
535 case ELF::R_CKCORE_PCREL32:
536 return (S + Addend -
Offset) & 0xFFFFFFFF;
544 case ELF::R_LARCH_NONE:
545 case ELF::R_LARCH_32:
546 case ELF::R_LARCH_32_PCREL:
547 case ELF::R_LARCH_64:
548 case ELF::R_LARCH_ADD6:
549 case ELF::R_LARCH_SUB6:
550 case ELF::R_LARCH_ADD8:
551 case ELF::R_LARCH_SUB8:
552 case ELF::R_LARCH_ADD16:
553 case ELF::R_LARCH_SUB16:
554 case ELF::R_LARCH_ADD32:
555 case ELF::R_LARCH_SUB32:
556 case ELF::R_LARCH_ADD64:
557 case ELF::R_LARCH_SUB64:
567 case ELF::R_LARCH_NONE:
569 case ELF::R_LARCH_32:
570 return (S + Addend) & 0xFFFFFFFF;
571 case ELF::R_LARCH_32_PCREL:
572 return (S + Addend -
Offset) & 0xFFFFFFFF;
573 case ELF::R_LARCH_64:
575 case ELF::R_LARCH_ADD6:
576 return (LocData & 0xC0) | ((LocData + S + Addend) & 0x3F);
577 case ELF::R_LARCH_SUB6:
578 return (LocData & 0xC0) | ((LocData - (S + Addend)) & 0x3F);
579 case ELF::R_LARCH_ADD8:
580 return (LocData + (S + Addend)) & 0xFF;
581 case ELF::R_LARCH_SUB8:
582 return (LocData - (S + Addend)) & 0xFF;
583 case ELF::R_LARCH_ADD16:
584 return (LocData + (S + Addend)) & 0xFFFF;
585 case ELF::R_LARCH_SUB16:
586 return (LocData - (S + Addend)) & 0xFFFF;
587 case ELF::R_LARCH_ADD32:
588 return (LocData + (S + Addend)) & 0xFFFFFFFF;
589 case ELF::R_LARCH_SUB32:
590 return (LocData - (S + Addend)) & 0xFFFFFFFF;
591 case ELF::R_LARCH_ADD64:
592 return (LocData + (S + Addend));
593 case ELF::R_LARCH_SUB64:
594 return (LocData - (S + Addend));
615 return (S + LocData) & 0xFFFFFFFF;
635 return (S + LocData) & 0xFFFFFFFF;
658 return (S + LocData) & 0xFFFFFFFF;
678 return (S + LocData) & 0xFFFFFFFF;
699 case wasm::R_WASM_FUNCTION_INDEX_LEB:
700 case wasm::R_WASM_TABLE_INDEX_SLEB:
701 case wasm::R_WASM_TABLE_INDEX_I32:
702 case wasm::R_WASM_MEMORY_ADDR_LEB:
703 case wasm::R_WASM_MEMORY_ADDR_SLEB:
704 case wasm::R_WASM_MEMORY_ADDR_I32:
705 case wasm::R_WASM_TYPE_INDEX_LEB:
706 case wasm::R_WASM_GLOBAL_INDEX_LEB:
707 case wasm::R_WASM_FUNCTION_OFFSET_I32:
708 case wasm::R_WASM_SECTION_OFFSET_I32:
709 case wasm::R_WASM_TAG_INDEX_LEB:
710 case wasm::R_WASM_GLOBAL_INDEX_I32:
711 case wasm::R_WASM_TABLE_NUMBER_LEB:
712 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
721 case wasm::R_WASM_MEMORY_ADDR_LEB64:
722 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
723 case wasm::R_WASM_MEMORY_ADDR_I64:
724 case wasm::R_WASM_TABLE_INDEX_SLEB64:
725 case wasm::R_WASM_TABLE_INDEX_I64:
726 case wasm::R_WASM_FUNCTION_OFFSET_I64:
736 case wasm::R_WASM_FUNCTION_INDEX_LEB:
737 case wasm::R_WASM_TABLE_INDEX_SLEB:
738 case wasm::R_WASM_TABLE_INDEX_I32:
739 case wasm::R_WASM_MEMORY_ADDR_LEB:
740 case wasm::R_WASM_MEMORY_ADDR_SLEB:
741 case wasm::R_WASM_MEMORY_ADDR_I32:
742 case wasm::R_WASM_TYPE_INDEX_LEB:
743 case wasm::R_WASM_GLOBAL_INDEX_LEB:
744 case wasm::R_WASM_FUNCTION_OFFSET_I32:
745 case wasm::R_WASM_SECTION_OFFSET_I32:
746 case wasm::R_WASM_TAG_INDEX_LEB:
747 case wasm::R_WASM_GLOBAL_INDEX_I32:
748 case wasm::R_WASM_TABLE_NUMBER_LEB:
749 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
760 case wasm::R_WASM_MEMORY_ADDR_LEB64:
761 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
762 case wasm::R_WASM_MEMORY_ADDR_I64:
763 case wasm::R_WASM_TABLE_INDEX_SLEB64:
764 case wasm::R_WASM_TABLE_INDEX_I64:
765 case wasm::R_WASM_FUNCTION_OFFSET_I64:
773std::pair<SupportsRelocation, RelocationResolver>
787 return {
nullptr,
nullptr};
789 }
else if (Obj.
isELF()) {
820 return {
nullptr,
nullptr};
826 "Invalid word size in object file");
862 return {
nullptr,
nullptr};
867 return {
nullptr,
nullptr};
868 }
else if (Obj.
isWasm()) {
873 return {
nullptr,
nullptr};
884 auto GetRelSectionType = [&]() ->
unsigned {
885 if (
auto *Elf32LEObj = dyn_cast<ELF32LEObjectFile>(Obj))
886 return Elf32LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
887 if (
auto *Elf64LEObj = dyn_cast<ELF64LEObjectFile>(Obj))
888 return Elf64LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
889 if (
auto *Elf32BEObj = dyn_cast<ELF32BEObjectFile>(Obj))
890 return Elf32BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
891 auto *Elf64BEObj = cast<ELF64BEObjectFile>(Obj);
892 return Elf64BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
909 return Resolver(R.getType(), R.getOffset(), S, LocData, Addend);
919 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.
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
virtual Triple::ArchType getArch() const =0
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)
uint64_t(*)(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend) RelocationResolver
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)
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 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 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.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...