<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100109>100109</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`EXCLUDE_FILE` linker script directive is not excluding files in linker script rule-matching
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
partaror
</td>
</tr>
</table>
<pre>
`EXCLUDE_FILE` linker script directive is not excluding files in linker script rule-matching.
Reproducible example:
```bash
#!/usr/bin/env bash
cat >1.c <<\EOF
int foo() { return 1; }
EOF
cat >2.c <<\EOF
int bar() { return 3; }
EOF
cat >script.t <<\EOF
SECTIONS {
FOO : { EXCLUDE_FILE(2.o) *(*.text*) }
BAR : { *(*.text*) }
}
EOF
clang-15 -o 1.o 1.c -c
clang-15 -o 2.o 2.c -c
ld.lld -o a.lld.out 1.o 2.o -T script.t
ld.bfd -o a.bfd.out 1.o 2.o -T script.t
```
Ideally, `1.o(.text)` should match `FOO` output section and `2.o(.text)` should match `BAR` output section. **However, when LLD is used, both `1.o(.text)` and `2.o(.text)` incorrectly matches `FOO` output section.**
Rule-matching is correct when GNU LD is used. (`1.o(.text)` matches `FOO` and `2.o(.text)` matches `BAR`)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VF1v6zYM_TXyCxFDkmMnfvCD8-GtQHED9N4L7G2QZSbWpkiBJKftvx9kZ026NuteBthKQh4eHTIkhffqYBArkq9IvknEEHrrqpNwQTjrktZ2rxUp6Pa39ePPzfb35uFxSwoKWpk_0YGXTp0CdMqhDOqMoDwYGwBfpB46ZQ6wVxo9KPOPCDdonB1FkL0yh5TQDaH1dD7hydlukKrVCPgijieNJKtvIaSg09MK319MPCOcEd4M3hHetMoQ3qA5ww1kPKUIQLItSyWQbB2ffL3dNZNTmQB7awlfEl4CWazAYRicAUayFZDFZoK94d9R8ruUrXAfKbP_QDkVKw2f8H7frn887L59j5STBaDZ7YBk9XjLuz-ML3lqx_t5PSqp04AvYfxVXkUArOqnN4Z_x95VroU5zFgOMwssja-Emfzo42l8rz7dpVp30SPil9QOYYyPuNkPuFbib3S7v6Db_Vfot365FfrQodD6lfA1kIKyWJ_lJdMydrjv7aA7GHs0IprdLprtEE5DAB_73RoQpotO_mX4qn76GJ5ORa5_tc94Rhe1PPdo4PFxEydp8NhFW2tD_7nIu9crI62LQ6lfJw3o7yaRTiLg3RTezmfUcqGb9P3y7SdcJcYslp_K-3jzXcE30KlU0T5KSboq68qsFAlWbMHZIstpRpO-mtM5xZwV7bxklIuiW4pFIbGcy6ItF5glquKUz-mCZ4zNs5ym7R73RZkzmsu97HJG5hSPQulU6_Mxte6QKO8HrBiljJaJFi1qP65Gzg0-w-glnMdN6aoYNGuHgydzqpUP_koTVND4v-_NZHC66kM4-bggeUN4c1ChH9pU2iPhTZRz-ZidnP0DZSC8GZPwhDeXLM8V_ysAAP__sWC9XQ">