From cbb2514d510b49bad9a4f2787ac49e4f905b20e1 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. llvm-svn: 172450 --- llvm/lib/MC/WinCOFFStreamer.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/MC/WinCOFFStreamer.cpp') diff --git a/llvm/lib/MC/WinCOFFStreamer.cpp b/llvm/lib/MC/WinCOFFStreamer.cpp index 5489ef8d89d..cc2c272f38b 100644 --- a/llvm/lib/MC/WinCOFFStreamer.cpp +++ b/llvm/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