summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringBase.cpp
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2016-08-22 18:26:27 +0000
committerTim Shen <timshen91@gmail.com>2016-08-22 18:26:27 +0000
commita5cc25e50f5be4b339f5da7cb5290f45ef59d172 (patch)
tree30aa9c3e37aa52abc617ef61e7a0c1d214c48f52 /llvm/lib/CodeGen/TargetLoweringBase.cpp
parentec8b8cc5954ac0c7c0ce0a4074cf87488431b980 (diff)
downloadbcm5719-llvm-a5cc25e50f5be4b339f5da7cb5290f45ef59d172.tar.gz
bcm5719-llvm-a5cc25e50f5be4b339f5da7cb5290f45ef59d172.zip
[SSP] Do not set __guard_local to hidden for OpenBSD SSP
__guard_local is defined as long on OpenBSD. If the source file contains a definition of __guard_local, it mismatches with the int8 pointer type used in LLVM. In that case, Module::getOrInsertGlobal() returns a cast operation instead of a GlobalVariable. Trying to set the visibility on the cast operation leads to random segfaults (seen when compiling the OpenBSD kernel, which also runs with stack protection). In the kernel, the hidden attribute does not matter. For userspace code, __guard_local is defined as hidden in the startup code. If a program re-defines __guard_local, the definition from the startup code will either win or the linker complains about multiple definitions (depending on whether the re-defined __guard_local is placed in the common segment or not). It also matches what gcc on OpenBSD does. Thanks Stefan Kempf <sisnkemp@gmail.com> for the patch! Differential Revision: http://reviews.llvm.org/D23674 llvm-svn: 279449
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringBase.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index 4bf02664946..62a3499a276 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -1817,9 +1817,7 @@ Value *TargetLoweringBase::getIRStackGuard(IRBuilder<> &IRB) const {
if (getTargetMachine().getTargetTriple().isOSOpenBSD()) {
Module &M = *IRB.GetInsertBlock()->getParent()->getParent();
PointerType *PtrTy = Type::getInt8PtrTy(M.getContext());
- auto Guard = cast<GlobalValue>(M.getOrInsertGlobal("__guard_local", PtrTy));
- Guard->setVisibility(GlobalValue::HiddenVisibility);
- return Guard;
+ return M.getOrInsertGlobal("__guard_local", PtrTy);
}
return nullptr;
}
OpenPOWER on IntegriCloud