35 uint64_t &FixedValue);
42 uint64_t &FixedValue);
50 uint64_t &FixedValue);
57 X86MachObjectWriter(
bool Is64Bit, uint32_t
CPUType, uint32_t CPUSubtype)
63 uint64_t &FixedValue)
override {
65 RecordX86_64Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
68 RecordX86Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
97 void X86MachObjectWriter::RecordX86_64Relocation(
100 uint64_t &FixedValue) {
106 uint32_t FixupOffset =
108 uint32_t FixupAddress =
112 unsigned IsExtern = 0;
114 const MCSymbol *RelSymbol =
nullptr;
124 Value += 1LL << Log2Size;
171 if (A_Base == B_Base && A_Base)
179 "unsupported relocation with subtraction expression, symbol '" +
180 Name +
"' can not be undefined in a subtraction expression");
195 (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
210 RelSymbol = Asm.
getAtom(*Symbol);
228 if (RelSymbol != Symbol)
237 Value -= FixupAddress + (1 << Log2Size);
241 bool isAbs = Value->evaluateAsAbsolute(Res, Layout,
248 Symbol->
getName() +
"'",
false);
252 Symbol->
getName() +
"'",
false);
288 switch (-(Target.
getConstant() + (1LL << Log2Size))) {
297 "relocation",
false);
321 "64-bit mode",
false);
332 MRE.
r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
333 (IsExtern << 27) | (Type << 28);
337 bool X86MachObjectWriter::recordScatteredRelocation(
MachObjectWriter *Writer,
344 uint64_t &FixedValue) {
345 uint64_t OriginalFixedValue = FixedValue;
355 "' can not be undefined in a subtraction expression",
360 FixedValue += SecAddr;
364 const MCSymbol *SB = &B->getSymbol();
368 "' can not be undefined in a subtraction expression",
387 if (FixupOffset > 0xffffff) {
389 format(
"0x%x", FixupOffset).print(Buffer,
sizeof(Buffer));
391 Twine(
"Section too large, can't encode "
392 "r_address (") + Buffer +
393 ") into 24 bits of scattered "
394 "relocation entry.");
414 if (FixupOffset > 0xffffff) {
415 FixedValue = OriginalFixedValue;
421 MRE.
r_word0 = ((FixupOffset << 0) |
437 uint64_t &FixedValue) {
440 "Should only be called with a 32-bit TLVP relocation!");
444 unsigned IsPCRel = 0;
452 uint32_t FixupAddress =
459 FixedValue += 1ULL << Log2Size;
479 uint64_t &FixedValue) {
486 recordTLVPRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
495 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
496 Target, Log2Size, FixedValue);
509 Offset += 1 << Log2Size;
514 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
515 Log2Size, FixedValue))
522 const MCSymbol *RelSymbol =
nullptr;
565 (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
570 bool Is64Bit, uint32_t
CPUType,
571 uint32_t CPUSubtype) {
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const MCAsmInfo * getAsmInfo() const
MCSectionMachO - This represents a section on a Mach-O system (used by Mac OS X). ...
const MCSymbol & getSymbol() const
bool doesSymbolRequireExternRelocation(const MCSymbol &S)
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
uint64_t getSectionAddress(const MCSection *Sec) const
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg) const
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.
static bool isFixupKindRIPRel(unsigned Kind)
MCContext & getContext() const
Defines the object file and target independent interfaces used by the assembler backend to write nati...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
A one-byte pc relative fixup.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCExpr * getVariableValue() const
getVariableValue() - Get the value for variable symbols.
Base class for the full range of assembler expressions which are needed for parsing.
Represent a reference to a symbol from inside an expression.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
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...
uint32_t getOffset() const
SectionAddrMap & getSectionAddressMap()
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
MCObjectWriter * createX86MachObjectWriter(raw_pwrite_stream &OS, bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
Construct an X86 Mach-O object writer.
The instances of the Type class are immutable: once they are created, they are never changed...
static bool is64Bit(const char *name)
bool hasAttribute(unsigned Value) const
void setUsedInReloc() const
MCFragment * getFragment() const
unsigned getOrdinal() const
MCFixupKind getKind() const
const MCSymbolRefExpr * getSymB() const
PowerPC TLS Dynamic Call Fixup
static unsigned getFixupKindLog2Size(unsigned Kind)
A two-byte pc relative fixup.
const MCSymbolRefExpr * getSymA() const
A four-byte pc relative fixup.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
uint64_t getFragmentAddress(const MCFragment *Fragment, const MCAsmLayout &Layout) const
MCSection * getParent() const
Target - Wrapper for Target specific information.
MCObjectWriter * createMachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
Construct a new Mach-O writer instance.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
StringRef getName() const
getName - Get the symbol name.
S_ATTR_DEBUG - A debug section.
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
bool isVariable() const
isVariable - Check if this is a variable symbol.
An abstract base class for streams implementations that also support a pwrite operation.
VariantKind getKind() const
int64_t getConstant() const
const ARM::ArchExtKind Kind
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const