llvm.org GIT mirror llvm / fa2eac5
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 Bill Wendling 7 years ago
2 changed file(s) with 16 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
485485 unsigned uid) const;
486486 void EmitLLVMUsedList(const ConstantArray *InitList);
487487 void EmitXXStructorList(const Constant *List, bool isCtor);
488 void EmitTLSInitFuncs(const ConstantArray *InitList);
488489 GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
489490 };
490491 }
12531253 return true;
12541254 }
12551255
1256 if (GV->getName() == "llvm.tls_init_funcs") {
1257 EmitTLSInitFuncs(cast(GV->getInitializer()));
1258 return true;
1259 }
1260
12561261 return false;
12571262 }
12581263
13171322 EmitAlignment(Align);
13181323 EmitXXStructor(Structors[i].second);
13191324 }
1325 }
1326
1327 /// EmitTLSInitFuncs - Emit the TLS initialization functions.
1328 void AsmPrinter::EmitTLSInitFuncs(const ConstantArray *InitList) {
1329 const DataLayout *TD = TM.getDataLayout();
1330 OutStreamer.SwitchSection(getObjFileLowering().getTLSThreadInitSection());
1331 EmitAlignment(Log2_32(TD->getPointerPrefAlignment()));
1332 for (unsigned I = 0, E = InitList->getNumOperands(); I != E; ++I)
1333 EmitGlobalConstant(
1334 dyn_cast(InitList->getOperand(I)->stripPointerCasts()));
13201335 }
13211336
13221337 //===--------------------------------------------------------------------===//