10 #ifndef LLVM_MC_MCMACHOBJECTWRITER_H
11 #define LLVM_MC_MCMACHOBJECTWRITER_H
27 class MachObjectWriter;
30 const unsigned Is64Bit : 1;
33 unsigned LocalDifference_RIT;
40 LocalDifference_RIT =
Type;
60 return LocalDifference_RIT;
72 uint64_t &FixedValue) = 0;
79 struct MachSymbolData {
85 bool operator<(
const MachSymbolData &RHS)
const;
89 std::unique_ptr<MCMachObjectTargetWriter> TargetObjectWriter;
98 : Sym(Sym), MRE(MRE) {}
111 std::vector<MachSymbolData> LocalSymbolData;
112 std::vector<MachSymbolData> ExternalSymbolData;
113 std::vector<MachSymbolData> UndefinedSymbolData;
117 MachSymbolData *findSymbolData(
const MCSymbol &Sym);
129 void reset()
override;
141 return SectionAddress.
lookup(Sec);
157 bool is64Bit()
const {
return TargetObjectWriter->is64Bit(); }
166 unsigned LoadCommandsSize,
bool SubsectionsViaSymbols);
173 uint64_t VMAddr, uint64_t VMSize,
174 uint64_t SectionDataStartOffset,
175 uint64_t SectionDataSize,
uint32_t MaxProt,
179 uint64_t VMAddr, uint64_t FileOffset,
unsigned Flags,
180 uint64_t RelocationsStart,
unsigned NumRelocations);
220 RelAndSymbol
P(RelSymbol, MRE);
221 Relocations[Sec].push_back(P);
228 unsigned Log2Size, uint64_t &FixedValue);
242 std::vector<MachSymbolData> &LocalSymbolData,
243 std::vector<MachSymbolData> &ExternalSymbolData,
244 std::vector<MachSymbolData> &UndefinedSymbolData);
255 bool InSet)
const override;
260 bool IsPCRel)
const override;
273 raw_pwrite_stream &OS,
274 bool IsLittleEndian);
278 #endif // LLVM_MC_MCMACHOBJECTWRITER_H
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)
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
void computeSectionAddresses(const MCAssembler &Asm, const MCAsmLayout &Layout)
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
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
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)
SectionAddrMap & getSectionAddressMap()
void writeLinkerOptionsLoadCommand(const std::vector< std::string > &Options)
uint32_t getCPUSubtype() const
uint32_t getCPUType() const
void recordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override
Record a relocation entry.
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)
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.
static std::vector< std::string > Flags
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
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const
void writeNlist(MachSymbolData &MSD, const MCAsmLayout &Layout)
MCMachObjectTargetWriter(bool Is64Bit_, uint32_t CPUType_, uint32_t CPUSubtype_)