<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107749>107749</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[lld elf] Segfault within ld-linux in -nostdlib executable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yaram
</td>
</tr>
</table>
<pre>
When linking an executable with `-nostdlib`, no PIE, and no linked dynamic libraries, the executable wil crash with a segmentation fault within `audit_list_add_dynamic_tag` in the ld-linux interpreter. Switching to PIE, or linking any dynamic libraries fixes the crash.
Steps to reproduce:
1. Create some simple `main.c`
```c
void _start() {
while(1);
}
```
2. Run the following commands to generate a minimal object and link it into an executable
```sh
clang -nostdlib -nostdinc -c -o main.o main.c
clang -fuse-ld=lld -nostdlib -o test main.o
```
3.
Run the generated executable, producing the segmentation fault
```sh
./test
```
I suspect the issue is due to missing dynamic segments in the executable trying to be accessed by ld-linux. Perhaps lld or clang frontend is adding the .interp section when it should not be.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VM2OozgQfhpzKQUZEwIcOOx0NtLcRtuHPUbGroB3jR3ZRafz9isD6Un3zkiRgzGu78dfWcZoBofYseobq46ZnGn0obvLIKes9_re_T2iA2vcv8YNIB3gO6qZZG8RboZGYAe-cz6StqZnB87ECzgPP77_mZ6k02mWtqMGfXdyMgqs6YMMBmP6hEb8XNOCCjKOa3UJEYcJHUky3sFFzpaWFeMSspy1obM1kc5S6_MGcCY5sAMH45bqVu-scfM7GEcYrgEJQw6vN0NqTKLog64PT0rv_-cLF_OOcSm6cMwZPzL-xzq-El5jKhbwGryeFbJyWypyeAkoCSH6CSGa6Wox8Z-kcblKtq2FDnz9qXX-5o2GcyQZiImGiRZY_W1dgttoLDLRFEy0rNzesvr4pRKsc5HDX_Nqx8Vb629Jo_LTJJ1eSA_oMCSGEibjzCQt-P4fVLScYXIFDCUH_ecQfIGL4_pCWekG-AjG9mScgp2CnYdF-Pannl3cNl7miDurWXm0Vj_X8UAYadv_BXydltupPPQ-lOln1uIF1kNaAjDiL2L2G2U5E6dE4ZfY6_gd4hyvybtU2cQ4pxH0jMnpycSYUB_p2pDjI65PzUDhvgW0R5BKYYyoob9_RDqHHxhGeY2QbPIBVvsuwTtCpxOq1PqhMV8bACKqReYttbYhiKOfbWpUgh7zTHelbstWZtgVtajqdl9UTTZ2Ldd93WpeFc2-7Ruuy7oQVaEOF95Xui4z0wku9rzlTVEUVVXlTdNUF40CD7qs-qJke46TNDa39m3KfRiyxZyu4HW9bzMre7TxcRWFLn216-chsj1PPR5_7iNDdrm0km60F1Yd4RWHT_fDU98_JeinvdkcbDcSXWNqVHFi4jQYGuc-V35i4pTAtr_dNfjUDEycFsaRidNG-q0T_wUAAP__bxO2Og">