diff options
author | Oren Ben Simhon <oren.ben.simhon@intel.com> | 2018-01-09 08:53:59 +0000 |
---|---|---|
committer | Oren Ben Simhon <oren.ben.simhon@intel.com> | 2018-01-09 08:53:59 +0000 |
commit | 1955fd01bdd56c691bb71410251faaa7feb66f81 (patch) | |
tree | b1bcb89c4431b94f31a359abd67c3cc278965351 /lib/Frontend/CompilerInvocation.cpp | |
parent | 799f997a14464b3d54eeeb03e9ee5f9633a07eb0 (diff) | |
download | clang-1955fd01bdd56c691bb71410251faaa7feb66f81.tar.gz |
Added Control Flow Protection Flag
Cf-protection is a target independent flag that instructs the back-end to instrument control flow mechanisms like: Branch, Return, etc.
For example in X86 this flag will be used to instrument Indirect Branch Tracking instructions.
Differential Revision: https://reviews.llvm.org/D40478
Change-Id: I5126e766c0e6b84118cae0ee8a20fe78cc373dea
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 2252800468..7af58b1794 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -798,6 +798,21 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.CallFEntry = Args.hasArg(OPT_mfentry); Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info); + if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) { + StringRef Name = A->getValue(); + if (Name == "full") { + Opts.CFProtectionReturn = 1; + Opts.CFProtectionBranch = 1; + } else if (Name == "return") + Opts.CFProtectionReturn = 1; + else if (Name == "branch") + Opts.CFProtectionBranch = 1; + else if (Name != "none") { + Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name; + Success = false; + } + } + if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections, OPT_compress_debug_sections_EQ)) { if (A->getOption().getID() == OPT_compress_debug_sections) { |