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,
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");
346 "32-bit absolute addressing is not supported in 64-bit mode");
359 MRE.
r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
360 (IsExtern << 27) | (Type << 28);
364 bool X86MachObjectWriter::recordScatteredRelocation(
MachObjectWriter *Writer,
371 uint64_t &FixedValue) {
372 uint64_t OriginalFixedValue = FixedValue;
384 "' can not be undefined in a subtraction expression");
390 FixedValue += SecAddr;
400 "' can not be undefined in a subtraction expression");
420 if (FixupOffset > 0xffffff) {
422 format(
"0x%x", FixupOffset).print(Buffer,
sizeof(Buffer));
424 Twine(
"Section too large, can't encode "
425 "r_address (") + Buffer +
426 ") into 24 bits of scattered "
427 "relocation entry.");
447 if (FixupOffset > 0xffffff) {
448 FixedValue = OriginalFixedValue;
454 MRE.
r_word0 = ((FixupOffset << 0) |
470 uint64_t &FixedValue) {
473 "Should only be called with a 32-bit TLVP relocation!");
477 unsigned IsPCRel = 0;
483 if (
auto *SymB = Target.
getSymB()) {
488 FixedValue = FixupAddress -
491 FixedValue += 1ULL << Log2Size;
510 uint64_t &FixedValue) {
517 recordTLVPRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
526 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
527 Target, Log2Size, FixedValue);
540 Offset += 1 << Log2Size;
545 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
546 Log2Size, FixedValue))
553 const MCSymbol *RelSymbol =
nullptr;
596 (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const MCAsmInfo * getAsmInfo() const
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
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...
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.
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 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.
INITIALIZE_PASS(HexagonEarlyIfConversion,"hexagon-eif","Hexagon early if conversion", false, false) bool HexagonEarlyIfConversion MachineBasicBlock * SB
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
void reportError(SMLoc L, const Twine &Msg)
unsigned getOrdinal() const
bool isInSection(bool SetUsed=true) const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
MCFixupKind getKind() const
const MCSymbolRefExpr * getSymB() const
S_ATTR_DEBUG - A debug section.
static unsigned getFixupKindLog2Size(unsigned Kind)
A two-byte pc relative fixup.
const MCSymbolRefExpr * getSymA() const
A four-byte pc relative fixup.
uint64_t getFragmentAddress(const MCFragment *Fragment, const MCAsmLayout &Layout) const
MCSection * getParent() const
Target - Wrapper for Target specific information.
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
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.
MCSection & getSection(bool SetUsed=true) const
Get the section associated with a defined, non-absolute symbol.
llvm_unreachable("Unknown RegBank!")
StringRef getName() const
getName - Get the symbol name.
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.
MCFragment * getFragment(bool SetUsed=true) const
An abstract base class for streams implementations that also support a pwrite operation.
VariantKind getKind() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
int64_t getConstant() const
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).