Go to the documentation of this file.
36 report_fatal_error(Twine(EI.message()));
43 case ELF::R_X86_64_NONE:
44 case ELF::R_X86_64_64:
45 case ELF::R_X86_64_DTPOFF32:
46 case ELF::R_X86_64_DTPOFF64:
47 case ELF::R_X86_64_PC32:
48 case ELF::R_X86_64_PC64:
49 case ELF::R_X86_64_32:
50 case ELF::R_X86_64_32S:
60 case ELF::R_X86_64_NONE:
62 case ELF::R_X86_64_64:
63 case ELF::R_X86_64_DTPOFF32:
64 case ELF::R_X86_64_DTPOFF64:
66 case ELF::R_X86_64_PC32:
67 case ELF::R_X86_64_PC64:
68 return S + Addend - Offset;
69 case ELF::R_X86_64_32:
70 case ELF::R_X86_64_32S:
71 return (
S + Addend) & 0xFFFFFFFF;
79 case ELF::R_AARCH64_ABS32:
80 case ELF::R_AARCH64_ABS64:
81 case ELF::R_AARCH64_PREL16:
82 case ELF::R_AARCH64_PREL32:
83 case ELF::R_AARCH64_PREL64:
93 case ELF::R_AARCH64_ABS32:
94 return (
S + Addend) & 0xFFFFFFFF;
95 case ELF::R_AARCH64_ABS64:
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:
245 case ELF::R_SPARC_32:
246 case ELF::R_SPARC_64:
247 case ELF::R_SPARC_UA32:
248 case ELF::R_SPARC_UA64:
257 case ELF::R_AMDGPU_ABS32:
258 case ELF::R_AMDGPU_ABS64:
268 case ELF::R_AMDGPU_ABS32:
269 case ELF::R_AMDGPU_ABS64:
278 case ELF::R_386_NONE:
280 case ELF::R_386_PC32:
290 case ELF::R_386_NONE:
294 case ELF::R_386_PC32:
295 return S - Offset + LocData;
303 case ELF::R_PPC_ADDR32:
304 case ELF::R_PPC_REL32:
314 case ELF::R_PPC_ADDR32:
315 return (
S + Addend) & 0xFFFFFFFF;
316 case ELF::R_PPC_REL32:
317 return (
S + Addend - Offset) & 0xFFFFFFFF;
324 case ELF::R_ARM_ABS32:
325 case ELF::R_ARM_REL32:
337 assert((LocData == 0 || Addend == 0) &&
338 "one of LocData and Addend must be 0");
340 case ELF::R_ARM_ABS32:
341 return (
S + LocData + Addend) & 0xFFFFFFFF;
342 case ELF::R_ARM_REL32:
343 return (
S + LocData + Addend - Offset) & 0xFFFFFFFF;
362 return (
S + Addend) & 0xFFFF;
364 return (
S + Addend) & 0xFFFFFFFF;
371 return Type == ELF::R_LANAI_32;
376 if (
Type == ELF::R_LANAI_32)
377 return (
S + Addend) & 0xFFFFFFFF;
384 case ELF::R_MIPS_TLS_DTPREL32:
394 if (
Type == ELF::R_MIPS_32)
395 return (
S + LocData) & 0xFFFFFFFF;
396 if (
Type == ELF::R_MIPS_TLS_DTPREL32)
397 return (
S + LocData) & 0xFFFFFFFF;
403 case ELF::R_SPARC_32:
404 case ELF::R_SPARC_UA32:
413 if (
Type == ELF::R_SPARC_32 ||
Type == ELF::R_SPARC_UA32)
419 return Type == ELF::R_HEX_32;
424 if (
Type == ELF::R_HEX_32)
431 case ELF::R_RISCV_NONE:
456 case ELF::R_RISCV_NONE:
459 return (
S +
RA) & 0xFFFFFFFF;
461 return (
S +
RA - Offset) & 0xFFFFFFFF;
465 return (A & 0xC0) | ((
S +
RA) & 0x3F);
467 return (A & 0xC0) | (((A & 0x3F) - (
S +
RA)) & 0x3F);
469 return (A + (
S +
RA)) & 0xFF;
471 return (A - (
S +
RA)) & 0xFF;
473 return (A + (
S +
RA)) & 0xFFFF;
475 return (A - (
S +
RA)) & 0xFFFF;
477 return (A + (
S +
RA)) & 0xFFFFFFFF;
479 return (A - (
S +
RA)) & 0xFFFFFFFF;
481 return (A + (
S +
RA));
483 return (A - (
S +
RA));
491 case ELF::R_CKCORE_NONE:
492 case ELF::R_CKCORE_ADDR32:
493 case ELF::R_CKCORE_PCREL32:
503 case ELF::R_CKCORE_NONE:
505 case ELF::R_CKCORE_ADDR32:
506 return (
S + Addend) & 0xFFFFFFFF;
507 case ELF::R_CKCORE_PCREL32:
508 return (
S + Addend - Offset) & 0xFFFFFFFF;
529 return (
S + LocData) & 0xFFFFFFFF;
549 return (
S + LocData) & 0xFFFFFFFF;
572 return (
S + LocData) & 0xFFFFFFFF;
592 return (
S + LocData) & 0xFFFFFFFF;
613 case wasm::R_WASM_FUNCTION_INDEX_LEB:
614 case wasm::R_WASM_TABLE_INDEX_SLEB:
615 case wasm::R_WASM_TABLE_INDEX_I32:
616 case wasm::R_WASM_MEMORY_ADDR_LEB:
617 case wasm::R_WASM_MEMORY_ADDR_SLEB:
618 case wasm::R_WASM_MEMORY_ADDR_I32:
619 case wasm::R_WASM_TYPE_INDEX_LEB:
620 case wasm::R_WASM_GLOBAL_INDEX_LEB:
621 case wasm::R_WASM_FUNCTION_OFFSET_I32:
622 case wasm::R_WASM_SECTION_OFFSET_I32:
623 case wasm::R_WASM_TAG_INDEX_LEB:
624 case wasm::R_WASM_GLOBAL_INDEX_I32:
625 case wasm::R_WASM_TABLE_NUMBER_LEB:
626 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
635 case wasm::R_WASM_MEMORY_ADDR_LEB64:
636 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
637 case wasm::R_WASM_MEMORY_ADDR_I64:
638 case wasm::R_WASM_TABLE_INDEX_SLEB64:
639 case wasm::R_WASM_TABLE_INDEX_I64:
640 case wasm::R_WASM_FUNCTION_OFFSET_I64:
650 case wasm::R_WASM_FUNCTION_INDEX_LEB:
651 case wasm::R_WASM_TABLE_INDEX_SLEB:
652 case wasm::R_WASM_TABLE_INDEX_I32:
653 case wasm::R_WASM_MEMORY_ADDR_LEB:
654 case wasm::R_WASM_MEMORY_ADDR_SLEB:
655 case wasm::R_WASM_MEMORY_ADDR_I32:
656 case wasm::R_WASM_TYPE_INDEX_LEB:
657 case wasm::R_WASM_GLOBAL_INDEX_LEB:
658 case wasm::R_WASM_FUNCTION_OFFSET_I32:
659 case wasm::R_WASM_SECTION_OFFSET_I32:
660 case wasm::R_WASM_TAG_INDEX_LEB:
661 case wasm::R_WASM_GLOBAL_INDEX_I32:
662 case wasm::R_WASM_TABLE_NUMBER_LEB:
663 case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
674 case wasm::R_WASM_MEMORY_ADDR_LEB64:
675 case wasm::R_WASM_MEMORY_ADDR_SLEB64:
676 case wasm::R_WASM_MEMORY_ADDR_I64:
677 case wasm::R_WASM_TABLE_INDEX_SLEB64:
678 case wasm::R_WASM_TABLE_INDEX_I64:
679 case wasm::R_WASM_FUNCTION_OFFSET_I64:
687 std::pair<SupportsRelocation, RelocationResolver>
701 return {
nullptr,
nullptr};
703 }
else if (Obj.
isELF()) {
729 return {
nullptr,
nullptr};
735 "Invalid word size in object file");
764 return {
nullptr,
nullptr};
769 return {
nullptr,
nullptr};
770 }
else if (Obj.
isWasm()) {
775 return {
nullptr,
nullptr};
786 auto GetRelSectionType = [&]() ->
unsigned {
787 if (
auto *Elf32LEObj = dyn_cast<ELF32LEObjectFile>(Obj))
788 return Elf32LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
789 if (
auto *Elf64LEObj = dyn_cast<ELF64LEObjectFile>(Obj))
790 return Elf64LEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
791 if (
auto *Elf32BEObj = dyn_cast<ELF32BEObjectFile>(Obj))
792 return Elf32BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
793 auto *Elf64BEObj = cast<ELF64BEObjectFile>(Obj);
794 return Elf64BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
806 return Resolver(R.getType(), R.getOffset(),
S, LocData, Addend);
816 R.getRawDataRefImpl().p);
static uint64_t resolveSystemZ(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 supportsRISCV(uint64_t Type)
This is an optimization pass for GlobalISel generic memory operations.
static bool supportsAVR(uint64_t Type)
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
static uint64_t resolveAArch64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
uint64_t(*)(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend) RelocationResolver
static bool supportsCSKY(uint64_t Type)
@ R_RISCV_SET6
Local label assignment.
static bool supportsMSP430(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)
The instances of the Type class are immutable: once they are created, they are never changed.
static uint64_t resolveARM(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static uint64_t resolveCOFFX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
@ R_RISCV_ADD8
8 bits label addition
virtual Triple::ArchType getArch() const =0
@ R_RISCV_64
A plain 64-bit pointer value relocation.
static uint64_t resolveX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
Tagged union holding either a T or a Error.
static bool supportsCOFFARM64(uint64_t Type)
static bool supportsMachOX86_64(uint64_t Type)
static uint64_t resolveSparc64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
@ R_RISCV_SUB64
64 bits label subtraction
static bool supportsBPF(uint64_t Type)
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
static bool supportsMips32(uint64_t Type)
static uint64_t resolveBPF(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static bool supportsCOFFARM(uint64_t Type)
static bool supportsSparc64(uint64_t Type)
static uint64_t resolvePPC32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsWasm64(uint64_t Type)
static uint64_t resolveWasm32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
@ R_RISCV_32
A plain 32-bit pointer value relocation.
static bool supportsX86_64(uint64_t Type)
static uint64_t resolveAVR(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Base class for error info classes.
static uint64_t resolveMips64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static bool supportsARM(uint64_t Type)
static uint64_t resolveHexagon(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
bar al al movzbl eax ret Missed when stored in a memory object
static uint64_t resolveRISCV(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static bool supportsCOFFX86_64(uint64_t Type)
static bool supportsSparc32(uint64_t Type)
@ R_RISCV_ADD16
16 bits label addition
static bool supportsSystemZ(uint64_t Type)
@ R_RISCV_ADD32
32 bits label addition
static bool supportsLanai(uint64_t Type)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
@ R_RISCV_SUB6
6 bits label subtraction
static bool supportsX86(uint64_t Type)
SI optimize exec mask operations pre RA
std::pair< SupportsRelocation, RelocationResolver > getRelocationResolver(const ObjectFile &Obj)
static bool supportsPPC64(uint64_t Type)
@ R_RISCV_SUB8
8 bits label subtraction
static uint64_t resolveMSP430(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
static uint64_t resolveMips32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static uint64_t resolveX86(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
This class is the base class for all object file types.
static bool supportsPPC32(uint64_t Type)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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
static bool supportsMips64(uint64_t Type)
static uint64_t resolveCOFFARM64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
static uint64_t resolveMachOX86_64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
@ R_RISCV_ADD64
64 bits label addition
static uint64_t resolveWasm64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
@ R_RISCV_32_PCREL
32 bits PC relative relocation
static bool supportsWasm32(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 resolvePPC64(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t, int64_t Addend)
Error takeError()
Take ownership of the stored error.
static bool supportsAArch64(uint64_t Type)
static uint64_t resolveSparc32(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend)
static uint64_t resolveCOFFARM(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t)
This is a value type class that represents a single relocation in the list of relocations in the obje...
@ R_RISCV_SUB32
32 bits label subtraction
static bool supportsHexagon(uint64_t Type)
Expected< int64_t > getAddend() const
static bool supportsAmdgpu(uint64_t 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...
static bool supportsCOFFX86(uint64_t Type)
uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, uint64_t S, uint64_t LocData)
@ R_RISCV_SUB16
16 bits label subtraction