aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandra Loosemore <sloosemore@baylibre.com>2025-04-05 16:36:35 +0000
committerSandra Loosemore <sloosemore@baylibre.com>2025-04-05 16:41:20 +0000
commit3026daa8edcc0d04ba6facdab84c5854255e55c6 (patch)
treed55eebe206750ffd049854f21e0b0fddf9f85b99
parent5b9fd65726afef37ed6a6e39f0ceb7f47160ba07 (diff)
downloadgcc-3026daa8edcc0d04ba6facdab84c5854255e55c6.zip
gcc-3026daa8edcc0d04ba6facdab84c5854255e55c6.tar.gz
gcc-3026daa8edcc0d04ba6facdab84c5854255e55c6.tar.bz2
Docs: Document -fcf-protection without argument [PR112589]
gcc/ChangeLog PR middle-end/112589 * common.opt (-fcf-protection): Add documentation string. * doc/invoke.texi (Option Summary): Add entry for -fcf-protection without argument. (Instrumentation Options): Tidy the -fcf-protection entry and and add documention for the form without an argument.
-rw-r--r--gcc/common.opt1
-rw-r--r--gcc/doc/invoke.texi27
2 files changed, 19 insertions, 9 deletions
diff --git a/gcc/common.opt b/gcc/common.opt
index b9e74cd..2c8fdde 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2055,6 +2055,7 @@ Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET) Set(4)
fcf-protection
Common RejectNegative Alias(fcf-protection=,full)
+Equivalent to -fcf-protection=full.
fcf-protection=
Common Joined RejectNegative Enum(cf_protection_level) EnumSet Var(flag_cf_protection) Init(CF_NONE)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4c9af42..8f51ea6 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -673,7 +673,7 @@ Objective-C and Objective-C++ Dialects}.
-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
-fsanitize-trap -fsanitize-trap=@var{style}
-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
--fsanitize-undefined-trap-on-error -fbounds-check
+-fsanitize-undefined-trap-on-error -fbounds-check -fcf-protection
-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
-fharden-compares -fharden-conditional-branches -fhardened
-fharden-control-flow-redundancy -fhardcfr-skip-leaf
@@ -18373,7 +18373,8 @@ operand constant, @code{__sanitizer_cov_trace_cmpf} or
@opindex fcf-protection
@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
-Enable code instrumentation of control-flow transfers to increase
+@itemx -fcf-protection
+Enable code instrumentation to increase
program security by checking that target addresses of control-flow
transfer instructions (such as indirect function call, function return,
indirect jump) are valid. This prevents diverting the flow of control
@@ -18381,22 +18382,30 @@ to an unexpected target. This is intended to protect against such
threats as Return-oriented Programming (ROP), and similarly
call/jmp-oriented programming (COP/JOP).
+The @option{-fcf-protection=} keywords are interpreted as follows.
+
The value @code{branch} tells the compiler to implement checking of
validity of control-flow transfer at the point of indirect branch
-instructions, i.e.@: call/jmp instructions. The value @code{return}
-implements checking of validity at the point of returning from a
-function. The value @code{full} is an alias for specifying both
-@code{branch} and @code{return}. The value @code{none} turns off
-instrumentation.
+instructions, i.e.@: call/jmp instructions.
+
+The value @code{return} implements checking of validity at the point of
+returning from a function.
-To override @option{-fcf-protection}, @option{-fcf-protection=none}
-needs to be added and then with @option{-fcf-protection=xxx}.
+The value @code{full} is an alias for specifying both
+@code{branch} and @code{return}.
The value @code{check} is used for the final link with link-time
optimization (LTO). An error is issued if LTO object files are
compiled with different @option{-fcf-protection} values. The
value @code{check} is ignored at the compile time.
+The value @code{none} turns off instrumentation.
+
+@option{-fcf-protection} is an alias for @option{-fcf-protection=full}.
+To override a previous @option{-fcf-protection} option on the command
+line, add @option{-fcf-protection=none} and then
+@option{-fcf-protection=@var{kind}}.
+
The macro @code{__CET__} is defined when @option{-fcf-protection} is
used. The first bit of @code{__CET__} is set to 1 for the value
@code{branch} and the second bit of @code{__CET__} is set to 1 for