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;
65 return LocalDifference_RIT;
77 uint64_t &FixedValue) = 0;
84 struct MachSymbolData {
90 bool operator<(
const MachSymbolData &RHS)
const;
94 std::unique_ptr<MCMachObjectTargetWriter> TargetObjectWriter;
103 : Sym(Sym), MRE(MRE) {}
116 std::vector<MachSymbolData> LocalSymbolData;
117 std::vector<MachSymbolData> ExternalSymbolData;
118 std::vector<MachSymbolData> UndefinedSymbolData;
122 MachSymbolData *findSymbolData(
const MCSymbol &Sym);
129 : TargetObjectWriter(
std::move(MOTW)),
130 W(OS, IsLittleEndian ? support::
little : support::
big) {}
139 void reset()
override;
151 return SectionAddress.
lookup(Sec);
155 uint64_t getFragmentAddress(
const MCFragment *Fragment,
160 bool doesSymbolRequireExternRelocation(
const MCSymbol &S);
167 bool is64Bit()
const {
return TargetObjectWriter->is64Bit(); }
169 uint32_t CPUType = TargetObjectWriter->getCPUType();
176 unsigned LoadCommandsSize,
bool SubsectionsViaSymbols);
182 void writeSegmentLoadCommand(
StringRef Name,
unsigned NumSections,
183 uint64_t VMAddr, uint64_t VMSize,
184 uint64_t SectionDataStartOffset,
185 uint64_t SectionDataSize,
uint32_t MaxProt,
189 uint64_t VMAddr, uint64_t FileOffset,
unsigned Flags,
190 uint64_t RelocationsStart,
unsigned NumRelocations);
196 void writeDysymtabLoadCommand(
202 void writeNlist(MachSymbolData &MSD,
const MCAsmLayout &Layout);
207 void writeLinkerOptionsLoadCommand(
const std::vector<std::string> &Options);
230 RelAndSymbol
P(RelSymbol, MRE);
231 Relocations[Sec].push_back(P);
238 unsigned Log2Size, uint64_t &FixedValue);
242 MCValue Target, uint64_t &FixedValue);
246 MCValue Target, uint64_t &FixedValue)
override;
252 std::vector<MachSymbolData> &LocalSymbolData,
253 std::vector<MachSymbolData> &ExternalSymbolData,
254 std::vector<MachSymbolData> &UndefinedSymbolData);
256 void computeSectionAddresses(
const MCAssembler &Asm,
262 bool isSymbolRefDifferenceFullyResolvedImpl(
const MCAssembler &Asm,
265 bool InSet)
const override;
267 bool isSymbolRefDifferenceFullyResolvedImpl(
const MCAssembler &Asm,
270 bool IsPCRel)
const override;
282 std::unique_ptr<MCObjectWriter>
288 #endif // LLVM_MC_MCMACHOBJECTWRITER_H Instances of this class represent a uniqued identifier for a section in the current translation unit...
This class represents lattice values for constants.
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
uint32_t getCPUType() 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)...
MachObjectWriter(std::unique_ptr< MCMachObjectTargetWriter > MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
support::endian::Writer W
amdgpu Simplify well known AMD library false Value Value const Twine & Name
virtual ~MCMachObjectTargetWriter()
Encapsulates the layout of an assembly file at a particular point in time.
virtual Triple::ObjectFormatType getFormat() const =0
void setLocalDifferenceRelocationType(unsigned Type)
Utility for building string tables with deduplicated suffixes.
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
SectionAddrMap & getSectionAddressMap()
static bool classof(const MCObjectTargetWriter *W)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
The instances of the Type class are immutable: once they are created, they are never changed...
uint32_t getCPUSubtype() const
PowerPC TLS Dynamic Call Fixup
virtual Triple::ObjectFormatType getFormat() const
unsigned getLocalDifferenceRelocationType() const
Target - Wrapper for Target specific information.
Adapter to write values to a stream in a particular byte order.
virtual void recordRelocation(MachObjectWriter *Writer, MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0
std::unique_ptr< MCObjectWriter > createMachObjectWriter(std::unique_ptr< MCMachObjectTargetWriter > MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
Construct a new Mach-O writer instance.
Base class for classes that define behaviour that is specific to both the target and the object forma...
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...
uint64_t getSectionAddress(const MCSection *Sec) const
An abstract base class for streams implementations that also support a pwrite operation.
bool operator<(int64_t V1, const APSInt &V2)
StringRef - Represent a constant reference to a string, i.e.
MCMachObjectTargetWriter(bool Is64Bit_, uint32_t CPUType_, uint32_t CPUSubtype_)