Add a handful of compiler options to harden code #8551
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The following compile-time warning options are added:
Enable additional format function warnings. The
2
form of theoption enables more extensive checks in calls to
printf
,scanf
etc. These are compile-time only checks, no effect on runtime
performance.
Warn when a switch case falls through. If this is an intended
-action, it can be marked with the
[[fallthrough]]
attributeEnable warnings about trampolines that require executable stacks.
The following options which affect the generated code are added:
Enable run-time checks for variable-size stack allocation validity.
This may affect performance if code allocates a lot of memory on the
stack, but since we don't do that, we should be fine.
Consider trailing array (at the end of struct) as flexible array
only if declared as
[]
Enable control flow protection to counter Return Oriented
Programming (ROP) and Jump Oriented Programming (JOP) attacks on
many x86 architectures
Enable branch protection to counter Return Oriented
Programming (ROP) and Jump Oriented Programming (JOP) attacks on
AArch64