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;
30 unsigned LocalDifference_RIT;
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(); }
163 unsigned LoadCommandsSize,
bool SubsectionsViaSymbols);
170 uint64_t VMAddr, uint64_t VMSize,
171 uint64_t SectionDataStartOffset,
172 uint64_t SectionDataSize,
uint32_t MaxProt,
176 uint64_t VMAddr, uint64_t FileOffset,
unsigned Flags,
177 uint64_t RelocationsStart,
unsigned NumRelocations);
217 RelAndSymbol
P(RelSymbol, MRE);
218 Relocations[Sec].push_back(P);
225 unsigned Log2Size, uint64_t &FixedValue);
234 uint64_t &FixedValue)
override;
240 std::vector<MachSymbolData> &LocalSymbolData,
241 std::vector<MachSymbolData> &ExternalSymbolData,
242 std::vector<MachSymbolData> &UndefinedSymbolData);
253 bool InSet)
const override;
258 bool IsPCRel)
const override;
271 raw_pwrite_stream &OS,
272 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...
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.
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B, bool InSet) const override
struct fuzzer::@269 Flags
Encapsulates the layout of an assembly file at a particular point in time.
void setLocalDifferenceRelocationType(unsigned Type)
void writeSegmentLoadCommand(StringRef Name, unsigned NumSections, uint64_t VMAddr, uint64_t VMSize, uint64_t SectionDataStartOffset, uint64_t SectionDataSize, uint32_t MaxProt, uint32_t InitProt)
Write a segment load command.
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)
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
SectionAddrMap & getSectionAddressMap()
void writeLinkerOptionsLoadCommand(const std::vector< std::string > &Options)
uint32_t getCPUSubtype() const
uint32_t getCPUType() const
The instances of the Type class are immutable: once they are created, they are never changed...
void writeHeader(MachO::HeaderFileType Type, unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols)
unsigned getLocalDifferenceRelocationType() const
void writeLinkeditLoadCommand(uint32_t Type, uint32_t DataOffset, uint32_t DataSize)
void writeSection(const MCAsmLayout &Layout, const MCSection &Sec, uint64_t VMAddr, uint64_t FileOffset, unsigned Flags, uint64_t RelocationsStart, unsigned NumRelocations)
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
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
bool operator<(int64_t V1, const APSInt &V2)
StringRef - Represent a constant reference to a string, i.e.
void bindIndirectSymbols(MCAssembler &Asm)
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
void writeNlist(MachSymbolData &MSD, const MCAsmLayout &Layout)
MCMachObjectTargetWriter(bool Is64Bit_, uint32_t CPUType_, uint32_t CPUSubtype_)