[PATCH] D29086: Restore visibility attribute for OpenBSD's stack guard
Stefan Kempf via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 08:27:48 PST 2017
sisnkemp created this revision.
This diff is from Philip Guenther (guenther at openbsd.org)
and got committed to the OpenBSD tree, see http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/gnu/llvm/lib/CodeGen/TargetLoweringBase.cpp?rev=1.3&content-type=text/x-cvsweb-markup
and http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/gnu/llvm/lib/CodeGen/TargetLoweringBase.cpp.diff?r1=1.2&r2=1.3&f=h
This repairs my previous patch (https://reviews.llvm.org/rL279449) that
missed the fact that removing visibility diff results accesses to
the stack protector look like this:
two loads
=========
movq __guard_local at GOTPCREL(%rip), %rbx
movq (%rbx), %rax
But better is one load only, which is what Philip's diff achieves
movq __guard_local(%rip), %rax
https://reviews.llvm.org/D29086
Files:
lib/CodeGen/TargetLoweringBase.cpp
Index: lib/CodeGen/TargetLoweringBase.cpp
===================================================================
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -1873,7 +1873,10 @@
if (getTargetMachine().getTargetTriple().isOSOpenBSD()) {
Module &M = *IRB.GetInsertBlock()->getParent()->getParent();
PointerType *PtrTy = Type::getInt8PtrTy(M.getContext());
- return M.getOrInsertGlobal("__guard_local", PtrTy);
+ Constant *C = M.getOrInsertGlobal("__guard_local", PtrTy);
+ if (GlobalVariable *G = dyn_cast_or_null<GlobalVariable>(C))
+ G->setVisibility(GlobalValue::HiddenVisibility);
+ return C;
}
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29086.85590.patch
Type: text/x-patch
Size: 685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170124/681b2939/attachment.bin>
More information about the llvm-commits
mailing list