aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-04-29 22:25:40 +0000
committerBill Wendling <isanbard@gmail.com>2013-04-29 22:25:40 +0000
commitfa2eac54e690928592a2bd6c1f8ee0f9b1923d5e (patch)
treeeacd277dab66dffc790872b261e751447502a89c /lib/CodeGen
parent59a0e79631ed851d98cf9c2ba6fa5f9aafdfdc93 (diff)
Emit the TLS initialization function pointers into the correct section.
The `llvm.tls_init_funcs' (created by the front-end) holds pointers to the TLS initialization functions. These need to be placed into the correct section so that they are run before `main()'. <rdar://problem/13733006> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 84162ace41..4a71ad3337 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1254,6 +1254,11 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
return true;
}
+ if (GV->getName() == "llvm.tls_init_funcs") {
+ EmitTLSInitFuncs(cast<ConstantArray>(GV->getInitializer()));
+ return true;
+ }
+
return false;
}
@@ -1320,6 +1325,16 @@ void AsmPrinter::EmitXXStructorList(const Constant *List, bool isCtor) {
}
}
+/// EmitTLSInitFuncs - Emit the TLS initialization functions.
+void AsmPrinter::EmitTLSInitFuncs(const ConstantArray *InitList) {
+ const DataLayout *TD = TM.getDataLayout();
+ OutStreamer.SwitchSection(getObjFileLowering().getTLSThreadInitSection());
+ EmitAlignment(Log2_32(TD->getPointerPrefAlignment()));
+ for (unsigned I = 0, E = InitList->getNumOperands(); I != E; ++I)
+ EmitGlobalConstant(
+ dyn_cast<Constant>(InitList->getOperand(I)->stripPointerCasts()));
+}
+
//===--------------------------------------------------------------------===//
// Emission and print routines
//