diff options
author | Fangrui Song <i@maskray.me> | 2020-12-04 16:57:45 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2020-12-04 16:57:45 -0800 |
commit | 2518433f861fcb877d0a7bdd9aec1aec1f77505a (patch) | |
tree | 0595287aa26049d9cbdcfc928146bd64e464c87e /llvm/lib/CodeGen/TargetLoweringBase.cpp | |
parent | 54971c3a75594a7055efbad22923e581e6e4e7f7 (diff) | |
download | llvm-2518433f861fcb877d0a7bdd9aec1aec1f77505a.zip llvm-2518433f861fcb877d0a7bdd9aec1aec1f77505a.tar.gz llvm-2518433f861fcb877d0a7bdd9aec1aec1f77505a.tar.bz2 |
Make __stack_chk_guard dso_local if Reloc::Static
This is currently implied by TargetMachine::shouldAssumeDSOLocal
but will be changed in the future.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 23b6245..61a2de7 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1969,10 +1969,13 @@ Value *TargetLoweringBase::getIRStackGuard(IRBuilder<> &IRB) const { // Currently only support "standard" __stack_chk_guard. // TODO: add LOAD_STACK_GUARD support. void TargetLoweringBase::insertSSPDeclarations(Module &M) const { - if (!M.getNamedValue("__stack_chk_guard")) - new GlobalVariable(M, Type::getInt8PtrTy(M.getContext()), false, - GlobalVariable::ExternalLinkage, - nullptr, "__stack_chk_guard"); + if (!M.getNamedValue("__stack_chk_guard")) { + auto *GV = new GlobalVariable(M, Type::getInt8PtrTy(M.getContext()), false, + GlobalVariable::ExternalLinkage, nullptr, + "__stack_chk_guard"); + if (getTargetMachine().getRelocationModel() == Reloc::Static) + GV->setDSOLocal(true); + } } // Currently only support "standard" __stack_chk_guard. |