10 #ifndef LLVM_MC_MCMACHOBJECTWRITER_H
11 #define LLVM_MC_MCMACHOBJECTWRITER_H
18 #include "llvm/Support/DataTypes.h"
24 class MachObjectWriter;
27 const unsigned Is64Bit : 1;
28 const uint32_t CPUType;
29 const uint32_t CPUSubtype;
30 unsigned LocalDifference_RIT;
34 uint32_t CPUSubtype_);
37 LocalDifference_RIT =
Type;
57 return LocalDifference_RIT;
69 uint64_t &FixedValue) = 0;
76 struct MachSymbolData {
82 bool operator<(
const MachSymbolData &RHS)
const;
86 std::unique_ptr<MCMachObjectTargetWriter> TargetObjectWriter;
95 : Sym(Sym), MRE(MRE) {}
108 std::vector<MachSymbolData> LocalSymbolData;
109 std::vector<MachSymbolData> ExternalSymbolData;
110 std::vector<MachSymbolData> UndefinedSymbolData;
114 MachSymbolData *findSymbolData(
const MCSymbol &Sym);
126 void reset()
override;
138 return SectionAddress.
lookup(Sec);
154 bool is64Bit()
const {
return TargetObjectWriter->is64Bit(); }
156 uint32_t
CPUType = TargetObjectWriter->getCPUType();
162 void writeHeader(
unsigned NumLoadCommands,
unsigned LoadCommandsSize,
163 bool SubsectionsViaSymbols);
170 uint64_t SectionDataStartOffset,
171 uint64_t SectionDataSize);
174 const MCSection &Sec, uint64_t FileOffset,
175 uint64_t RelocationsStart,
unsigned NumRelocations);
179 uint32_t StringTableSize);
182 uint32_t FirstLocalSymbol, uint32_t NumLocalSymbols,
183 uint32_t FirstExternalSymbol, uint32_t NumExternalSymbols,
184 uint32_t FirstUndefinedSymbol, uint32_t NumUndefinedSymbols,
185 uint32_t IndirectSymbolOffset, uint32_t NumIndirectSymbols);
215 RelAndSymbol
P(RelSymbol, MRE);
216 Relocations[Sec].push_back(P);
223 unsigned Log2Size, uint64_t &FixedValue);
232 uint64_t &FixedValue)
override;
238 std::vector<MachSymbolData> &LocalSymbolData,
239 std::vector<MachSymbolData> &ExternalSymbolData,
240 std::vector<MachSymbolData> &UndefinedSymbolData);
251 bool IsPCRel)
const override;
264 raw_pwrite_stream &OS,
265 bool IsLittleEndian);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void recordScatteredRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, unsigned Log2Size, uint64_t &FixedValue)
MachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
void computeSectionAddresses(const MCAssembler &Asm, const MCAsmLayout &Layout)
bool doesSymbolRequireExternRelocation(const MCSymbol &S)
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
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
void executePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout) override
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
void writeSection(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCSection &Sec, uint64_t FileOffset, uint64_t RelocationsStart, unsigned NumRelocations)
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)...
virtual ~MCMachObjectTargetWriter()
void writeDysymtabLoadCommand(uint32_t FirstLocalSymbol, uint32_t NumLocalSymbols, uint32_t FirstExternalSymbol, uint32_t NumExternalSymbols, uint32_t FirstUndefinedSymbol, uint32_t NumUndefinedSymbols, uint32_t IndirectSymbolOffset, uint32_t NumIndirectSymbols)
void writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override
Write the object file.
Encapsulates the layout of an assembly file at a particular point in time.
void setLocalDifferenceRelocationType(unsigned Type)
bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)
Utility for building string tables with deduplicated suffixes.
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
void writeSymtabLoadCommand(uint32_t SymbolOffset, uint32_t NumSymbols, uint32_t StringTableOffset, uint32_t StringTableSize)
SectionAddrMap & getSectionAddressMap()
void writeLinkerOptionsLoadCommand(const std::vector< std::string > &Options)
void writeHeader(unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols)
uint32_t getCPUSubtype() const
uint32_t getCPUType() const
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
The instances of the Type class are immutable: once they are created, they are never changed...
void writeSegmentLoadCommand(unsigned NumSections, uint64_t VMSize, uint64_t SectionDataStartOffset, uint64_t SectionDataSize)
Write a segment load command.
unsigned getLocalDifferenceRelocationType() const
PowerPC TLS Dynamic Call Fixup
void writeLinkeditLoadCommand(uint32_t Type, uint32_t DataOffset, uint32_t DataSize)
uint64_t getPaddingSize(const MCSection *SD, const MCAsmLayout &Layout) const
uint64_t getFragmentAddress(const MCFragment *Fragment, const MCAsmLayout &Layout) const
Target - Wrapper for Target specific information.
MCObjectWriter * createMachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
Construct a new Mach-O writer instance.
void computeSymbolTable(MCAssembler &Asm, std::vector< MachSymbolData > &LocalSymbolData, std::vector< MachSymbolData > &ExternalSymbolData, std::vector< MachSymbolData > &UndefinedSymbolData)
Compute the symbol table data.
void recordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, bool &IsPCRel, uint64_t &FixedValue) override
Record a relocation entry.
virtual void recordRelocation(MachObjectWriter *Writer, MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0
void recordTLVPRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)
An abstract base class for streams implementations that also support a pwrite operation.
void reset() override
lifetime management
const ARM::ArchExtKind Kind
bool operator<(int64_t V1, const APSInt &V2)
void bindIndirectSymbols(MCAssembler &Asm)
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const
void writeNlist(MachSymbolData &MSD, const MCAsmLayout &Layout)
MCMachObjectTargetWriter(bool Is64Bit_, uint32_t CPUType_, uint32_t CPUSubtype_)