35 report_fatal_error(Twine(EI.message()));
42 case ELF::R_X86_64_NONE:
43 case ELF::R_X86_64_64:
44 case ELF::R_X86_64_DTPOFF32:
45 case ELF::R_X86_64_DTPOFF64:
46 case ELF::R_X86_64_PC32:
47 case ELF::R_X86_64_PC64:
48 case ELF::R_X86_64_32:
49 case ELF::R_X86_64_32S:
59 case ELF::R_X86_64_NONE:
61 case ELF::R_X86_64_64:
62 case ELF::R_X86_64_DTPOFF32:
63 case ELF::R_X86_64_DTPOFF64:
65 case ELF::R_X86_64_PC32:
66 case ELF::R_X86_64_PC64:
67 return S + Addend -
Offset;
68 case ELF::R_X86_64_32:
69 case ELF::R_X86_64_32S:
70 return (S + Addend) & 0xFFFFFFFF;
78 case ELF::R_AARCH64_ABS32:
79 case ELF::R_AARCH64_ABS64:
80 case ELF::R_AARCH64_PREL16:
81 case ELF::R_AARCH64_PREL32:
82 case ELF::R_AARCH64_PREL64:
92 case ELF::R_AARCH64_ABS32:
93 return (S + Addend) & 0xFFFFFFFF;
94 case ELF::R_AARCH64_ABS64:
96 case ELF::R_AARCH64_PREL16:
97 return (S + Addend -
Offset) & 0xFFFF;
98 case ELF::R_AARCH64_PREL32:
99 return (S + Addend -
Offset) & 0xFFFFFFFF;
100 case ELF::R_AARCH64_PREL64:
101 return S + Addend -
Offset;
109 case ELF::R_BPF_64_ABS32:
110 case ELF::R_BPF_64_ABS64:
120 case ELF::R_BPF_64_ABS32:
121 return (S + LocData) & 0xFFFFFFFF;
122 case ELF::R_BPF_64_ABS64:
133 case ELF::R_MIPS_TLS_DTPREL64:
134 case ELF::R_MIPS_PC32:
145 return (S + Addend) & 0xFFFFFFFF;
148 case ELF::R_MIPS_TLS_DTPREL64:
149 return S + Addend - 0x8000;
150 case ELF::R_MIPS_PC32:
151 return S + Addend -
Offset;
159 case ELF::R_MSP430_32:
160 case ELF::R_MSP430_16_BYTE:
170 case ELF::R_MSP430_32:
171 return (S + Addend) & 0xFFFFFFFF;
172 case ELF::R_MSP430_16_BYTE:
173 return (S + Addend) & 0xFFFF;
181 case ELF::R_PPC64_ADDR32:
182 case ELF::R_PPC64_ADDR64:
183 case ELF::R_PPC64_REL32:
184 case ELF::R_PPC64_REL64:
194 case ELF::R_PPC64_ADDR32:
195 return (S + Addend) & 0xFFFFFFFF;
196 case ELF::R_PPC64_ADDR64:
198 case ELF::R_PPC64_REL32:
199 return (S + Addend -
Offset) & 0xFFFFFFFF;
200 case ELF::R_PPC64_REL64:
201 return S + Addend -
Offset;
221 return (S + Addend) & 0xFFFFFFFF;
231 case ELF::R_SPARC_32:
232 case ELF::R_SPARC_64:
233 case ELF::R_SPARC_UA32:
234 case ELF::R_SPARC_UA64:
244 case ELF::R_SPARC_32:
245 case ELF::R_SPARC_64:
246 case ELF::R_SPARC_UA32:
247 case ELF::R_SPARC_UA64:
262 if (
const auto *ELFObj = dyn_cast<ELFObjectFileBase>(&Obj))
269 case ELF::R_AMDGPU_ABS32:
270 case ELF::R_AMDGPU_ABS64:
280 case ELF::R_AMDGPU_ABS32:
281 case ELF::R_AMDGPU_ABS64:
290 case ELF::R_386_NONE:
292 case ELF::R_386_PC32:
302 case ELF::R_386_NONE:
306 case ELF::R_386_PC32:
307 return S -
Offset + LocData;
315 case ELF::R_PPC_ADDR32:
316 case ELF::R_PPC_REL32:
326 case ELF::R_PPC_ADDR32:
327 return (S + Addend) & 0xFFFFFFFF;
328 case ELF::R_PPC_REL32:
329 return (S + Addend -
Offset) & 0xFFFFFFFF;
336 case ELF::R_ARM_ABS32:
337 case ELF::R_ARM_REL32:
349 assert((LocData == 0 || Addend == 0) &&
350 "one of LocData and Addend must be 0");
352 case ELF::R_ARM_ABS32:
353 return (S + LocData + Addend) & 0xFFFFFFFF;
354 case ELF::R_ARM_REL32:
355 return (S + LocData + Addend -
Offset) & 0xFFFFFFFF;
374 return (S + Addend) & 0xFFFF;
376 return (S + Addend) & 0xFFFFFFFF;
383 return Type == ELF::R_LANAI_32;
388 if (
Type == ELF::R_LANAI_32)
389 return (S + Addend) & 0xFFFFFFFF;
396 case ELF::R_MIPS_TLS_DTPREL32:
406 if (
Type == ELF::R_MIPS_32)
407 return (S + LocData) & 0xFFFFFFFF;
408 if (
Type == ELF::R_MIPS_TLS_DTPREL32)
409 return (S + LocData) & 0xFFFFFFFF;
415 case ELF::R_SPARC_32:
416 case ELF::R_SPARC_UA32:
425 if (
Type == ELF::R_SPARC_32 ||
Type == ELF::R_SPARC_UA32)
431 return Type == ELF::R_HEX_32;
436 if (
Type == ELF::R_HEX_32)
443 case ELF::R_RISCV_NONE:
444 case ELF::R_RISCV_32:
445 case ELF::R_RISCV_32_PCREL:
446 case ELF::R_RISCV_64:
447 case ELF::R_RISCV_SET6:
448 case ELF::R_RISCV_SET8:
449 case ELF::R_RISCV_SUB6:
450 case ELF::R_RISCV_ADD8:
451 case ELF::R_RISCV_SUB8:
452 case ELF::R_RISCV_SET16:
453 case ELF::R_RISCV_ADD16:
454 case ELF::R_RISCV_SUB16:
455 case ELF::R_RISCV_SET32:
456 case ELF::R_RISCV_ADD32:
457 case ELF::R_RISCV_SUB32:
458 case ELF::R_RISCV_ADD64:
459 case ELF::R_RISCV_SUB64:
464 case ELF::R_RISCV_SET_ULEB128:
465 case ELF::R_RISCV_SUB_ULEB128:
477 case ELF::R_RISCV_NONE:
479 case ELF::R_RISCV_32:
480 return (S +
RA) & 0xFFFFFFFF;
481 case ELF::R_RISCV_32_PCREL:
482 return (S +
RA -
Offset) & 0xFFFFFFFF;
483 case ELF::R_RISCV_64:
485 case ELF::R_RISCV_SET6:
486 return (
A & 0xC0) | ((S +
RA) & 0x3F);
487 case ELF::R_RISCV_SUB6:
488 return (
A & 0xC0) | (((
A & 0x3F) - (S +
RA)) & 0x3F);
489 case ELF::R_RISCV_SET8:
490 return (S +
RA) & 0xFF;
491 case ELF::R_RISCV_ADD8:
492 return (
A + (S +
RA)) & 0xFF;
493 case ELF::R_RISCV_SUB8:
494 return (
A - (S +
RA)) & 0xFF;
495 case ELF::R_RISCV_SET16:
496 return (S +
RA) & 0xFFFF;
497 case ELF::R_RISCV_ADD16:
498 return (
A + (S +
RA)) & 0xFFFF;
499 case ELF::R_RISCV_SUB16:
500 return (
A - (S +
RA)) & 0xFFFF;
501 case ELF::R_RISCV_SET32:
502 return (S +
RA) & 0xFFFFFFFF;
503 case ELF::R_RISCV_ADD32:
504 return (
A + (S +
RA)) & 0xFFFFFFFF;
505 case ELF::R_RISCV_SUB32:
506 return (
A - (S +
RA)) & 0xFFFFFFFF;
507 case ELF::R_RISCV_ADD64:
508 return (
A + (S +
RA));
509 case ELF::R_RISCV_SUB64:
510 return (
A - (S +
RA));
518 case ELF::R_CKCORE_NONE:
519 case ELF::R_CKCORE_ADDR32:
520 case ELF::R_CKCORE_PCREL32:
530 case ELF::R_CKCORE_NONE:
532 case ELF::R_CKCORE_ADDR32:
533 return (S + Addend) & 0xFFFFFFFF;
534 case ELF::R_CKCORE_PCREL32:
535 return (S + Addend -
Offset) & 0xFFFFFFFF;
543 case ELF::R_LARCH_NONE:
544 case ELF::R_LARCH_32:
545 case ELF::R_LARCH_32_PCREL:
546 case ELF::R_LARCH_64:
547 case ELF::R_LARCH_ADD6:
548 case ELF::R_LARCH_SUB6:
549 case ELF::R_LARCH_ADD8:
550 case ELF::R_LARCH_SUB8:
551 case ELF::R_LARCH_ADD16:
552 case ELF::R_LARCH_SUB16:
553 case ELF::R_LARCH_ADD32:
554 case ELF::R_LARCH_SUB32:
555 case ELF::R_LARCH_ADD64:
556 case ELF::R_LARCH_SUB64:
566 case ELF::R_LARCH_NONE:
568 case ELF::R_LARCH_32:
569 return (S + Addend) & 0xFFFFFFFF;
570 case ELF::R_LARCH_32_PCREL:
571 return (S + Addend -
Offset) & 0xFFFFFFFF;
572 case ELF::R_LARCH_64:
574 case ELF::R_LARCH_ADD6:
575 return (LocData & 0xC0) | ((LocData + S + Addend) & 0x3F);
576 case ELF::R_LARCH_SUB6:
577 return (LocData & 0xC0) | ((LocData - (S + Addend)) & 0x3F);
578 case ELF::R_LARCH_ADD8:
579 return (LocData + (S + Addend)) & 0xFF;
580 case ELF::R_LARCH_SUB8:
581 return (LocData - (S + Addend)) & 0xFF;
582 case ELF::R_LARCH_ADD16:
583 return (LocData + (S + Addend)) & 0xFFFF;
584 case ELF::R_LARCH_SUB16:
585 return (LocData - (S + Addend)) & 0xFFFF;
586 case ELF::R_LARCH_ADD32:
587 return (LocData + (S + Addend)) & 0xFFFFFFFF;
588 case ELF::R_LARCH_SUB32:
589 return (LocData - (S + Addend)) & 0xFFFFFFFF;
590 case ELF::R_LARCH_ADD64:
591 return (LocData + (S + Addend));
592 case ELF::R_LARCH_SUB64:
593 return (LocData - (S + Addend));
614 return (S + LocData) & 0xFFFFFFFF;
634 return (S + LocData) & 0xFFFFFFFF;
657 return (S + LocData) & 0xFFFFFFFF;
677 return (S + LocData) & 0xFFFFFFFF;
698 case wasm::R_WASM_FUNCTION_INDEX_LEB:
699 case wasm::R_WASM_TABLE_INDEX_SLEB:
700 case wasm::R_WASM_TABLE_INDEX_I32:
701 case wasm::R_WASM_MEMORY_ADDR_LEB:
702 case wasm::R_WASM_MEMORY_ADDR_SLEB:
703 case wasm::R_WASM_MEMORY_ADDR_I32:
704 case wasm::R_WASM_TYPE_INDEX_LEB:
705 case wasm::R_WASM_GLOBAL_INDEX_LEB:
706 case wasm::R_WASM_FUNCTION_OFFSET_I32:
707 case wasm::R_WASM_SECTION_OFFSET_I32:
708 case wasm::R_WASM_TAG_INDEX_LEB:
709 case wasm::R_WASM_GLOBAL_INDEX_I32:
710 case wasm::R_WASM_TABLE_NUMBER_LEB:
711 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
720 case wasm::R_WASM_MEMORY_ADDR_LEB64:
721 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
722 case wasm::R_WASM_MEMORY_ADDR_I64:
723 case wasm::R_WASM_TABLE_INDEX_SLEB64:
724 case wasm::R_WASM_TABLE_INDEX_I64:
725 case wasm::R_WASM_FUNCTION_OFFSET_I64:
735 case wasm::R_WASM_FUNCTION_INDEX_LEB:
736 case wasm::R_WASM_TABLE_INDEX_SLEB:
737 case wasm::R_WASM_TABLE_INDEX_I32:
738 case wasm::R_WASM_MEMORY_ADDR_LEB:
739 case wasm::R_WASM_MEMORY_ADDR_SLEB:
740 case wasm::R_WASM_MEMORY_ADDR_I32:
741 case wasm::R_WASM_TYPE_INDEX_LEB:
742 case wasm::R_WASM_GLOBAL_INDEX_LEB:
743 case wasm::R_WASM_FUNCTION_OFFSET_I32:
744 case wasm::R_WASM_SECTION_OFFSET_I32:
745 case wasm::R_WASM_TAG_INDEX_LEB:
746 case wasm::R_WASM_GLOBAL_INDEX_I32:
747 case wasm::R_WASM_TABLE_NUMBER_LEB:
748 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
759 case wasm::R_WASM_MEMORY_ADDR_LEB64:
760 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
761 case wasm::R_WASM_MEMORY_ADDR_I64:
762 case wasm::R_WASM_TABLE_INDEX_SLEB64:
763 case wasm::R_WASM_TABLE_INDEX_I64:
764 case wasm::R_WASM_FUNCTION_OFFSET_I64:
772std::pair<SupportsRelocation, RelocationResolver>
786 return {
nullptr,
nullptr};
788 }
else if (Obj.
isELF()) {
818 return {
nullptr,
nullptr};
824 "Invalid word size in object file");
859 return {
nullptr,
nullptr};
864 return {
nullptr,
nullptr};
865 }
else if (Obj.
isWasm()) {
870 return {
nullptr,
nullptr};
881 auto GetRelSectionType = [&]() ->
unsigned {
882 if (
auto *Elf32LEObj = dyn_cast<ELF32LEObjectFile>(Obj))
883 return Elf32LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
884 if (
auto *Elf64LEObj = dyn_cast<ELF64LEObjectFile>(Obj))
885 return Elf64LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
886 if (
auto *Elf32BEObj = dyn_cast<ELF32BEObjectFile>(Obj))
887 return Elf32BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
888 auto *Elf64BEObj = cast<ELF64BEObjectFile>(Obj);
889 return Elf64BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
903 return Resolver(R.getType(), R.getOffset(), S, LocData, Addend);
913 R.getRawDataRefImpl().p);
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 uint64_t resolveAmdgpu(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsWasm32(uint64_t Type)
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 resolveHexagon(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
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...