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

    <tr>
        <th>Summary</th>
        <td>
            LLD does not report forward reference errors in linker script
        </td>
    </tr>

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

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

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

<pre>
    Unlike GNU LD, LLD does not report forward reference error. This can result in unexpected output image layout.

Reproducible example:

```bash
#!/usr/bin/env bash

cat >1.c <<\EOF
int foo() { return 1; }
int bar() { return 3; }
EOF

cat >script.t <<\EOF
SECTIONS {
  FOO ALIGN(ADDR(BAR), 0x1000) : {
 *(*foo*)
  }
  BAR : {
    *(*bar*)
 }
}
EOF

clang-15 -o 1.o 1.c -c -ffunction-sections
ld.bfd -o 1.bfd.elf 1.o -T script.t # reports the error, "ld.bfd:script.t:2: non constant or forward reference address expression for section FOO"
ld.lld -o 1.lld.elf 1.o -T script.t # Links fine; no error or warning reported related to forward reference
```

If the decision to not report forward references in linker script diagnostics is intentional, then can anyone please tell why is it so when it can lead to unexpected final layout?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVNFu4yoQ_Rr8MoqFwUmcBz84Tb2qFLVSt_sBGMYxtwQswNv2769wvG12u73SlRxGgnOYcyYziBD0ySLWZL0n60Mmpjg4X4_CR-Gdzzqn3uof1uhnhG_3P-B4IOwGjscDKIcBrIvgcXQ-Qu_8i_AKPPbo0UoE9N75HJ4GHUAKCx7DZCJoC5PF1xFlRAVuiuMUQZ_FCcGINzfFnNADoc1lfcTROzVJ3RkEfBXn0SDhzTWEbOjl60QYli3GCSsIa6fgCWs7bQlr0f6EK8i8ShGB8Nsil0D4TfrWN7cP7eVQ22TLEVYRtgOy3YPHOHkLBeF7INvDB6wT_jOM_wZ7v_a3zEF6PcY8_iX999ubp7uH--_pyssOQPvwAM3x7ts9YVVzODwSVu2bR8J26W-hrwWldBbBmysWYc0srpnNNAm9XPcuDmDfPP5BA_hgzv6umO_EL-0ZYU-rYg0rB0WefhJWElZ9P1kZtbOrgHMMF7xRederC7rrVY6mn3mrJ_goEeNLtwWIw9JgyThh7MInvPmFJrxhyY91FqSzIQobwfm_9KlQymMIgK9jitrZBIJFXyo5YexdpTGLSmO-VnnU9jlAry2mFrDuIjWlfxHeantafGDSYUSK0X2W9kd_X9f3rp9LoFDqWXF0_zmMIY2d0fYZ_aIUlBYn60LUMoBO5xFtMixMKmkc0M5TK-ybswijQREQIhoDL8PbzIgQHLwkoI4z1qCYjVzNd6-tMMtgE760SKZqrnZ8JzKsiy3dbKtttS6zoRZqh7zCUlZU7XjHy40SqqxKLjaiKDeY6ZpRVlJGi6Ioy6LMe7opZbGWXHYoNhUjJcWz0CY35uc5d_6U6RAmrCvKtpvMiA5N-PXY-TqBVt10CqSkRocYPmhRR4P1_3jpPpc4m7yphxjHkF4s1hLWnnQcpi6X7kxYm3ItYTV69w_KSFg76w2EtbPkfwMAAP__UG26LQ">