This is an archive of the discontinued LLVM Phabricator instance.

Add -mmanual-endbr switch to allow manual selection of control-flow protection

Authored by gftg on Jan 27 2022, 4:15 AM.



GCC has plans [1] to add a new switch that enables finer-grained control
of the insertion of CET stuff in generated code. This patch duplicates
their implementation within LLVM, in the hope that it can also be used
by Xen maintainers.


  • 8< --

With -fcf-protection=branch, clang automatically adds control-flow
protection to indirect calls and jumps. On X86, this translates to ENDBR
instructions being added to the prologues of functions.

This patch adds a new switch, '-mmanual-endbr', which tells the compiler
that, even though -fcf-protection is in use, functions should not get
the instrumentation automatically. Instead, it allows users to manually
add the new attribute, 'cf_check', to functions that require it.

Depends on D118052.

Diff Detail

Event Timeline

gftg created this revision.Jan 27 2022, 4:15 AM
gftg abandoned this revision.Jan 27 2022, 4:17 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 27 2022, 4:17 AM