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;
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;
400 "symbol '" + B->getSymbol().
getName() +
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;
493 FixedValue += 1ULL << Log2Size;
513 uint64_t &FixedValue) {
520 recordTLVPRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
529 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
530 Target, Log2Size, FixedValue);
543 Offset += 1 << Log2Size;
548 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
549 Log2Size, FixedValue))
556 const MCSymbol *RelSymbol =
nullptr;
599 (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
S_ATTR_DEBUG - A debug section.
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.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
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
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static unsigned getFixupKindLog2Size(unsigned Kind)
A two-byte pc relative fixup.
const MCSymbolRefExpr * getSymA() const
A four-byte pc relative fixup.
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
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.
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
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).