Skip to content

Commit 2518433

Browse files
committed
Make __stack_chk_guard dso_local if Reloc::Static
This is currently implied by TargetMachine::shouldAssumeDSOLocal but will be changed in the future.
1 parent 54971c3 commit 2518433

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,10 +1969,13 @@ Value *TargetLoweringBase::getIRStackGuard(IRBuilder<> &IRB) const {
19691969
// Currently only support "standard" __stack_chk_guard.
19701970
// TODO: add LOAD_STACK_GUARD support.
19711971
void TargetLoweringBase::insertSSPDeclarations(Module &M) const {
1972-
if (!M.getNamedValue("__stack_chk_guard"))
1973-
new GlobalVariable(M, Type::getInt8PtrTy(M.getContext()), false,
1974-
GlobalVariable::ExternalLinkage,
1975-
nullptr, "__stack_chk_guard");
1972+
if (!M.getNamedValue("__stack_chk_guard")) {
1973+
auto *GV = new GlobalVariable(M, Type::getInt8PtrTy(M.getContext()), false,
1974+
GlobalVariable::ExternalLinkage, nullptr,
1975+
"__stack_chk_guard");
1976+
if (getTargetMachine().getRelocationModel() == Reloc::Static)
1977+
GV->setDSOLocal(true);
1978+
}
19761979
}
19771980

19781981
// Currently only support "standard" __stack_chk_guard.

0 commit comments

Comments
 (0)