Support x86 Indirect Branch Tracking. #557
Open
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.
This PR adds support for IBT, a control-flow integrity mechanism in the x86 architecture. It adds
endbr64
instructions at function entry points, so that they can be called via a pointer, and anotrack
prefix for jumps through jump tables.These instructions are generated if the
-fcf-protection=branch
option is given on the command-line. On BSD systems,-fcf-protection=branch
is the default and-fcf-protection=none
can be given to turn IBT off.If
-fcf-protection=branch
is given, appropriate ELF annotations are added to object files so that the Linux linker and loader can activate IBT at run-time if all object files have been compiled with-fcf-protection=branch
. (OpenBSD ignores this annotation and activates IBT by default, except if the program was linked with-z nobtcfi
.)Few Intel processors and no AMD processors support IBT in hardware. On other processors, the special IBT instructions are treated like NOPs. I have not been able to test that this PR actually implements IBT. I just tested that the generated code works fine on non-IBT-enabled processors and carries the ELF annotations that Linux expects.
Fixes: #556.