diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-04-29 22:25:40 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-04-29 22:25:40 +0000 |
commit | fb7e32ebd62c8d0e98b2e7bbf53b9db8ebbd5981 (patch) | |
tree | d8cd54978531822cd514d61e82d0a022f7258f27 /llvm/lib/CodeGen | |
parent | e4dd2e01323ab59dfb5766112fa34516f8fe6265 (diff) | |
download | bcm5719-llvm-fb7e32ebd62c8d0e98b2e7bbf53b9db8ebbd5981.tar.gz bcm5719-llvm-fb7e32ebd62c8d0e98b2e7bbf53b9db8ebbd5981.zip |
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>
llvm-svn: 180737
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 84162ace418..4a71ad33373 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/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 // |