From 7c3fea7721e421de235917d9454d448f976500fc Mon Sep 17 00:00:00 2001 From: Xiang1 Zhang Date: Thu, 22 Oct 2020 09:46:42 +0800 Subject: [X86] Support customizing stack protector guard Reviewed By: nickdesaulniers, MaskRay Differential Revision: https://reviews.llvm.org/D88631 --- clang/lib/Frontend/CompilerInvocation.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f61a393..ff0df26 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1254,6 +1254,21 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, } Opts.SSPBufferSize = getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags); + + Opts.StackProtectorGuard = + std::string(Args.getLastArgValue(OPT_mstack_protector_guard_EQ)); + + if (Arg *A = Args.getLastArg(OPT_mstack_protector_guard_offset_EQ)) { + StringRef Val = A->getValue(); + unsigned Offset = Opts.StackProtectorGuardOffset; + Val.getAsInteger(10, Offset); + Opts.StackProtectorGuardOffset = Offset; + } + + Opts.StackProtectorGuardReg = + std::string(Args.getLastArgValue(OPT_mstack_protector_guard_reg_EQ, + "none")); + Opts.StackRealignment = Args.hasArg(OPT_mstackrealign); if (Arg *A = Args.getLastArg(OPT_mstack_alignment)) { StringRef Val = A->getValue(); -- cgit v1.1