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

    <tr>
        <th>Summary</th>
        <td>
            [LLD] Stride mismatch when using EHcont, also not set in GuardFlags
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    The EHcont table uses the same stride as the CF table. These tables can have a stride, which is marked in GuardFlags, [see MSDN](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-load-configuration-structure-image-only):

> Mask for the subfield that contains the stride of Control Flow Guard function table entries (that is, the additional count of bytes per table entry).

These are mismatched. LLD unconditionally leaves the stride at 0, however it writes the EHcont table with a stride of 1: 

https://github.com/llvm/llvm-project/blob/8ab62da18d47fa0ce6aef9da50cca34a26ea775c/lld/COFF/Writer.cpp#L1799

this results in tha only every fifth EHcont entry actually works:

![image](https://github.com/llvm/llvm-project/assets/8676443/5f6736a2-3e92-452d-95a5-e9d8278a8e6b)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlEuP4zYMxz-NciEc2PL74MPOZN0eZtvDLtAzLdGROrIU6DHB9NMXcpJ2puihvfghUOSPf_5BDEGfLdHE2ifWng6YonJ-srjhH8EdFiffpx-K4OvPwtkIERdDkAIFiIog4EYQoteSAG9Hz_Mt6Ag_FAW6_QQQaEHhGwHe4xl_hqvSQoEOsKF_JQnawk8JvZwNnkMOYO1TIIJv30-_sPbE-KBivARWf2F8Znw2hN4eNy28C26NR-E2xmeyRQqMz1dtpbvev2rO-CxpSWfG5wsVq_MbRsbrqKgwDmUhnF31OXmM2tkiRJ9ETJ4KveGZCmfNO-NjLl2eWPl41l_hG4ZXWJ2_CZKWVZOREBVGyJKhtnetbjK5FZ6djd4ZmI273hqGNVmR694FJhu9pgCMD3sivauRs6CUOgeiAeGSjTnf8h4pwIX8h9sZ9vgR9TYN9ASbDhtGoUge4eXlBMkKZx9ZzTsYwjf6xIwRygyg3JXeyIOOcPU63oM-WeOqo_prxhmuYvUX-AjyeYRnHVVa7pMz5u3xKi7e_U4iMj4vxi2MzwMuHZdYDbLpVywFdUjrKLEthcC6Qd4R9n0r9gSS8fn51zlX-C2T-qO4XBivX6p-HD_SRKUDeArJxJD9FxVCnjXkRt9h1WtUjw53XQFFTLtOV-dfwz8NwSvWPu2W-TfD_oduMQSK2bRD13dNUzM-t2vX1x3yoqaRF03LZTG22BY0yoH3Aw7ULdmbO8FBTrUc6xEPNFXdWHVVWVbNQU1L3Qwch2Uox5KqtW-7hpqK49q1oiNZHvTES16XQzlWY1NWzXFcOrGWbd30y1IvY8uakjbU5piRj86fDzqERFPXtH15MLiQCY894qe9ryWdA2tKo0MMf1-LOpp947y8nFh7gu83tzyMCVdFFlLQ9nyXPpsPTXBgXYRA8fOmOCRvpv8t9M6ehd7x_wwAAP__XRKiOg">