36 bool getAArch64FixupKindMachOInfo(
const MCFixup &
Fixup,
unsigned &RelocType,
51bool AArch64MachObjectWriter::getAArch64FixupKindMachOInfo(
57 switch (
Fixup.getTargetKind()) {
84 switch (
Sym->getKind()) {
100 switch (
Sym->getKind()) {
102 Asm.getContext().reportError(
Fixup.getLoc(),
103 "ADR/ADRP relocations must be GOT relative");
125 const MCSymbol &Symbol,
unsigned Log2Size) {
135 if (!Symbol.isInSection())
137 const MCSectionMachO &RefSec = cast<MCSectionMachO>(Symbol.getSection());
142 (RefSec.
getName() ==
"__cfstring" ||
143 RefSec.
getName() ==
"__objc_classrefs"))
149void AArch64MachObjectWriter::recordRelocation(
155 uint32_t FixupOffset =
Asm.getFragmentOffset(*Fragment);
156 unsigned Log2Size = 0;
161 const MCSymbol *RelSymbol =
nullptr;
163 FixupOffset +=
Fixup.getOffset();
167 FixedValue += FixupOffset;
179 Asm.getContext().reportError(
Fixup.getLoc(),
180 "conditional branch requires assembler-local"
190 Asm.getContext().reportError(
Fixup.getLoc(),
191 "Invalid relocation on conditional branch!");
195 if (!getAArch64FixupKindMachOInfo(
Fixup,
Type,
Target.getSymA(), Log2Size,
197 Asm.getContext().reportError(
Fixup.getLoc(),
"unknown AArch64 fixup kind!");
203 if (
Target.isAbsolute()) {
209 Asm.getContext().reportError(
Fixup.getLoc(),
210 "PC relative absolute relocation!");
216 }
else if (
Target.getSymB()) {
228 Asm.getSymbolOffset(*
B) ==
229 Asm.getFragmentOffset(*Fragment) +
Fixup.getOffset()) {
235 MRE.
r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
241 Asm.getContext().reportError(
Fixup.getLoc(),
242 "unsupported relocation of modified symbol");
248 Asm.getContext().reportError(
Fixup.getLoc(),
249 "unsupported pc-relative relocation of "
261 Asm.getContext().reportError(
263 "unsupported relocation of local symbol '" +
A->getName() +
264 "'. Must have non-local symbol earlier in section.");
268 Asm.getContext().reportError(
270 "unsupported relocation of local symbol '" +
B->getName() +
271 "'. Must have non-local symbol earlier in section.");
275 if (A_Base == B_Base && A_Base) {
276 Asm.getContext().reportError(
277 Fixup.getLoc(),
"unsupported relocation with identical base");
294 MRE.
r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
304 bool CanUseLocalRelocation =
306 if (
Symbol->isTemporary() && (
Value || !CanUseLocalRelocation)) {
309 if (!
Symbol->isInSection()) {
310 Asm.getContext().reportError(
312 "unsupported relocation of local symbol '" +
Symbol->getName() +
313 "'. Must have non-local symbol earlier in section.");
331 if (
Symbol->isInSection()) {
345 }
else if (
Symbol->isInSection()) {
346 if (!CanUseLocalRelocation) {
347 Asm.getContext().reportError(
349 "unsupported relocation of local symbol '" +
Symbol->getName() +
350 "'. Must have non-local symbol earlier in section.");
364 "This constant variable should have been expanded during evaluation");
375 if (!isInt<24>(
Value)) {
376 Asm.getContext().reportError(
Fixup.getLoc(),
377 "addend too big for relocation");
384 (
Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
400 auto *Expr = cast<AArch64AuthMCExpr>(
Fixup.getValue());
405 Asm.getContext().reportError(
Fixup.getLoc(),
406 "invalid PC relative auth relocation");
411 Asm.getContext().reportError(
412 Fixup.getLoc(),
"invalid auth relocation size, must be 8 bytes");
417 Asm.getContext().reportError(
419 "invalid auth relocation, can't reference two symbols");
426 if (!isInt<32>(
Value)) {
427 Asm.getContext().reportError(
Fixup.getLoc(),
428 "addend too big for relocation");
434 (
uint64_t(Expr->hasAddressDiversity()) << 48) |
435 (
uint64_t(Key) << 49) | (1ULL << 63);
445 (
Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
449std::unique_ptr<MCObjectTargetWriter>
452 return std::make_unique<AArch64MachObjectWriter>(CPUType, CPUSubtype,
static bool canUseLocalRelocation(const MCSectionMachO &Section, const MCSymbol &Symbol, unsigned Log2Size)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isSectionAtomizableBySymbols(const MCSection &Section)
True if the section is atomized using the symbols in it.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
MCSection * getParent() const
virtual void recordRelocation(MachObjectWriter *Writer, MCAssembler &Asm, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0
This represents a section on a Mach-O system (used by Mac OS X).
MachO::SectionType getType() const
StringRef getSegmentName() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
unsigned getOrdinal() const
StringRef getName() const
Represent a reference to a symbol from inside an expression.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCFragment * getFragment(bool SetUsed=true) const
This represents an "assembler immediate".
uint64_t getFragmentAddress(const MCAssembler &Asm, const MCFragment *Fragment) const
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)
uint64_t getSymbolAddress(const MCSymbol &S, const MCAssembler &Asm) const
const MCSymbol * getAtom(const MCSymbol &S) const
Target - Wrapper for Target specific information.
const char * getName() const
getName - Get the target name.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ fixup_aarch64_ldst_imm12_scale4
@ fixup_aarch64_pcrel_call26
@ fixup_aarch64_pcrel_branch26
@ fixup_aarch64_pcrel_branch19
@ fixup_aarch64_pcrel_branch14
@ fixup_aarch64_ldst_imm12_scale2
@ fixup_aarch64_ldst_imm12_scale16
@ fixup_aarch64_pcrel_adrp_imm21
@ fixup_aarch64_add_imm12
@ fixup_aarch64_ldst_imm12_scale8
@ fixup_aarch64_ldst_imm12_scale1
@ S_ATTR_DEBUG
S_ATTR_DEBUG - A debug section.
@ S_CSTRING_LITERALS
S_CSTRING_LITERALS - Section with literal C strings.
@ ARM64_RELOC_POINTER_TO_GOT
@ ARM64_RELOC_AUTHENTICATED_POINTER
@ ARM64_RELOC_GOT_LOAD_PAGE21
@ ARM64_RELOC_TLVP_LOAD_PAGEOFF12
@ ARM64_RELOC_GOT_LOAD_PAGEOFF12
@ ARM64_RELOC_TLVP_LOAD_PAGE21
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_Data_2
A two-byte fixup.
std::unique_ptr< MCObjectTargetWriter > createAArch64MachObjectWriter(uint32_t CPUType, uint32_t CPUSubtype, bool IsILP32)