Use OutStreamer.SwitchSection instead of writing out textual section directives.
authorBob Wilson <bob.wilson@apple.com>
Wed, 30 Sep 2009 22:25:37 +0000 (22:25 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 30 Sep 2009 22:25:37 +0000 (22:25 +0000)
Add a new TargetLoweringObjectFileMachO::getConstTextCoalSection method to
get access to that section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83178 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLoweringObjectFile.h
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp

index 454a0940b97420cd3332c66049931f25d3f3951a..821e53783c6170687533bfa6dcb6a9cf8de48bc9 100644 (file)
@@ -301,11 +301,17 @@ public:
                                         SectionKind K) const;
 
   /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
-  /// symbols into.
+  /// text symbols into.
   const MCSection *getTextCoalSection() const {
     return TextCoalSection;
   }
   
+  /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
+  /// we put weak read-only symbols into.
+  const MCSection *getConstTextCoalSection() const {
+    return ConstTextCoalSection;
+  }
+  
   /// getLazySymbolPointerSection - Return the section corresponding to
   /// the .lazy_symbol_pointer directive.
   const MCSection *getLazySymbolPointerSection() const {
index b496a810b02b614cab5845979da5b76305f55d36..5d14a9b4d3f9f0bb61fee65f6717ff5ea967d80c 100644 (file)
@@ -1053,13 +1053,24 @@ void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
       // avoid out-of-range branches that are due a fundamental limitation of
       // the way symbol offsets are encoded with the current Darwin ARM
       // relocations.
-      O << "\t.section __TEXT,__text,regular\n"
-        << "\t.section __TEXT,__textcoal_nt,coalesced\n"
-        << "\t.section __TEXT,__const_coal,coalesced\n";
-      if (RelocM == Reloc::DynamicNoPIC)
-        O << "\t.section __TEXT,__symbol_stub4,symbol_stubs,none,12\n";
-      else
-        O << "\t.section __TEXT,__picsymbolstub4,symbol_stubs,none,16\n";
+      TargetLoweringObjectFileMachO &TLOFMacho = 
+        static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
+      OutStreamer.SwitchSection(TLOFMacho.getTextSection());
+      OutStreamer.SwitchSection(TLOFMacho.getTextCoalSection());
+      OutStreamer.SwitchSection(TLOFMacho.getConstTextCoalSection());
+      if (RelocM == Reloc::DynamicNoPIC) {
+        const MCSection *sect =
+          TLOFMacho.getMachOSection("__TEXT", "__symbol_stub4",
+                                    MCSectionMachO::S_SYMBOL_STUBS,
+                                    12, SectionKind::getText());
+        OutStreamer.SwitchSection(sect);
+      } else {
+        const MCSection *sect =
+          TLOFMacho.getMachOSection("__TEXT", "__picsymbolstub4",
+                                    MCSectionMachO::S_SYMBOL_STUBS,
+                                    16, SectionKind::getText());
+        OutStreamer.SwitchSection(sect);
+      }
     }
   }