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

    <tr>
        <th>Summary</th>
        <td>
            [LLD] corrupt input file: version definition index 0 for symbol g_aucPatchArea is out of bounds
        </td>
    </tr>

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

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

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

<pre>
    ```
$ ld.lld -o lsw_test idcs_stub.c.o libidcs_stubs.so

ld.lld: error: corrupt input file: version definition index 0 for symbol g_aucPatchArea is out of bounds
>>> defined in libidcs_stubs.so

ld.lld: error: corrupt input file: version definition index 0 for symbol g_aucPatchDataArea is out of bounds
>>> defined in libidcs_stubs.so

ld.lld: error: corrupt input file: version definition index 0 for symbol writeout_fn_list is out of bounds
>>> defined in libidcs_stubs.so

ld.lld: error: corrupt input file: version definition index 0 for symbol m_test is out of bounds
>>> defined in libidcs_stubs.so

ld.lld: error: corrupt input file: version definition index 0 for symbol reset_fn_list is out of bounds
>>> defined in libidcs_stubs.so
```
libidcs_stubs.so --> libglobal_stubs.so --> vos.o

$ readelf -sW **vos.o** | grep g_aucPatchArea

```
173: 00001000 0x80000 OBJECT  GLOBAL DEFAULT COM g_aucPatchArea
```

$ readelf -sW **libglobal_stubs.so** | grep g_aucPatchArea

```
557: 00036000 524288 OBJECT GLOBAL DEFAULT    25 g_aucPatchArea
450: 00036000 524288 OBJECT GLOBAL DEFAULT    25 g_aucPatchArea
```

$ readelf -sW **libidcs_stubs.so** | grep g_aucPatchArea

```
2431: 005f1000 524288 OBJECT GLOBAL DEFAULT 26 g_aucPatchArea
27650: 005f1000 524288 OBJECT GLOBAL DEFAULT    26 g_aucPatchArea
```
I find that the ver of symbol g_aucPatchArea is VER_NDX_LOCAL.
https://github.com/llvm/llvm-project/blob/6c462fe2112c83b2682ffa3e7b0a70c33ea4ca7e/lld/ELF/InputFiles.cpp#L1530-L1541
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMlm2P4yYQxz8NfjOKxYOxvS_8wpvE1VVut6q2D-8ibMYJLWsiwHt3374iybZKun2401VdCdkjDH9-MzCDVQhmPyM2RN4TucnUEg_ON2v3aOZf0WeD0x8bUtJLoxtCW8ILsDq3VsPKgQ3vdxFDBKPHsAtxGfIxd2DN8HtHyIO7TD09z5OJaAG9dz4Zo_N-OUYw83GJMBmLqfcZfTBuBo2TmU1Mppk1fgAKk_MQPj4NzsJ-p5bxOxXHQ-tRgQnglghugsEtsw6XlcX23M5iqMHM_w_kRkX1hkHfexPRLXE3zTtr0r6-Scyny6F7k3AeA37JAF7n3-0gWK2SjDXD3rpB2dsPzy7kV96mBPaoNNoJVuEnILwlvD0PO5lAqjXsPR5vcutK5BqKVSLFh1JKGaUU6Ic62fBw__V2_QjwVf9w3_aw2XbtD_0jrB--eV37ptT8De-f_f1seCmrC7woE7TkBa_rF_YbdADg8lXtQtIvIfNpMbg-L58bAV4IdmaXE_tHdl6-qsyr8iUC_0YlReB1oRu4dzCZWUM8qAjxgCkJUzb9Zfn_cfv97tvNz7v-Yd32-VnjEOMxENES3hHe7U08pIvKPRHeWfv88lodvfsFx0h4N1g3EN6VY1HyCTljfKzFwMuaT5MSWA1UVXQUAlUxqgpPAprwbtunBd6lqtEZiyEfj0fCRc-koKueyYJluhH6TtypDBtWUUYlK1iRHRpRToqNtR4nPUzsTqlCjuUdsqFmCktdZabhlAvGeEU5K2WRoxoHiapmSupJaiQFxSdlbJ6cyZ3fZyaEBZtKFJXIrBrQhper3jcnj4dlH0hBU6UKf0yLJtrTT0Hfb4jc_Jf3c7Z423zy9pz8CoR3J9d-CwAA__9a-rWn">