Hi Chris,<div><br></div><div>Here's a patch to fix MCSectionCOFF, removing IsDirective and the tabs from MCSectionCOFF and fixing TLOF calls to MCSectionCOFF.</div><div><br></div><div>Its been tested with 'make TESTSUITE=CodeGen/X86 check'.</div>

<div><br></div><div>Patch attached and inline.</div><div><br></div><div>Aaron</div><div><br></div><div><div><div>Index: include/llvm/MC/MCSection.h</div><div>===================================================================</div>

<div>--- include/llvm/MC/MCSection.h<span class="Apple-tab-span" style="white-space:pre">       </span>(revision 100074)</div><div>+++ include/llvm/MC/MCSection.h<span class="Apple-tab-span" style="white-space:pre">     </span>(working copy)</div>

<div>@@ -45,23 +45,13 @@</div><div>     // The memory for this string is stored in the same MCContext as *this.</div><div>     StringRef Name;</div><div>     </div><div>-    /// IsDirective - This is true if the section name is a directive, not</div>

<div>-    /// something that should be printed with ".section".</div><div>-    ///</div><div>-    /// FIXME: This is a hack.  Switch to a semantic view of the section instead</div><div>-    /// of a syntactic one.</div>

<div>-    bool IsDirective;</div><div>-    </div><div>-    MCSectionCOFF(StringRef name, bool isDirective, SectionKind K)</div><div>-      : MCSection(K), Name(name), IsDirective(isDirective) {</div><div>-    }</div><div>

+    MCSectionCOFF(StringRef name, SectionKind K) : MCSection(K), Name(name) {}</div><div>   public:</div><div>     </div><div>-    static MCSectionCOFF *Create(StringRef Name, bool IsDirective, </div><div>+    static MCSectionCOFF *Create(StringRef Name, </div>

<div>                                  SectionKind K, MCContext &Ctx);</div><div> </div><div>     StringRef getName() const { return Name; }</div><div>-    bool isDirective() const { return IsDirective; }</div><div>     </div>

<div>     virtual void PrintSwitchToSection(const MCAsmInfo &MAI,</div><div>                                       raw_ostream &OS) const;</div><div>Index: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h</div>

<div>===================================================================</div><div>--- include/llvm/CodeGen/TargetLoweringObjectFileImpl.h<span class="Apple-tab-span" style="white-space:pre">     </span>(revision 100074)</div>

<div>+++ include/llvm/CodeGen/TargetLoweringObjectFileImpl.h<span class="Apple-tab-span" style="white-space:pre">       </span>(working copy)</div><div>@@ -200,8 +200,7 @@</div><div> </div><div>   /// getCOFFSection - Return the MCSection for the specified COFF section.</div>

<div>   /// FIXME: Switch this to a semantic view eventually.</div><div>-  const MCSection *getCOFFSection(StringRef Name, bool isDirective,</div><div>-                                  SectionKind K) const;</div><div>+  const MCSection *getCOFFSection(StringRef Name, SectionKind K) const;</div>

<div> };</div><div> </div><div> } // end namespace llvm</div><div>Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp</div><div>===================================================================</div><div>--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 100074)</div>

<div>+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp<span class="Apple-tab-span" style="white-space:pre">      </span>(working copy)</div><div>@@ -803,7 +803,7 @@</div><div> </div><div> </div><div> const MCSection *TargetLoweringObjectFileCOFF::</div>

<div>-getCOFFSection(StringRef Name, bool isDirective, SectionKind Kind) const {</div><div>+getCOFFSection(StringRef Name, SectionKind Kind) const {</div><div>   // Create the map if it doesn't already exist.</div><div>

   if (UniquingMap == 0)</div><div>     UniquingMap = new MachOUniqueMapTy();</div><div>@@ -813,7 +813,7 @@</div><div>   const MCSectionCOFF *&Entry = Map[Name];</div><div>   if (Entry) return Entry;</div><div> </div>

<div>-  return Entry = MCSectionCOFF::Create(Name, isDirective, Kind, getContext());</div><div>+  return Entry = MCSectionCOFF::Create(Name, Kind, getContext());</div><div> }</div><div> </div><div> void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,</div>

<div>@@ -821,63 +821,51 @@</div><div>   if (UniquingMap != 0)</div><div>     ((COFFUniqueMapTy*)UniquingMap)->clear();</div><div>   TargetLoweringObjectFile::Initialize(Ctx, TM);</div><div>-  TextSection = getCOFFSection("\t.text", true, SectionKind::getText());</div>

<div>-  DataSection = getCOFFSection("\t.data", true, SectionKind::getDataRel());</div><div>+  TextSection = getCOFFSection(".text", SectionKind::getText());</div><div>+  DataSection = getCOFFSection(".data", SectionKind::getDataRel());</div>

<div>   StaticCtorSection =</div><div>-    getCOFFSection(".ctors", false, SectionKind::getDataRel());</div><div>+    getCOFFSection(".ctors", SectionKind::getDataRel());</div><div>   StaticDtorSection =</div>

<div>-    getCOFFSection(".dtors", false, SectionKind::getDataRel());</div><div>+    getCOFFSection(".dtors", SectionKind::getDataRel());</div><div> </div><div>   // FIXME: We're emitting LSDA info into a readonly section on COFF, even</div>

<div>   // though it contains relocatable pointers.  In PIC mode, this is probably a</div><div>   // big runtime hit for C++ apps.  Either the contents of the LSDA need to be</div><div>   // adjusted or this should be a data section.</div>

<div>   LSDASection =</div><div>-    getCOFFSection(".gcc_except_table", false, SectionKind::getReadOnly());</div><div>+    getCOFFSection(".gcc_except_table", SectionKind::getReadOnly());</div><div>   EHFrameSection =</div>

<div>-    getCOFFSection(".eh_frame", false, SectionKind::getDataRel());</div><div>+    getCOFFSection(".eh_frame", SectionKind::getDataRel());</div><div> </div><div>   // Debug info.</div><div>-  // FIXME: Don't use 'directive' mode here.</div>

<div>   DwarfAbbrevSection =</div><div>-    getCOFFSection("\t.section\t.debug_abbrev,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_abbrev", SectionKind::getMetadata());</div>

<div>   DwarfInfoSection =</div><div>-    getCOFFSection("\t.section\t.debug_info,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_info", SectionKind::getMetadata());</div>

<div>   DwarfLineSection =</div><div>-    getCOFFSection("\t.section\t.debug_line,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_line", SectionKind::getMetadata());</div>

<div>   DwarfFrameSection =</div><div>-    getCOFFSection("\t.section\t.debug_frame,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_frame", SectionKind::getMetadata());</div>

<div>   DwarfPubNamesSection =</div><div>-    getCOFFSection("\t.section\t.debug_pubnames,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_pubnames", SectionKind::getMetadata());</div>

<div>   DwarfPubTypesSection =</div><div>-    getCOFFSection("\t.section\t.debug_pubtypes,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_pubtypes", SectionKind::getMetadata());</div>

<div>   DwarfStrSection =</div><div>-    getCOFFSection("\t.section\t.debug_str,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_str", SectionKind::getMetadata());</div>

<div>   DwarfLocSection =</div><div>-    getCOFFSection("\t.section\t.debug_loc,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_loc", SectionKind::getMetadata());</div>

<div>   DwarfARangesSection =</div><div>-    getCOFFSection("\t.section\t.debug_aranges,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_aranges", SectionKind::getMetadata());</div>

<div>   DwarfRangesSection =</div><div>-    getCOFFSection("\t.section\t.debug_ranges,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_ranges", SectionKind::getMetadata());</div>

<div>   DwarfMacroInfoSection =</div><div>-    getCOFFSection("\t.section\t.debug_macinfo,\"dr\"",</div><div>-                   true, SectionKind::getMetadata());</div><div>+    getCOFFSection(".debug_macinfo", SectionKind::getMetadata());</div>

<div> }</div><div> </div><div> const MCSection *TargetLoweringObjectFileCOFF::</div><div> getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,</div><div>                          Mangler *Mang, const TargetMachine &TM) const {</div>

<div>-  return getCOFFSection(GV->getSection(), false, Kind);</div><div>+  return getCOFFSection(GV->getSection(), Kind);</div><div> }</div><div> </div><div> static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) {</div>

<div>@@ -901,7 +889,7 @@</div><div>     SmallString<128> Name(Prefix, Prefix+strlen(Prefix));</div><div>     MCSymbol *Sym = Mang->getSymbol(GV);</div><div>     Name.append(Sym->getName().begin(), Sym->getName().end());</div>

<div>-    return getCOFFSection(Name.str(), false, Kind);</div><div>+    return getCOFFSection(Name.str(), Kind);</div><div>   }</div><div> </div><div>   if (Kind.isText())</div><div>Index: lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp</div>

<div>===================================================================</div><div>--- lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp<span class="Apple-tab-span" style="white-space:pre">     </span>(revision 100074)</div><div>+++ lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp<span class="Apple-tab-span" style="white-space:pre">     </span>(working copy)</div>

<div>@@ -594,8 +594,7 @@</div><div> </div><div>       // Output linker support code for dllexported globals on windows.</div><div>       if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {</div><div>-        OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",</div>

<div>-                                                          true,</div><div>+        OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".drectve",</div><div>                                                    SectionKind::getMetadata()));</div>

<div>         for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)</div><div>           O << "\t.ascii \" -export:" << *DLLExportedGlobals[i] << ",data\"\n";</div>

<div>Index: lib/MC/MCSection.cpp</div><div>===================================================================</div><div>--- lib/MC/MCSection.cpp<span class="Apple-tab-span" style="white-space:pre">  </span>(revision 100074)</div>

<div>+++ lib/MC/MCSection.cpp<span class="Apple-tab-span" style="white-space:pre">      </span>(working copy)</div><div>@@ -25,19 +25,17 @@</div><div> //===----------------------------------------------------------------------===//</div>

<div> </div><div> MCSectionCOFF *MCSectionCOFF::</div><div>-Create(StringRef Name, bool IsDirective, SectionKind K, MCContext &Ctx) {</div><div>+Create(StringRef Name, SectionKind K, MCContext &Ctx) {</div><div>   char *NameCopy = static_cast<char*>(</div>

<div>     Ctx.Allocate(Name.size(), /*Alignment=*/1));</div><div>   memcpy(NameCopy, Name.data(), Name.size());</div><div>-  return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()),</div><div>-                                 IsDirective, K);</div>

<div>+  return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()), K);</div><div> }</div><div> </div><div> void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,</div><div>                                          raw_ostream &OS) const {</div>

<div>-  </div><div>-  if (isDirective()) {</div><div>-    OS << getName() << '\n';</div><div>+  if (getName() == StringRef(".text") || getName() == StringRef(".data")) {</div><div>
+    OS << "\t" << getName() << '\n';</div>
<div>     return;</div><div>   }</div><div>   OS << "\t.section\t" << getName() << ",\"";</div><div>@@ -45,5 +43,7 @@</div><div>     OS << 'x';</div><div>   if (getKind().isWriteable())</div>

<div>     OS << 'w';</div><div>+  if (getKind().isMetadata())</div><div>+    OS << "dr";</div><div>   OS << "\"\n";</div><div> }</div><div><br></div></div></div>