aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorserge_sans_paille <sguelton@redhat.com>2019-09-09 16:59:34 +0200
committerserge-sans-paille <sguelton@redhat.com>2020-02-07 19:54:39 +0100
commit4a1a0690ad6813a4c8cdb8dc20ea6337aa1f61e0 (patch)
tree6b9b4ba6201031022276a77f1928174c0932ac28 /clang/lib/Frontend/CompilerInvocation.cpp
parentd06dd29e09b6b03a834ec0639d57446fb8515d12 (diff)
downloadllvm-4a1a0690ad6813a4c8cdb8dc20ea6337aa1f61e0.zip
llvm-4a1a0690ad6813a4c8cdb8dc20ea6337aa1f61e0.tar.gz
llvm-4a1a0690ad6813a4c8cdb8dc20ea6337aa1f61e0.tar.bz2
Support -fstack-clash-protection for x86
Implement protection against the stack clash attack [0] through inline stack probing. Probe stack allocation every PAGE_SIZE during frame lowering or dynamic allocation to make sure the page guard, if any, is touched when touching the stack, in a similar manner to GCC[1]. This extends the existing `probe-stack' mechanism with a special value `inline-asm'. Technically the former uses function call before stack allocation while this patch provides inlined stack probes and chunk allocation. Only implemented for x86. [0] https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt [1] https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00556.html This a recommit of 39f50da2a357a8f685b3540246c5d762734e035f with correct option flags set. Differential Revision: https://reviews.llvm.org/D68720
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 17e1906..dd5b607 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1238,6 +1238,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.NoStackArgProbe = Args.hasArg(OPT_mno_stack_arg_probe);
+ Opts.StackClashProtector = Args.hasArg(OPT_stack_clash_protection);
+
if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
StringRef Name = A->getValue();
unsigned Method = llvm::StringSwitch<unsigned>(Name)