35 uint64_t &FixedValue);
42 uint64_t &FixedValue);
50 uint64_t &FixedValue);
63 uint64_t &FixedValue)
override {
65 RecordX86_64Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
68 RecordX86Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
103 void X86MachObjectWriter::RecordX86_64Relocation(
106 uint64_t &FixedValue) {
118 unsigned IsExtern = 0;
120 const MCSymbol *RelSymbol =
nullptr;
130 Value += 1LL << Log2Size;
159 "unsupported relocation of modified symbol");
167 Fixup.
getLoc(),
"unsupported pc-relative relocation of difference");
181 if (A_Base == B_Base && A_Base) {
183 Fixup.
getLoc(),
"unsupported relocation with identical base");
192 "unsupported relocation with subtraction expression, symbol '" +
193 Name +
"' can not be undefined in a subtraction expression");
209 (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
224 RelSymbol = Asm.
getAtom(*Symbol);
242 if (RelSymbol != Symbol)
251 Value -= FixupAddress + (1 << Log2Size);
255 bool isAbs = Value->evaluateAsAbsolute(Res, Layout,
262 "unsupported relocation of variable '" +
268 Fixup.
getLoc(),
"unsupported relocation of undefined symbol '" +
288 Fixup.
getLoc(),
"unsupported symbol modifier in relocation");
307 switch (-(Target.
getConstant() + (1LL << Log2Size))) {
317 "unsupported symbol modifier in branch relocation");
335 Fixup.
getLoc(),
"TLVP symbol modifier should have been rip-rel");
339 Fixup.
getLoc(),
"unsupported symbol modifier in relocation");
347 "32-bit absolute addressing is not supported in 64-bit mode");
360 MRE.
r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
361 (IsExtern << 27) | (Type << 28);
365 bool X86MachObjectWriter::recordScatteredRelocation(
MachObjectWriter *Writer,
372 uint64_t &FixedValue) {
373 uint64_t OriginalFixedValue = FixedValue;
385 "' can not be undefined in a subtraction expression");
391 FixedValue += SecAddr;
401 "' can not be undefined in a subtraction expression");
421 if (FixupOffset > 0xffffff) {
423 format(
"0x%x", FixupOffset).print(Buffer,
sizeof(Buffer));
425 Twine(
"Section too large, can't encode " 426 "r_address (") + Buffer +
427 ") into 24 bits of scattered " 428 "relocation entry.");
448 if (FixupOffset > 0xffffff) {
449 FixedValue = OriginalFixedValue;
455 MRE.
r_word0 = ((FixupOffset << 0) |
471 uint64_t &FixedValue) {
474 "Should only be called with a 32-bit TLVP relocation!");
478 unsigned IsPCRel = 0;
484 if (
auto *SymB = Target.
getSymB()) {
489 FixedValue = FixupAddress -
492 FixedValue += 1ULL << Log2Size;
511 uint64_t &FixedValue) {
518 recordTLVPRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
527 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
528 Target, Log2Size, FixedValue);
541 Offset += 1 << Log2Size;
546 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
547 Log2Size, FixedValue))
554 const MCSymbol *RelSymbol =
nullptr;
597 (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
601 std::unique_ptr<MCObjectTargetWriter>
604 return llvm::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
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
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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...
static bool is64Bit(const char *name)
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.
StringRef - Represent a constant reference to a string, i.e.
MCFixupKind getKind() const