diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-10-31 01:26:55 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-10-31 01:26:55 +0000 |
commit | 2e323aa09d57c094f6df0ca424f3b4a2aafc8853 (patch) | |
tree | ecbade383194618317d3849ed6dc48e33a0682b7 | |
parent | 0de0c5da429f8651eeccbcbe68feab23054bd55d (diff) |
Apply Aton's LLVM patch for PR973: Linux ctors / dtors support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31303 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86AsmPrinter.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 60316517a8..9ef0ad1027 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -145,10 +145,11 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { unsigned Align = TD->getPreferredAlignmentLog(I); if (C->isNullValue() && /* FIXME: Verify correct */ + !I->hasSection() && (I->hasInternalLinkage() || I->hasWeakLinkage() || I->hasLinkOnceLinkage() || (Subtarget->isTargetDarwin() && - I->hasExternalLinkage() && !I->hasSection()))) { + I->hasExternalLinkage()))) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (I->hasExternalLinkage()) { O << "\t.globl\t" << name << "\n"; @@ -185,14 +186,14 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { } else if (Subtarget->isTargetCygwin()) { std::string SectionName(".section\t.data$linkonce." + name + - ",\"aw\"\n"); + ",\"aw\""); SwitchToDataSection(SectionName.c_str(), I); O << "\t.globl " << name << "\n" << "\t.linkonce same_size\n"; } else { std::string SectionName("\t.section\t.llvm.linkonce.d." + name + - ",\"aw\",@progbits\n"); + ",\"aw\",@progbits"); SwitchToDataSection(SectionName.c_str(), I); O << "\t.weak " << name << "\n"; } @@ -215,7 +216,24 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { break; } } - SwitchToDataSection(TAI->getDataSection(), I); + // FIXME: special handling for ".ctors" & ".dtors" sections + if (I->hasSection() && + (I->getSection() == ".ctors" || + I->getSection() == ".dtors")) { + std::string SectionName = ".section " + I->getSection(); + + if (Subtarget->isTargetCygwin()) { + SectionName += ",\"aw\""; + } else { + assert(!Subtarget->isTargetDarwin()); + SectionName += ",\"aw\",@progbits"; + } + + SwitchToDataSection(SectionName.c_str()); + } else { + SwitchToDataSection(TAI->getDataSection(), I); + } + break; } default: |