fix section switching to ensure that stubs are emitted to the right
authorChris Lattner <sabre@nondot.org>
Thu, 16 Jul 2009 01:23:26 +0000 (01:23 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 16 Jul 2009 01:23:26 +0000 (01:23 +0000)
section on ppc.

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

lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp

index 44b0d0c6a3537235894d580dbc67a2cc0e8bdcf6..b74321c6a9fd27623aed0c33d89e135efe9c74e4 100644 (file)
@@ -984,10 +984,10 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
 
   // Output stubs for dynamically-linked functions
   if (TM.getRelocationModel() == Reloc::PIC_ && !FnStubs.empty()) {
-    SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs,"
-                        "pure_instructions,32");
     for (StringMap<FnStubInfo>::iterator I = FnStubs.begin(), E = FnStubs.end();
          I != E; ++I) {
+      SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs,"
+                          "pure_instructions,32");
       EmitAlignment(4);
       const FnStubInfo &Info = I->second;
       O << Info.Stub << ":\n";
@@ -1003,16 +1003,17 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
       O << Info.LazyPtr << "-" << Info.AnonSymbol << ")(r11)\n";
       O << "\tmtctr r12\n";
       O << "\tbctr\n";
+      
       SwitchToDataSection(".lazy_symbol_pointer");
       O << Info.LazyPtr << ":\n";
       O << "\t.indirect_symbol " << I->getKeyData() << '\n';
       O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n";
     }
   } else if (!FnStubs.empty()) {
-    SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs,"
-                        "pure_instructions,16");
     for (StringMap<FnStubInfo>::iterator I = FnStubs.begin(), E = FnStubs.end();
          I != E; ++I) {
+      SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs,"
+                          "pure_instructions,16");
       EmitAlignment(4);
       const FnStubInfo &Info = I->second;
       O << Info.Stub << ":\n";