35 bool getAArch64FixupKindMachOInfo(
const MCFixup &
Fixup,
unsigned &RelocType,
51bool AArch64MachObjectWriter::getAArch64FixupKindMachOInfo(
57 switch (
Fixup.getTargetKind()) {
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() ==
"__objc_classrefs")
151void AArch64MachObjectWriter::recordRelocation(
159 unsigned Log2Size = 0;
164 const MCSymbol *RelSymbol =
nullptr;
166 FixupOffset +=
Fixup.getOffset();
170 FixedValue += FixupOffset;
182 Asm.getContext().reportError(
Fixup.getLoc(),
183 "conditional branch requires assembler-local"
193 Asm.getContext().reportError(
Fixup.getLoc(),
194 "Invalid relocation on conditional branch!");
198 if (!getAArch64FixupKindMachOInfo(
Fixup,
Type,
Target.getSymA(), Log2Size,
200 Asm.getContext().reportError(
Fixup.getLoc(),
"unknown AArch64 fixup kind!");
206 if (
Target.isAbsolute()) {
212 Asm.getContext().reportError(
Fixup.getLoc(),
213 "PC relative absolute relocation!");
219 }
else if (
Target.getSymB()) {
238 MRE.
r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
244 Asm.getContext().reportError(
Fixup.getLoc(),
245 "unsupported relocation of modified symbol");
251 Asm.getContext().reportError(
Fixup.getLoc(),
252 "unsupported pc-relative relocation of "
264 Asm.getContext().reportError(
266 "unsupported relocation of local symbol '" +
A->getName() +
267 "'. Must have non-local symbol earlier in section.");
271 Asm.getContext().reportError(
273 "unsupported relocation of local symbol '" +
B->getName() +
274 "'. Must have non-local symbol earlier in section.");
278 if (A_Base == B_Base && A_Base) {
279 Asm.getContext().reportError(
280 Fixup.getLoc(),
"unsupported relocation with identical base");
295 MRE.
r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
305 bool CanUseLocalRelocation =
307 if (
Symbol->isTemporary() && (
Value || !CanUseLocalRelocation)) {
310 if (!
Symbol->isInSection()) {
311 Asm.getContext().reportError(
313 "unsupported relocation of local symbol '" +
Symbol->getName() +
314 "'. Must have non-local symbol earlier in section.");
318 if (!
Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
331 if (
Symbol->isInSection()) {
346 }
else if (
Symbol->isInSection()) {
347 if (!CanUseLocalRelocation) {
348 Asm.getContext().reportError(
350 "unsupported relocation of local symbol '" +
Symbol->getName() +
351 "'. Must have non-local symbol earlier in section.");
362 Fixup.getOffset() + (1ULL << Log2Size);
365 "This constant variable should have been expanded during evaluation");
376 if (!isInt<24>(
Value)) {
377 Asm.getContext().reportError(
Fixup.getLoc(),
378 "addend too big for relocation");
385 (
Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
406 (
Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
410std::unique_ptr<MCObjectTargetWriter>
413 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())
Encapsulates the layout of an assembly file at a particular point in time.
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
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 MCAsmLayout &Layout, 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.
VariantKind getKind() const
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 getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)
uint64_t getFragmentAddress(const MCFragment *Fragment, const MCAsmLayout &Layout) 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)