51 bool DWARFMustBeAtTheEnd;
52 bool CreatedADWARFSection;
62 void EmitDataRegionEnd();
66 std::unique_ptr<MCObjectWriter> OW,
67 std::unique_ptr<MCCodeEmitter> Emitter,
68 bool DWARFMustBeAtTheEnd,
bool label)
71 LabelSections(label), DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd),
72 CreatedADWARFSection(
false) {}
75 void reset()
override {
76 CreatedADWARFSection =
false;
77 HasSectionLabel.
clear();
87 void EmitEHSymAttributes(
const MCSymbol *Symbol,
MCSymbol *EHSymbol)
override;
93 void EmitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
95 void EmitThumbFunc(
MCSymbol *Func)
override;
97 void EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue)
override;
101 void EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
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" ||
143 SecName ==
"__thread_ptr"))
149 void MCMachOStreamer::ChangeSection(
MCSection *Section,
150 const MCExpr *Subsection) {
152 bool Created = changeSectionImpl(Section, Subsection);
155 if (SegName ==
"__DWARF")
156 CreatedADWARFSection =
true;
158 assert(!CreatedADWARFSection &&
"Creating regular section after DWARF");
162 if (LabelSections && !HasSectionLabel[Section] &&
164 MCSymbol *Label = getContext().createLinkerPrivateTempSymbol();
166 HasSectionLabel[
Section] =
true;
170 void MCMachOStreamer::EmitEHSymAttributes(
const MCSymbol *Symbol,
172 getAssembler().registerSymbol(*Symbol);
175 if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition())
181 void MCMachOStreamer::EmitLabel(
MCSymbol *Symbol,
SMLoc Loc) {
184 if (getAssembler().isSymbolLinkerVisible(*Symbol))
196 cast<MCSymbolMachO>(
Symbol)->clearReferenceType();
204 const MCSymbol &SymA = SymAExpr->getSymbol();
206 cast<MCSymbolMachO>(
Symbol)->setAltEntry();
214 MCSymbol *Start = getContext().createTempSymbol();
218 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
219 Regions.push_back(Data);
222 void MCMachOStreamer::EmitDataRegionEnd() {
223 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
224 assert(!Regions.empty() &&
"Mismatched .end_data_region!");
226 assert(!Data.End &&
"Mismatched .end_data_region!");
228 Data.End = getContext().createTempSymbol();
234 getAssembler().getBackend().handleAssemblerFlag(Flag);
242 getAssembler().setSubsectionsViaSymbols(
true);
248 getAssembler().getLinkerOptions().push_back(Options);
272 unsigned Minor,
unsigned Update,
274 getAssembler().setVersionMin(Kind, Major, Minor, Update, SDKVersion);
277 void MCMachOStreamer::EmitBuildVersion(
unsigned Platform,
unsigned Major,
278 unsigned Minor,
unsigned Update,
284 void MCMachOStreamer::EmitThumbFunc(
MCSymbol *Symbol) {
287 getAssembler().setIsThumbFunc(Symbol);
288 cast<MCSymbolMachO>(
Symbol)->setThumbFunc();
291 bool MCMachOStreamer::EmitSymbolAttribute(
MCSymbol *Sym,
302 ISD.
Section = getCurrentSectionOnly();
303 getAssembler().getIndirectSymbols().push_back(ISD);
310 getAssembler().registerSymbol(*Symbol);
399 void MCMachOStreamer::EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
401 getAssembler().registerSymbol(*Symbol);
402 cast<MCSymbolMachO>(
Symbol)->setDesc(DescValue);
405 void MCMachOStreamer::EmitCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
410 getAssembler().registerSymbol(*Symbol);
415 void MCMachOStreamer::EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
416 unsigned ByteAlignment) {
418 return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
419 Symbol, Size, ByteAlignment);
423 uint64_t Size,
unsigned ByteAlignment,
429 getContext().reportError(
430 Loc,
"The usage of .zerofill is restricted to sections of " 431 "ZEROFILL type. Use .zero or .space instead.");
437 SwitchSection(Section);
441 EmitValueToAlignment(ByteAlignment, 0, 1, 0);
451 uint64_t Size,
unsigned ByteAlignment) {
452 EmitZerofill(Section, Symbol, Size, ByteAlignment);
455 void MCMachOStreamer::EmitInstToData(
const MCInst &Inst,
462 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
473 void MCMachOStreamer::FinishImpl() {
474 EmitFrames(&getAssembler().getBackend());
482 for (
const MCSymbol &Symbol : getAssembler().symbols()) {
483 if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.
isInSection() &&
487 "Invalid offset in atom defining symbol!");
495 const MCSymbol *CurrentAtom =
nullptr;
498 CurrentAtom = Symbol;
499 Frag.setAtom(CurrentAtom);
507 std::unique_ptr<MCAsmBackend> &&MAB,
508 std::unique_ptr<MCObjectWriter> &&OW,
509 std::unique_ptr<MCCodeEmitter> &&CE,
510 bool RelaxAll,
bool DWARFMustBeAtTheEnd,
511 bool LabelSections) {
513 new MCMachOStreamer(Context, std::move(MAB), std::move(OW), std::move(CE),
514 DWARFMustBeAtTheEnd, LabelSections);
518 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.
void setCommon(uint64_t Size, unsigned Align, bool Target=false)
Mark this symbol as being 'common'.
.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.
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)
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)
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
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
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)