35 bool getAArch64FixupKindMachOInfo(
const MCFixup &
Fixup,
unsigned &RelocType,
50bool AArch64MachObjectWriter::getAArch64FixupKindMachOInfo(
56 switch (
Fixup.getTargetKind()) {
83 switch (
Sym->getKind()) {
99 switch (
Sym->getKind()) {
101 Asm.getContext().reportError(
Fixup.getLoc(),
102 "ADR/ADRP relocations must be GOT relative");
124 const MCSymbol &Symbol,
unsigned Log2Size) {
134 if (!Symbol.isInSection())
136 const MCSectionMachO &RefSec = cast<MCSectionMachO>(Symbol.getSection());
141 (RefSec.
getName() ==
"__cfstring" ||
142 RefSec.
getName() ==
"__objc_classrefs"))
148void AArch64MachObjectWriter::recordRelocation(
154 uint32_t FixupOffset =
Asm.getFragmentOffset(*Fragment);
155 unsigned Log2Size = 0;
160 const MCSymbol *RelSymbol =
nullptr;
162 FixupOffset +=
Fixup.getOffset();
166 FixedValue += FixupOffset;
178 Asm.getContext().reportError(
Fixup.getLoc(),
179 "conditional branch requires assembler-local"
189 Asm.getContext().reportError(
Fixup.getLoc(),
190 "Invalid relocation on conditional branch!");
194 if (!getAArch64FixupKindMachOInfo(
Fixup,
Type,
Target.getSymA(), Log2Size,
196 Asm.getContext().reportError(
Fixup.getLoc(),
"unknown AArch64 fixup kind!");
202 if (
Target.isAbsolute()) {
208 Asm.getContext().reportError(
Fixup.getLoc(),
209 "PC relative absolute relocation!");
215 }
else if (
Target.getSymB()) {
227 Asm.getSymbolOffset(*
B) ==
228 Asm.getFragmentOffset(*Fragment) +
Fixup.getOffset()) {
234 MRE.
r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
240 Asm.getContext().reportError(
Fixup.getLoc(),
241 "unsupported relocation of modified symbol");
247 Asm.getContext().reportError(
Fixup.getLoc(),
248 "unsupported pc-relative relocation of "
260 Asm.getContext().reportError(
262 "unsupported relocation of local symbol '" +
A->getName() +
263 "'. Must have non-local symbol earlier in section.");
267 Asm.getContext().reportError(
269 "unsupported relocation of local symbol '" +
B->getName() +
270 "'. Must have non-local symbol earlier in section.");
274 if (A_Base == B_Base && A_Base) {
275 Asm.getContext().reportError(
276 Fixup.getLoc(),
"unsupported relocation with identical base");
293 MRE.
r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
303 bool CanUseLocalRelocation =
305 if (
Symbol->isTemporary() && (
Value || !CanUseLocalRelocation)) {
308 if (!
Symbol->isInSection()) {
309 Asm.getContext().reportError(
311 "unsupported relocation of local symbol '" +
Symbol->getName() +
312 "'. Must have non-local symbol earlier in section.");
330 if (
Symbol->isInSection()) {
344 }
else if (
Symbol->isInSection()) {
345 if (!CanUseLocalRelocation) {
346 Asm.getContext().reportError(
348 "unsupported relocation of local symbol '" +
Symbol->getName() +
349 "'. Must have non-local symbol earlier in section.");
363 "This constant variable should have been expanded during evaluation");
374 if (!isInt<24>(
Value)) {
375 Asm.getContext().reportError(
Fixup.getLoc(),
376 "addend too big for relocation");
383 (
Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
404 (
Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
408std::unique_ptr<MCObjectTargetWriter>
411 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_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)