Fix crash before main on ppc/linux with static constructors. PR1771
authorNick Lewycky <nicholas@mxc.ca>
Sun, 4 Nov 2007 17:32:10 +0000 (17:32 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sun, 4 Nov 2007 17:32:10 +0000 (17:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43676 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCTargetAsmInfo.cpp

index 9ff41cab90c68a072bfd9e6b1a0161ba61a9fe85..53412792180ce4e95517b8380999708052c5e5a7 100644 (file)
@@ -668,6 +668,8 @@ bool LinuxAsmPrinter::doFinalization(Module &M) {
       if (I->hasExternalLinkage()) {
         O << "\t.global " << name << '\n';
         O << "\t.type " << name << ", @object\n";
+        if (TAI->getBSSSection())
+          SwitchToDataSection(TAI->getBSSSection(), I);
         O << name << ":\n";
         O << "\t.zero " << Size << "\n";
       } else if (I->hasInternalLinkage()) {
index 7d9acd9c360f4a6bfcf9b14cc32b16e727c9e4e9..992b090edd519b61c90bdeedd67373ffa7f349d7 100644 (file)
@@ -60,6 +60,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
   HiddenDirective = "\t.private_extern\t";
   SupportsExceptionHandling = false;
   NeedsIndirectEncoding = true;
+  BSSSection = 0;
 
   DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
   DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
@@ -94,6 +95,7 @@ LinuxTargetAsmInfo::LinuxTargetAsmInfo(const PPCTargetMachine &TM)
   StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
   UsedDirective = "\t# .no_dead_strip\t";
   WeakRefDirective = "\t.weak\t";
+  BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
 
   DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits";
   DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits";