42 bool DWARFMustBeAtTheEnd;
43 bool CreatedADWARFSection;
53 void EmitDataRegionEnd();
59 DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd), CreatedADWARFSection(
false) {}
62 void reset()
override {
63 HasSectionLabel.clear();
77 unsigned Minor,
unsigned Update)
override;
80 void EmitSymbolDesc(
MCSymbol *
Symbol,
unsigned DescValue)
override;
86 void EmitCOFFSymbolStorageClass(
int StorageClass)
override {
89 void EmitCOFFSymbolType(
int Type)
override {
92 void EndCOFFSymbolDef()
override {
102 void EmitFileDirective(
StringRef Filename)
override {
109 void EmitIdent(
StringRef IdentString)
override {
114 getAssembler().getLOHContainer().addDirective(Kind, Args);
117 void FinishImpl()
override;
128 if (SegName ==
"__LD" && SecName ==
"__compact_unwind")
131 if (SegName ==
"__IMPORT") {
132 if (SecName ==
"__jump_table")
135 if (SecName ==
"__pointers")
139 if (SegName ==
"__TEXT" && SecName ==
"__eh_frame")
142 if (SegName ==
"__DATA" && SecName ==
"__nl_symbol_ptr")
149 const MCExpr *Subsection) {
154 if (SegName ==
"__DWARF")
155 CreatedADWARFSection =
true;
157 assert(!CreatedADWARFSection &&
"Creating regular section after DWARF");
161 if (LabelSections && !HasSectionLabel[Section] &&
163 MCSymbol *
Label = getContext().createLinkerPrivateTempSymbol();
165 HasSectionLabel[
Section] =
true;
171 getAssembler().registerSymbol(*Symbol);
174 if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition())
180 void MCMachOStreamer::EmitLabel(
MCSymbol *Symbol) {
181 assert(Symbol->
isUndefined() &&
"Cannot define a symbol twice!");
184 AssignSection(Symbol, getCurrentSection().first);
187 if (getAssembler().isSymbolLinkerVisible(*Symbol))
199 cast<MCSymbolMachO>(
Symbol)->clearReferenceType();
203 if (!getAssembler().getBackend().hasDataInCodeSupport())
206 MCSymbol *Start = getContext().createTempSymbol();
210 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
211 Regions.push_back(Data);
214 void MCMachOStreamer::EmitDataRegionEnd() {
215 if (!getAssembler().getBackend().hasDataInCodeSupport())
217 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
218 assert(!Regions.empty() &&
"Mismatched .end_data_region!");
220 assert(!Data.End &&
"Mismatched .end_data_region!");
222 Data.End = getContext().createTempSymbol();
228 getAssembler().getBackend().handleAssemblerFlag(Flag);
236 getAssembler().setSubsectionsViaSymbols(
true);
242 getAssembler().getLinkerOptions().push_back(Options);
266 unsigned Minor,
unsigned Update) {
267 getAssembler().setVersionMinInfo(Kind, Major, Minor, Update);
270 void MCMachOStreamer::EmitThumbFunc(
MCSymbol *Symbol) {
273 getAssembler().setIsThumbFunc(Symbol);
274 cast<MCSymbolMachO>(
Symbol)->setThumbFunc();
277 bool MCMachOStreamer::EmitSymbolAttribute(
MCSymbol *Sym,
288 ISD.
Section = getCurrentSectionOnly();
289 getAssembler().getIndirectSymbols().push_back(ISD);
296 getAssembler().registerSymbol(*Symbol);
376 void MCMachOStreamer::EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
378 getAssembler().registerSymbol(*Symbol);
379 cast<MCSymbolMachO>(
Symbol)->setDesc(DescValue);
382 void MCMachOStreamer::EmitCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
385 assert(Symbol->
isUndefined() &&
"Cannot define a symbol twice!");
387 AssignSection(Symbol,
nullptr);
389 getAssembler().registerSymbol(*Symbol);
394 void MCMachOStreamer::EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
395 unsigned ByteAlignment) {
397 return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
398 Symbol, Size, ByteAlignment);
402 uint64_t Size,
unsigned ByteAlignment) {
403 getAssembler().registerSection(*Section);
410 assert(Section->
isVirtualSection() &&
"Section does not have zerofill type!");
412 assert(Symbol->
isUndefined() &&
"Cannot define a symbol twice!");
414 getAssembler().registerSymbol(*Symbol);
417 if (ByteAlignment != 1)
420 AssignSection(Symbol, Section);
433 uint64_t Size,
unsigned ByteAlignment) {
434 EmitZerofill(Section, Symbol, Size, ByteAlignment);
438 void MCMachOStreamer::EmitInstToData(
const MCInst &Inst,
445 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
449 for (
unsigned i = 0, e = Fixups.
size(); i != e; ++i) {
456 void MCMachOStreamer::FinishImpl() {
457 EmitFrames(&getAssembler().getBackend());
465 for (
const MCSymbol &Symbol : getAssembler().symbols()) {
466 if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.
getFragment()) {
469 "Invalid offset in atom defining symbol!");
477 ie = getAssembler().
end(); it != ie; ++it) {
478 const MCSymbol *CurrentAtom =
nullptr;
482 CurrentAtom = Symbol;
483 it2->setAtom(CurrentAtom);
492 bool RelaxAll,
bool DWARFMustBeAtTheEnd,
493 bool LabelSections) {
494 MCMachOStreamer *S =
new MCMachOStreamer(Context, MAB, OS, CE,
495 DWARFMustBeAtTheEnd, LabelSections);
497 S->getAssembler().setRelaxAll(
true);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const_iterator end(StringRef path)
Get end iterator over path.
void setPrivateExtern(bool Value)
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
MCSectionMachO - This represents a section on a Mach-O system (used by Mac OS X). ...
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
void EmitLabel(MCSymbol *Symbol) override
Emit a label for Symbol into the current section.
.type _foo, STT_OBJECT # aka
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void setAlignment(unsigned Value)
A raw_ostream that writes to an SmallVector or SmallString.
const_iterator begin(StringRef path)
Get begin iterator over path.
.type _foo, STT_NOTYPE # aka
unsigned getAlignment() const
static std::error_code getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
COFF::SymbolStorageClass StorageClass
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
void setCommon(uint64_t Size, unsigned Align)
Mark this symbol as being 'common'.
Context object for machine code objects.
void setWeakReference() const
.code16 (X86) / .code 16 (ARM)
Streaming object file generation interface.
StringRef getSectionName() const
.type _foo, STT_GNU_IFUNC
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void setWeakDefinition() const
void setExternal(bool Value) const
SmallVectorImpl< char > & getContents()
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.
.weak_def_can_be_hidden (MachO)
The instances of the Type class are immutable: once they are created, they are never changed...
MCCodeEmitter - Generic instruction encoding interface.
SmallVectorImpl< MCFixup > & getFixups()
MCLOHType
Linker Optimization Hint Type.
.subsections_via_symbols (MachO)
void setReferenceTypeUndefinedLazy(bool Value) const
MCFragment * getFragment() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
static bool canGoAfterDWARF(const MCSectionMachO &MSec)
void setSymbolResolver() const
void setFragment(MCFragment *Value) const
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
An iterator type that allows iterating over the pointees via some other iterator. ...
.type _foo, STT_TLS # aka
MCSymbol * getBeginSymbol()
void setNoDeadStrip() const
StringRef getSegmentName() const
.code32 (X86) / .code 32 (ARM)
.type _foo, STT_COMMON # aka
void FinishImpl() override
Streamer specific finalization.
uint64_t getOffset() const
.type _foo, STT_FUNC # aka
void reset() override
state management
MCSubtargetInfo - Generic base class for all target subtargets.
An abstract base class for streams implementations that also support a pwrite operation.
Fragment for data and encoded instructions.
const ARM::ArchExtKind Kind
bool isPrivateExtern() const
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
MCStreamer * createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *CE, bool RelaxAll, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
Generic interface to target specific assembler backends.
StringRef - Represent a constant reference to a string, i.e.
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
void setBeginSymbol(MCSymbol *Sym)