https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128360

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2026-11-02
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Confirmed.

The documentation for cf_check says:

  The 'cf_check' attribute on a function is used to inform the compiler
  that ENDBR instruction should be placed at the function entry when
  '-fcf-protection=branch' is enabled.

and -mmanual-endbr is documented as:

  Insert ENDBR instruction at function entry only via the 'cf_check'
  function attribute.

so a function carrying cf_check should always get ENDBR at entry. However,
rest_of_insert_endbr_and_patchable_area additionally requires
!only_called_directly_p () (or one of the other conditions from the
automatic heuristic), so cf_check is silently ignored for static or
localized functions whose address is not visible to the compiler.

The fix is to let cf_check take precedence over the heuristic, and to use
the heuristic only when -mmanual-endbr is not given:

Reply via email to