From 030f63a397edc20f8f661bac62f7b90cb5cf57bc Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Mon, 14 Jan 2013 19:04:57 +0000 Subject: Expose an InitToTextSection through MCStreamer. The aim of this patch is to fix the following piece of code in the platform-independent AsmParser: void AsmParser::CheckForValidSection() { if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) { TokError("expected section directive before assembly directive"); Out.SwitchSection(Ctx.getMachOSection( "__TEXT", "__text", MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 0, SectionKind::getText())); } } This was added for the "-n" option of llvm-mc. The proposed fix adds another virtual method to MCStreamer, called InitToTextSection. Conceptually, it's similar to the existing InitSections which initializes all common sections and switches to text. The new method is implemented by each platform streamer in a way that it sees fit. So AsmParser can now do this: void AsmParser::CheckForValidSection() { if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) { TokError("expected section directive before assembly directive"); Out.InitToTextSection(); } } Which is much more reasonable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172450 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/WinCOFFStreamer.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/MC/WinCOFFStreamer.cpp') diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index 5489ef8d89..cc2c272f38 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -50,6 +50,7 @@ public: // MCStreamer interface virtual void InitSections(); + virtual void InitToTextSection(); virtual void EmitLabel(MCSymbol *Symbol); virtual void EmitDebugLabel(MCSymbol *Symbol); virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); @@ -173,6 +174,10 @@ void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size, // MCStreamer interface +void WinCOFFStreamer::InitToTextSection() { + SetSectionText(); +} + void WinCOFFStreamer::InitSections() { SetSectionText(); SetSectionData(); -- cgit v1.2.3