summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2010-05-22 00:10:22 +0000
committerEric Christopher <echristo@apple.com>2010-05-22 00:10:22 +0000
commit6fdea1bda839653c05a523e20760997d59dfb030 (patch)
tree6b622f0bae00fe3721d3d056ad5562edd6c83de1 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
parentea465e1847a91f8b62b7f92ecf94a1338a0dc2d1 (diff)
downloadbcm5719-llvm-6fdea1bda839653c05a523e20760997d59dfb030.tar.gz
bcm5719-llvm-6fdea1bda839653c05a523e20760997d59dfb030.zip
Add full bss data support for darwin tls variables.
llvm-svn: 104414
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 50a50750e8b..d0b48b0db8d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -314,7 +314,32 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
// Handle the tbss directive on darwin which is a thread local bss directive
// like zerofill.
if (GVKind.isThreadBSS() && MAI->hasMachoTBSSDirective()) {
- OutStreamer.EmitTBSSSymbol(TheSection, GVSym, Size, 1 << AlignLog);
+ // Emit the .tbss symbol
+ MCSymbol *MangSym =
+ OutContext.GetOrCreateSymbol(GVSym->getName() + Twine("$tlv$init"));
+ OutStreamer.EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog);
+ OutStreamer.AddBlankLine();
+
+ // Emit the variable struct for the runtime.
+ const MCSection *TLVSect
+ = getObjFileLowering().getTLSExtraDataSection();
+
+ OutStreamer.SwitchSection(TLVSect);
+ // Emit the linkage here.
+ EmitLinkage(GV->getLinkage(), GVSym);
+ OutStreamer.EmitLabel(GVSym);
+
+ // Three pointers in size:
+ // - __tlv_bootstrap - used to make sure support exists
+ // - spare pointer, used when mapped by the runtime
+ // - pointer to mangled symbol above with initializer
+ unsigned PtrSize = TD->getPointerSizeInBits()/8;
+ OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("__tlv_bootstrap"),
+ PtrSize, 0);
+ OutStreamer.EmitIntValue(0, PtrSize, 0);
+ OutStreamer.EmitSymbolValue(MangSym, PtrSize, 0);
+
+ OutStreamer.AddBlankLine();
return;
}
OpenPOWER on IntegriCloud