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

    <tr>
        <th>Summary</th>
        <td>
            [lld] Replicate GNU ld behavior regarding `--dynamic-linker`
        </td>
    </tr>

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

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

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

<pre>
    In reference to: https://lore.kernel.org/all/CAFP8O3Kqx-gdTBFn_hesWzd-6NCpGEz1=fMoJXuX+n4c7sp0Bw@mail.gmail.com/

> GNU ld seems to ignore --dynamic-linker for a position-dependent
executable (ET_EXEC) when there is no DT_NEEDED entry.
ld.lld respects --dynamic-linker in this case. Before this kernel
report, I do not know any user inconvenienced by this difference.
(mold respects --dynamic-linker as well.)
This could be helpful to test an executable with PT_INTERP but no DT_NEEDED.

If we're able to replicate this behavior inside of LLVM lld then it'll make using LLVM to build the Linux kernel inside of Nix a lot easier. It's likely other distros or build environments could benefit from having consistent behavior. I might be able to write this in a PR myself but I am not familiar with the codebase.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8lE9v4zYQxT8NfRlYkCnZsg86xP8Ct1k3CNw2t4ASR9LUFKmSlB3vpy8oq9mkBfYiAcTwcd7vkSOco1oj5my-ZvPtRPS-MTZ_Mc5tTNv1Hu1jf5sURt7ygwaLFVrUJYI3LHmAxvvOseSB8T3je2UsRme0GlVkbM34XijF-H7zsH9e_pb8-vf7tJan9V6_Nej-_C6ni-Ome9x9n7FkW30zv7z2r4yvdVpmrovXV5bGrSAV1cO3NG04Jd6y-GH8Jjt4PP4OSoJDbB14A1RrYxGmU3nToqVyqkif0UJlLAjojCNPRk8ldqglan9Xwncsey8KhcD4cnd6273uNoyv4NqgBt-gRSAH2sD29Hbc7ba7LaD29hbd9ysZKSXBouuw9O7_x1NQIQelcBjBGqvQ5LByx3WXsdgZ6xnfwAGkAW08nLW5gtA36N0gUxp9QU0hAgnF7a4hqRpjGfthfNmanzYkHFxRqYjx1X3LaWjP9EpCgdCg6qpeBaIenQeh4ROjK_kGnk9vh-Np9_IMRe-_oIk-h3So4IqMZxZh2OsNWOwUlcKPBApsxIVMcOdIIpgKnp7--AaBqA_8yTOeKQWtOCP0jnR9L_AGip7uVfBEun8faX5SOtI7CFDGAwpHaCM4BDUHis6obmBCuCDJeWscGDsqor6QNbpF7X9Q0ViRh8qaFkLHuobSaEfOo_YfLiI4QEt1E1Y-HF8t_euWNAh4foH25lBVA7sDiHYIuxItKRL2Dji4Ko3EItyZicwTuUpWYoL5LOMZT_g8nU2aXJYpn2cLWSzSVBSYySor4mIZJ4uFTGYinlDOY57GKz6PebqKZxGmy2oxm1dFlWVJPE9ZGuPwwpS6tOHdTsi5HvNZvFquFhMlClRumA-cKyUZ52FQ2DyUT4u-diyNFTnvfgh48moYKaF-voWXj8TH9_qRucVaWBlYskX831vKFvGktyr_OmVq8k1fjPMgHDn-pp01f2HpGd8PBhzj-9HDJef_BAAA__95IqOn">