diff options
Diffstat (limited to 'llvm/lib/MC/MCMachOStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCMachOStreamer.cpp | 131 |
1 files changed, 67 insertions, 64 deletions
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index 8e558a36b7a1f..2b1d1b28ea184 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -56,10 +56,10 @@ private: /// labels in the middle of the section. DenseMap<const MCSection*, bool> HasSectionLabel; - void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override; + void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override; - void EmitDataRegion(DataRegionData::KindTy Kind); - void EmitDataRegionEnd(); + void emitDataRegion(DataRegionData::KindTy Kind); + void emitDataRegionEnd(); public: MCMachOStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB, @@ -81,40 +81,40 @@ public: /// @name MCStreamer Interface /// @{ - void ChangeSection(MCSection *Sect, const MCExpr *Subsect) override; - void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; - void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; - void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override; - void EmitAssemblerFlag(MCAssemblerFlag Flag) override; - void EmitLinkerOptions(ArrayRef<std::string> Options) override; - void EmitDataRegion(MCDataRegionType Kind) override; - void EmitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor, + void changeSection(MCSection *Sect, const MCExpr *Subsect) override; + void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; + void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; + void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override; + void emitAssemblerFlag(MCAssemblerFlag Flag) override; + void emitLinkerOptions(ArrayRef<std::string> Options) override; + void emitDataRegion(MCDataRegionType Kind) override; + void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion) override; - void EmitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, + void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion) override; - void EmitThumbFunc(MCSymbol *Func) override; - bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; - void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; - void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, + void emitThumbFunc(MCSymbol *Func) override; + bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; + void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; + void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; - void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, + void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; - void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, + void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, unsigned ByteAlignment = 0, SMLoc Loc = SMLoc()) override; - void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, + void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) override; - void EmitIdent(StringRef IdentString) override { + void emitIdent(StringRef IdentString) override { llvm_unreachable("macho doesn't support this directive"); } - void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override { + void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override { getAssembler().getLOHContainer().addDirective(Kind, Args); } - void FinishImpl() override; + void finishImpl() override; }; } // end anonymous namespace. @@ -123,7 +123,7 @@ static bool canGoAfterDWARF(const MCSectionMachO &MSec) { // These sections are created by the assembler itself after the end of // the .s file. StringRef SegName = MSec.getSegmentName(); - StringRef SecName = MSec.getSectionName(); + StringRef SecName = MSec.getName(); if (SegName == "__LD" && SecName == "__compact_unwind") return true; @@ -146,7 +146,7 @@ static bool canGoAfterDWARF(const MCSectionMachO &MSec) { return false; } -void MCMachOStreamer::ChangeSection(MCSection *Section, +void MCMachOStreamer::changeSection(MCSection *Section, const MCExpr *Subsection) { // Change the section normally. bool Created = changeSectionImpl(Section, Subsection); @@ -155,7 +155,9 @@ void MCMachOStreamer::ChangeSection(MCSection *Section, if (SegName == "__DWARF") CreatedADWARFSection = true; else if (Created && DWARFMustBeAtTheEnd && !canGoAfterDWARF(MSec)) - assert(!CreatedADWARFSection && "Creating regular section after DWARF"); + assert((!CreatedADWARFSection || + Section == getContext().getObjectFileInfo()->getStackMapSection()) + && "Creating regular section after DWARF"); // Output a linker-local symbol so we don't need section-relative local // relocations. The linker hates us when we do that. @@ -167,24 +169,24 @@ void MCMachOStreamer::ChangeSection(MCSection *Section, } } -void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol, +void MCMachOStreamer::emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) { getAssembler().registerSymbol(*Symbol); if (Symbol->isExternal()) - EmitSymbolAttribute(EHSymbol, MCSA_Global); + emitSymbolAttribute(EHSymbol, MCSA_Global); if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition()) - EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition); + emitSymbolAttribute(EHSymbol, MCSA_WeakDefinition); if (Symbol->isPrivateExtern()) - EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern); + emitSymbolAttribute(EHSymbol, MCSA_PrivateExtern); } -void MCMachOStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { +void MCMachOStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) { // We have to create a new fragment if this is an atom defining symbol, // fragments cannot span atoms. if (getAssembler().isSymbolLinkerVisible(*Symbol)) insert(new MCDataFragment()); - MCObjectStreamer::EmitLabel(Symbol, Loc); + MCObjectStreamer::emitLabel(Symbol, Loc); // This causes the reference type flag to be cleared. Darwin 'as' was "trying" // to clear the weak reference and weak definition bits too, but the @@ -196,7 +198,7 @@ void MCMachOStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { cast<MCSymbolMachO>(Symbol)->clearReferenceType(); } -void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { +void MCMachOStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) { MCValue Res; if (Value->evaluateAsRelocatable(Res, nullptr, nullptr)) { @@ -206,30 +208,30 @@ void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { cast<MCSymbolMachO>(Symbol)->setAltEntry(); } } - MCObjectStreamer::EmitAssignment(Symbol, Value); + MCObjectStreamer::emitAssignment(Symbol, Value); } -void MCMachOStreamer::EmitDataRegion(DataRegionData::KindTy Kind) { +void MCMachOStreamer::emitDataRegion(DataRegionData::KindTy Kind) { // Create a temporary label to mark the start of the data region. MCSymbol *Start = getContext().createTempSymbol(); - EmitLabel(Start); + emitLabel(Start); // Record the region for the object writer to use. DataRegionData Data = { Kind, Start, nullptr }; std::vector<DataRegionData> &Regions = getAssembler().getDataRegions(); Regions.push_back(Data); } -void MCMachOStreamer::EmitDataRegionEnd() { +void MCMachOStreamer::emitDataRegionEnd() { std::vector<DataRegionData> &Regions = getAssembler().getDataRegions(); assert(!Regions.empty() && "Mismatched .end_data_region!"); DataRegionData &Data = Regions.back(); assert(!Data.End && "Mismatched .end_data_region!"); // Create a temporary label to mark the end of the data region. Data.End = getContext().createTempSymbol(); - EmitLabel(Data.End); + emitLabel(Data.End); } -void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { +void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) { // Let the target do whatever target specific stuff it needs to do. getAssembler().getBackend().handleAssemblerFlag(Flag); // Do any generic stuff we need to do. @@ -244,51 +246,51 @@ void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { } } -void MCMachOStreamer::EmitLinkerOptions(ArrayRef<std::string> Options) { +void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) { getAssembler().getLinkerOptions().push_back(Options); } -void MCMachOStreamer::EmitDataRegion(MCDataRegionType Kind) { +void MCMachOStreamer::emitDataRegion(MCDataRegionType Kind) { switch (Kind) { case MCDR_DataRegion: - EmitDataRegion(DataRegionData::Data); + emitDataRegion(DataRegionData::Data); return; case MCDR_DataRegionJT8: - EmitDataRegion(DataRegionData::JumpTable8); + emitDataRegion(DataRegionData::JumpTable8); return; case MCDR_DataRegionJT16: - EmitDataRegion(DataRegionData::JumpTable16); + emitDataRegion(DataRegionData::JumpTable16); return; case MCDR_DataRegionJT32: - EmitDataRegion(DataRegionData::JumpTable32); + emitDataRegion(DataRegionData::JumpTable32); return; case MCDR_DataRegionEnd: - EmitDataRegionEnd(); + emitDataRegionEnd(); return; } } -void MCMachOStreamer::EmitVersionMin(MCVersionMinType Kind, unsigned Major, +void MCMachOStreamer::emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion) { getAssembler().setVersionMin(Kind, Major, Minor, Update, SDKVersion); } -void MCMachOStreamer::EmitBuildVersion(unsigned Platform, unsigned Major, +void MCMachOStreamer::emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion) { getAssembler().setBuildVersion((MachO::PlatformType)Platform, Major, Minor, Update, SDKVersion); } -void MCMachOStreamer::EmitThumbFunc(MCSymbol *Symbol) { +void MCMachOStreamer::emitThumbFunc(MCSymbol *Symbol) { // Remember that the function is a thumb function. Fixup and relocation // values will need adjusted. getAssembler().setIsThumbFunc(Symbol); cast<MCSymbolMachO>(Symbol)->setThumbFunc(); } -bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Sym, +bool MCMachOStreamer::emitSymbolAttribute(MCSymbol *Sym, MCSymbolAttr Attribute) { MCSymbolMachO *Symbol = cast<MCSymbolMachO>(Sym); @@ -324,6 +326,7 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Sym, case MCSA_ELF_TypeCommon: case MCSA_ELF_TypeNoType: case MCSA_ELF_TypeGnuUniqueObject: + case MCSA_Extern: case MCSA_Hidden: case MCSA_IndirectSymbol: case MCSA_Internal: @@ -396,13 +399,13 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Sym, return true; } -void MCMachOStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { +void MCMachOStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { // Encode the 'desc' value into the lowest implementation defined bits. getAssembler().registerSymbol(*Symbol); cast<MCSymbolMachO>(Symbol)->setDesc(DescValue); } -void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, +void MCMachOStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself. assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); @@ -412,14 +415,14 @@ void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Symbol->setCommon(Size, ByteAlignment); } -void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, +void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { // '.lcomm' is equivalent to '.zerofill'. - return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(), + return emitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(), Symbol, Size, ByteAlignment); } -void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, +void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment, SMLoc Loc) { // On darwin all virtual sections have zerofill type. Disallow the usage of @@ -438,21 +441,21 @@ void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, // The symbol may not be present, which only creates the section. if (Symbol) { - EmitValueToAlignment(ByteAlignment, 0, 1, 0); - EmitLabel(Symbol); - EmitZeros(Size); + emitValueToAlignment(ByteAlignment, 0, 1, 0); + emitLabel(Symbol); + emitZeros(Size); } PopSection(); } // This should always be called with the thread local bss section. Like the // .zerofill directive this doesn't actually switch sections on us. -void MCMachOStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, +void MCMachOStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { - EmitZerofill(Section, Symbol, Size, ByteAlignment); + emitZerofill(Section, Symbol, Size, ByteAlignment); } -void MCMachOStreamer::EmitInstToData(const MCInst &Inst, +void MCMachOStreamer::emitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) { MCDataFragment *DF = getOrCreateDataFragment(); @@ -470,8 +473,8 @@ void MCMachOStreamer::EmitInstToData(const MCInst &Inst, DF->getContents().append(Code.begin(), Code.end()); } -void MCMachOStreamer::FinishImpl() { - EmitFrames(&getAssembler().getBackend()); +void MCMachOStreamer::finishImpl() { + emitFrames(&getAssembler().getBackend()); // We have to set the fragment atom associations so we can relax properly for // Mach-O. @@ -500,7 +503,7 @@ void MCMachOStreamer::FinishImpl() { } } - this->MCObjectStreamer::FinishImpl(); + this->MCObjectStreamer::finishImpl(); } MCStreamer *llvm::createMachOStreamer(MCContext &Context, @@ -513,7 +516,7 @@ MCStreamer *llvm::createMachOStreamer(MCContext &Context, new MCMachOStreamer(Context, std::move(MAB), std::move(OW), std::move(CE), DWARFMustBeAtTheEnd, LabelSections); const Triple &Target = Context.getObjectFileInfo()->getTargetTriple(); - S->EmitVersionForTarget(Target, Context.getObjectFileInfo()->getSDKVersion()); + S->emitVersionForTarget(Target, Context.getObjectFileInfo()->getSDKVersion()); if (RelaxAll) S->getAssembler().setRelaxAll(true); return S; |