34 uint64_t &FixedValue);
41 uint64_t &FixedValue);
49 uint64_t &FixedValue);
62 uint64_t &FixedValue)
override {
64 RecordX86_64Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
67 RecordX86Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
102 void X86MachObjectWriter::RecordX86_64Relocation(
105 uint64_t &FixedValue) {
117 unsigned IsExtern = 0;
119 const MCSymbol *RelSymbol =
nullptr;
129 Value += 1LL << Log2Size;
158 "unsupported relocation of modified symbol");
166 Fixup.
getLoc(),
"unsupported pc-relative relocation of difference");
180 if (A_Base == B_Base && A_Base) {
182 Fixup.
getLoc(),
"unsupported relocation with identical base");
191 "unsupported relocation with subtraction expression, symbol '" +
192 Name +
"' can not be undefined in a subtraction expression");
208 (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
223 RelSymbol = Asm.
getAtom(*Symbol);
241 if (RelSymbol != Symbol)
250 Value -= FixupAddress + (1 << Log2Size);
254 bool isAbs = Value->evaluateAsAbsolute(Res, Layout,
261 "unsupported relocation of variable '" +
267 Fixup.
getLoc(),
"unsupported relocation of undefined symbol '" +
287 Fixup.
getLoc(),
"unsupported symbol modifier in relocation");
306 switch (-(Target.
getConstant() + (1LL << Log2Size))) {
316 "unsupported symbol modifier in branch relocation");
334 Fixup.
getLoc(),
"TLVP symbol modifier should have been rip-rel");
338 Fixup.
getLoc(),
"unsupported symbol modifier in relocation");
345 "32-bit absolute addressing is not supported in 64-bit mode");
358 MRE.
r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
359 (IsExtern << 27) | (Type << 28);
363 bool X86MachObjectWriter::recordScatteredRelocation(
MachObjectWriter *Writer,
370 uint64_t &FixedValue) {
371 uint64_t OriginalFixedValue = FixedValue;
383 "' can not be undefined in a subtraction expression");
389 FixedValue += SecAddr;
399 "' can not be undefined in a subtraction expression");
419 if (FixupOffset > 0xffffff) {
421 format(
"0x%x", FixupOffset).print(Buffer,
sizeof(Buffer));
423 Twine(
"Section too large, can't encode " 424 "r_address (") + Buffer +
425 ") into 24 bits of scattered " 426 "relocation entry.");
446 if (FixupOffset > 0xffffff) {
447 FixedValue = OriginalFixedValue;
453 MRE.
r_word0 = ((FixupOffset << 0) |
469 uint64_t &FixedValue) {
472 "Should only be called with a 32-bit TLVP relocation!");
476 unsigned IsPCRel = 0;
482 if (
auto *SymB = Target.
getSymB()) {
487 FixedValue = FixupAddress -
490 FixedValue += 1ULL << Log2Size;
509 uint64_t &FixedValue) {
516 recordTLVPRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
525 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
526 Target, Log2Size, FixedValue);
539 Offset += 1 << Log2Size;
544 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
545 Log2Size, FixedValue))
552 const MCSymbol *RelSymbol =
nullptr;
595 (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
599 std::unique_ptr<MCObjectTargetWriter>
602 return std::make_unique<X86MachObjectWriter>(Is64Bit,
CPUType, CPUSubtype);
const MCAsmInfo * getAsmInfo() const
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const
bool hasAttribute(unsigned Value) const
void setUsedInReloc() const
This represents a section on a Mach-O system (used by Mac OS X).
bool doesSymbolRequireExternRelocation(const MCSymbol &S)
This class represents lattice values for constants.
bool isVariable() const
isVariable - Check if this is a variable symbol.
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
VariantKind getKind() const
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
std::unique_ptr< MCObjectTargetWriter > createX86MachObjectWriter(bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
Construct an X86 Mach-O object writer.
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
static bool isFixupKindRIPRel(unsigned Kind)
unsigned getOrdinal() const
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
A one-byte pc relative fixup.
MCContext & getContext() const
int64_t getConstant() const
const MCSymbolRefExpr * getSymB() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Encapsulates the layout of an assembly file at a particular point in time.
Base class for the full range of assembler expressions which are needed for parsing.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Represent a reference to a symbol from inside an expression.
bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
SectionAddrMap & getSectionAddressMap()
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
The instances of the Type class are immutable: once they are created, they are never changed...
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const
True if the section is atomized using the symbols in it.
const MCSymbol * getAtom(const MCSymbol &S) const
Find the symbol which defines the atom containing the given symbol, or null if there is no such symbo...
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
const MCSymbolRefExpr * getSymA() const
void reportError(SMLoc L, const Twine &Msg)
uint32_t getOffset() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
PowerPC TLS Dynamic Call Fixup
static unsigned getFixupKindLog2Size(unsigned Kind)
A two-byte pc relative fixup.
uint64_t getFragmentAddress(const MCFragment *Fragment, const MCAsmLayout &Layout) const
A four-byte pc relative fixup.
const MCSymbol & getSymbol() const
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
MCFragment * getFragment(bool SetUsed=true) const
Target - Wrapper for Target specific information.
MCSection * getParent() const
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
S_ATTR_DEBUG - A debug section.
uint64_t getSectionAddress(const MCSection *Sec) const
StringRef getName() const
getName - Get the symbol name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
LLVM Value Representation.
unsigned getTargetKind() const
StringRef - Represent a constant reference to a string, i.e.
static bool is64Bit(const char *name)
MCFixupKind getKind() const