<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54247>54247</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            -fcf-protection=branch should generate endbr instead of notrack jumps
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          lvwr
      </td>
    </tr>
</table>

<pre>
    When -fcf-protection=branch is used, the compiler will generate jump tables where the indirect jump is prefixed with the NOTRACK prefix, so it can jump to non-ENDBR targets. Yet, for NOTRACK prefixes to work, the NOTRACK specific enable bit must be set, what renders the binary broken on any environment where this is not the case. In fact, having NOTRACK disabled was a design choice for the Linux kernel CET support [https://lkml.org/lkml/2022/3/7/1068].

With the above, the compiler should generate jump tables with ENDBRs, for proper correctness. And, if security regarding the additional ENDBRs is a concern, the code can be explicitly compiled with -fno-jump-tables.

This was also reported on gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1U11v2zAM_DX2CxFDtvPRPPihbRpg2NABRYFiT4Ms0bYaRTIkOWn260cpSYd2KGBHciiSx7tTa-WpeRnQwKwT3Wx0NqAIypqs3rSOGzGA8jB5lFl1D2FAEHY_Ko0Ojkpr6NGg4wHhddqPEHir0cNxQIfpsDJSOSp4DlOl0WGn3lBSdhjSkcefz0-3998vkdjFW1ABBDeXohaMNbOHx83dE3VwPQZfwC8M8Wxn3acK1J8yjtbtroivcT-iUJ0SgCbihJa67CcfoEXw53LHgQdwaCQ6n3JbZbg7QevsjjiyBrg5Uf5BOWv2aML7rDQbPcaGM0ncYwHfDHRcpMIDPyjTv0ORykcIRAP3wEGiV70BMVglMM0Ui_xQZnqDHTqDGu4fnsFP42hdgGxxN4Qw-qy-zaotPXq314V1_WVLS8Wqipaa3hW9JVveZItNkbFNxm7Pvy9XBXhrD_ifvH6wk5ZfCBxTkyD-KgI5Z6QsYV3U26AnjW5Nco3qiF4xORVOxG3PnYxUpM5Sqmg2ri_VIoecihhBU_-DJDHZgXTCt1EroYI-XZFerDTrjJ1FjLMzxg-jPkd5EtWazOUwskiJJGcvBLEIH-mkP4veTBdG26n_Q1bntCVOjr_puxC9yuqtknRLSja_KZe5bGq5rtc8DwQOmy9v02dayWuto3viA3JC1EULOS52iW-fT043n8DRtFNb0PRRbX24LrHbK0a3bZX3E5Iy28W8mq_yocEK1wu2Zqs5Lspq1ZWlWNYrxtYVW2PJZK55i9o3ZKysqgweIZWgPZkmV010E6vZqoybumAoeLeulosb0TJZtdmc4Z4rXUQckbXcNQkSUeUpqJWnK_se5D66HTG1o_p8CoOljMPR5alvk3D_BdpnjWc">