32 unsigned Log2Size, uint64_t &FixedValue);
40 PPCMachObjectWriter(
bool Is64Bit, uint32_t
CPUType, uint32_t CPUSubtype)
46 uint64_t &FixedValue)
override {
50 RecordPPCRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
93 switch ((
unsigned)FixupKind) {
119 switch ((
unsigned)FixupKind) {
147 const uint32_t FixupOffset,
const uint32_t Index,
148 const unsigned IsPCRel,
const unsigned Log2Size,
149 const unsigned IsExtern,
const unsigned Type) {
165 const uint32_t Addr,
const unsigned Type,
166 const unsigned Log2Size,
const unsigned IsPCRel,
167 const uint32_t Value2) {
170 MRE.
r_word0 = ((Addr << 0) | (Type << 24) | (Log2Size << 28) |
183 FixupOffset &= ~uint32_t(3);
191 bool PPCMachObjectWriter::recordScatteredRelocation(
194 unsigned Log2Size, uint64_t &FixedValue) {
196 const uint32_t FixupOffset =
getFixupOffset(Layout, Fragment, Fixup);
211 "' can not be undefined in a subtraction expression");
215 FixedValue += SecAddr;
219 const MCSymbol *SB = &B->getSymbol();
223 "' can not be undefined in a subtraction expression");
241 if (FixupOffset > 0xffffff) {
243 format(
"0x%x", FixupOffset).print(Buffer,
sizeof(Buffer));
245 Twine(
"Section too large, can't encode "
247 Buffer +
") into 24 bits of scattered "
248 "relocation entry.");
254 uint32_t other_half = 0;
257 other_half = (FixedValue >> 16) & 0xffff;
263 FixedValue &= 0xffff;
266 other_half = FixedValue & 0xffff;
268 ((FixedValue >> 16) + ((FixedValue & 0x8000) ? 1 : 0)) & 0xffff;
271 other_half = FixedValue & 0xffff;
272 FixedValue = (FixedValue >> 16) & 0xffff;
281 Log2Size, IsPCRel, Value2);
291 if (FixupOffset > 0xffffff)
301 void PPCMachObjectWriter::RecordPPCRelocation(
304 uint64_t &FixedValue) {
308 const unsigned RelocType =
getRelocType(Target, FK, IsPCRel);
317 recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
318 Log2Size, FixedValue);
329 const uint32_t FixupOffset =
getFixupOffset(Layout, Fragment, Fixup);
331 unsigned Type = RelocType;
333 const MCSymbol *RelSymbol =
nullptr;
340 "not yet implemented");
378 bool Is64Bit, uint32_t
CPUType,
379 uint32_t CPUSubtype) {
381 new PPCMachObjectWriter(Is64Bit, CPUType, CPUSubtype), OS,
Instances of this class represent a uniqued identifier for a section in the current translation unit...
A eight-byte pc relative fixup.
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 ...
static void makeRelocationInfo(MachO::any_relocation_info &MRE, const uint32_t FixupOffset, const uint32_t Index, const unsigned IsPCRel, const unsigned Log2Size, const unsigned IsExtern, const unsigned Type)
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.
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)...
static uint32_t getFixupOffset(const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup)
Compute fixup offset (address).
A one-byte pc relative fixup.
fixup_ppc_half16 - A 16-bit fixup corresponding to lo16(_foo) or ha16(_foo) for instrs like 'li' or '...
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.
Represent a reference to a symbol from inside an expression.
static unsigned getRelocType(const MCValue &Target, const MCFixupKind FixupKind, const bool IsPCRel)
Translates generic PPC fixup kind to Mach-O/PPC relocation type enum.
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.
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.
static unsigned getFixupKindLog2Size(unsigned Kind)
computes the log2 of the size of the relocation, used for relocation_info::r_length.
static void makeScatteredRelocationInfo(MachO::any_relocation_info &MRE, const uint32_t Addr, const unsigned Type, const unsigned Log2Size, const unsigned IsPCRel, const uint32_t Value2)
The instances of the Type class are immutable: once they are created, they are never changed...
MCFixupKind
Extensible enumeration to represent the type of a fixup.
MCFragment * getFragment() const
unsigned getOrdinal() const
MCFixupKind getKind() const
const MCSymbolRefExpr * getSymB() const
MCObjectWriter * createPPCMachObjectWriter(raw_pwrite_stream &OS, bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
Construct a PPC Mach-O object writer.
PowerPC TLS Dynamic Call Fixup
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.
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.
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.
An abstract base class for streams implementations that also support a pwrite operation.
VariantKind getKind() const
const ARM::ArchExtKind Kind
LLVM Value Representation.
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
fixup_ppc_brcond14 - 14-bit PC relative relocation for conditional branches.
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const