From 7afe0000f60335bc50d19802bdb19b1196de720e Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 22 Mar 2014 19:26:18 +0000 Subject: ARM IAS: properly handle function entries in .thumb When a label is parsed, check if there is type information available for the label. If so, check if the symbol is a function. If the symbol is a function and we are in thumb mode and no explicit thumb_func has been emitted, adjust the symbol data to indicate that the function definition is a thumb function. The application of this inferencing is improved value handling in the object file (the required thumb bit is set on symbols which are thumb functions). It also helps improve compatibility with binutils. The one complication that arises from this handling is the MCAsmStreamer. The default implementation of getOrCreateSymbolData in MCStreamer does not support tracking the symbol data. In order to support the semantics of thumb functions, track symbol data in assembly streamer. Although O(n) in number of labels in the TU, this is already done in various other streamers and as such the memory overhead is not a practical concern in this scenario. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204544 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCAsmStreamer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/MC/MCAsmStreamer.cpp') diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 759058efcb..85d4dd79b3 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -57,6 +57,8 @@ private: EHPrivateExtern = 1 << 2 }; DenseMap FlagMap; + DenseMap SymbolMap; + bool needsSet(const MCExpr *Value); void EmitRegisterName(int64_t Register); @@ -252,6 +254,8 @@ public: void EmitRawTextImpl(StringRef String) override; void FinishImpl() override; + + virtual MCSymbolData &getOrCreateSymbolData(const MCSymbol *Symbol) override; }; } // end anonymous namespace. @@ -1417,6 +1421,15 @@ void MCAsmStreamer::FinishImpl() { EmitFrames(AsmBackend.get(), false); } +MCSymbolData &MCAsmStreamer::getOrCreateSymbolData(const MCSymbol *Symbol) { + MCSymbolData *&Entry = SymbolMap[Symbol]; + + if (!Entry) + Entry = new MCSymbolData(*Symbol, 0, 0, 0); + + return *Entry; +} + MCStreamer *llvm::createAsmStreamer(MCContext &Context, formatted_raw_ostream &OS, bool isVerboseAsm, bool useCFI, -- cgit v1.2.3