52 bool DWARFMustBeAtTheEnd;
53 bool CreatedADWARFSection;
63 void EmitDataRegionEnd();
67 std::unique_ptr<MCObjectWriter> OW,
68 std::unique_ptr<MCCodeEmitter> Emitter,
69 bool DWARFMustBeAtTheEnd,
bool label)
72 LabelSections(label), DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd),
73 CreatedADWARFSection(
false) {}
76 void reset()
override {
77 CreatedADWARFSection =
false;
78 HasSectionLabel.
clear();
88 void EmitEHSymAttributes(
const MCSymbol *Symbol,
MCSymbol *EHSymbol)
override;
94 void EmitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
96 void EmitThumbFunc(
MCSymbol *Func)
override;
98 void EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue)
override;
102 void EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
110 void EmitIdent(
StringRef IdentString)
override {
115 getAssembler().getLOHContainer().addDirective(Kind, Args);
118 void FinishImpl()
override;
129 if (SegName ==
"__LD" && SecName ==
"__compact_unwind")
132 if (SegName ==
"__IMPORT") {
133 if (SecName ==
"__jump_table")
136 if (SecName ==
"__pointers")
140 if (SegName ==
"__TEXT" && SecName ==
"__eh_frame")
143 if (SegName ==
"__DATA" && (SecName ==
"__nl_symbol_ptr" ||
144 SecName ==
"__thread_ptr"))
150 void MCMachOStreamer::ChangeSection(
MCSection *Section,
151 const MCExpr *Subsection) {
153 bool Created = changeSectionImpl(Section, Subsection);
156 if (SegName ==
"__DWARF")
157 CreatedADWARFSection =
true;
159 assert(!CreatedADWARFSection &&
"Creating regular section after DWARF");
163 if (LabelSections && !HasSectionLabel[Section] &&
165 MCSymbol *Label = getContext().createLinkerPrivateTempSymbol();
167 HasSectionLabel[
Section] =
true;
171 void MCMachOStreamer::EmitEHSymAttributes(
const MCSymbol *Symbol,
173 getAssembler().registerSymbol(*Symbol);
176 if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition())
182 void MCMachOStreamer::EmitLabel(
MCSymbol *Symbol,
SMLoc Loc) {
185 if (getAssembler().isSymbolLinkerVisible(*Symbol))
197 cast<MCSymbolMachO>(
Symbol)->clearReferenceType();
205 const MCSymbol &SymA = SymAExpr->getSymbol();
207 cast<MCSymbolMachO>(
Symbol)->setAltEntry();
215 MCSymbol *Start = getContext().createTempSymbol();
219 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
220 Regions.push_back(Data);
223 void MCMachOStreamer::EmitDataRegionEnd() {
224 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
225 assert(!Regions.empty() &&
"Mismatched .end_data_region!");
227 assert(!Data.End &&
"Mismatched .end_data_region!");
229 Data.End = getContext().createTempSymbol();
235 getAssembler().getBackend().handleAssemblerFlag(Flag);
243 getAssembler().setSubsectionsViaSymbols(
true);
249 getAssembler().getLinkerOptions().push_back(Options);
273 unsigned Minor,
unsigned Update,
275 getAssembler().setVersionMin(Kind, Major, Minor, Update, SDKVersion);
278 void MCMachOStreamer::EmitBuildVersion(
unsigned Platform,
unsigned Major,
279 unsigned Minor,
unsigned Update,
285 void MCMachOStreamer::EmitThumbFunc(
MCSymbol *Symbol) {
288 getAssembler().setIsThumbFunc(Symbol);
289 cast<MCSymbolMachO>(
Symbol)->setThumbFunc();
292 bool MCMachOStreamer::EmitSymbolAttribute(
MCSymbol *Sym,
303 ISD.
Section = getCurrentSectionOnly();
304 getAssembler().getIndirectSymbols().push_back(ISD);
311 getAssembler().registerSymbol(*Symbol);
395 void MCMachOStreamer::EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
397 getAssembler().registerSymbol(*Symbol);
398 cast<MCSymbolMachO>(
Symbol)->setDesc(DescValue);
401 void MCMachOStreamer::EmitCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
406 getAssembler().registerSymbol(*Symbol);
411 void MCMachOStreamer::EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
412 unsigned ByteAlignment) {
414 return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
415 Symbol, Size, ByteAlignment);
419 uint64_t Size,
unsigned ByteAlignment,
425 getContext().reportError(
426 Loc,
"The usage of .zerofill is restricted to sections of " 427 "ZEROFILL type. Use .zero or .space instead.");
433 SwitchSection(Section);
437 EmitValueToAlignment(ByteAlignment, 0, 1, 0);
447 uint64_t Size,
unsigned ByteAlignment) {
448 EmitZerofill(Section, Symbol, Size, ByteAlignment);
451 void MCMachOStreamer::EmitInstToData(
const MCInst &Inst,
458 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
469 void MCMachOStreamer::FinishImpl() {
470 EmitFrames(&getAssembler().getBackend());
478 for (
const MCSymbol &Symbol : getAssembler().symbols()) {
479 if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.
isInSection() &&
483 "Invalid offset in atom defining symbol!");
491 const MCSymbol *CurrentAtom =
nullptr;
494 CurrentAtom = Symbol;
495 Frag.setAtom(CurrentAtom);
503 std::unique_ptr<MCAsmBackend> &&MAB,
504 std::unique_ptr<MCObjectWriter> &&OW,
505 std::unique_ptr<MCCodeEmitter> &&CE,
506 bool RelaxAll,
bool DWARFMustBeAtTheEnd,
507 bool LabelSections) {
509 new MCMachOStreamer(Context, std::move(MAB), std::move(OW), std::move(CE),
510 DWARFMustBeAtTheEnd, LabelSections);
514 S->getAssembler().setRelaxAll(
true);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void setPrivateExtern(bool Value)
void setReferenceTypeUndefinedLazy(bool Value) const
This represents a section on a Mach-O system (used by Mac OS X).
This class represents lattice values for constants.
bool isVariable() const
isVariable - Check if this is a variable symbol.
.type _foo, STT_OBJECT # aka
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A raw_ostream that writes to an SmallVector or SmallString.
.type _foo, STT_NOTYPE # aka
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
int64_t getConstant() const
const MCSymbolRefExpr * getSymB() const
void setExternal(bool Value) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Represent a reference to a symbol from inside an expression.
void setCommon(uint64_t Size, unsigned Align)
Mark this symbol as being 'common'.
StringRef getSectionName() const
Context object for machine code objects.
void setSymbolResolver() const
.code16 (X86) / .code 16 (ARM)
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Streaming object file generation interface.
.type _foo, STT_GNU_IFUNC
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
SmallVectorImpl< char > & getContents()
StringRef getSegmentName() const
Instances of this class represent a single low-level machine instruction.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Streaming machine code generation interface.
void setWeakDefinition() const
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
.weak_def_can_be_hidden (MachO)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
void setHasInstructions(const MCSubtargetInfo &STI)
Record that the fragment contains instructions with the MCSubtargetInfo in effect when the instructio...
SmallVectorImpl< MCFixup > & getFixups()
MCLOHType
Linker Optimization Hint Type.
const MCSymbolRefExpr * getSymA() const
const MCObjectFileInfo * getObjectFileInfo() const
.subsections_via_symbols (MachO)
uint64_t getOffset() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
static bool canGoAfterDWARF(const MCSectionMachO &MSec)
PowerPC TLS Dynamic Call Fixup
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
MCFragment * getFragment(bool SetUsed=true) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
.type _foo, STT_TLS # aka
MCSymbol * getBeginSymbol()
const Triple & getTargetTriple() const
Target - Wrapper for Target specific information.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
.code32 (X86) / .code 32 (ARM)
.type _foo, STT_COMMON # aka
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Represents a version number in the form major[.minor[.subminor[.build]]].
void FinishImpl() override
Streamer specific finalization.
const VersionTuple & getSDKVersion() const
.type _foo, STT_FUNC # aka
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void reset() override
state management
Generic base class for all target subtargets.
void setNoDeadStrip() const
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...
StringRef getName() const
getName - Get the symbol name.
Fragment for data and encoded instructions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
MCStreamer * createMachOStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
Represents a location in source code.
void setWeakReference() const
bool isPrivateExtern() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
void setBeginSymbol(MCSymbol *Sym)