<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/154658>154658</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Useless .got.plt section being created with `-mcmodel=large` and `-flto`, absent with either removed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
CasualPokePlayer
</td>
</tr>
</table>
<pre>
Functionally, this bug doesn't really cause any issue, other than raising a "false red flag" for a project which relies on there being absolutely no relocations occurring.
For context, I [work with a project](https://github.com/TASEmulators/BizHawk/tree/4906fee/waterbox) which requires that the end build have no reloations, as the "[ld.so](https://github.com/TASEmulators/BizHawk/tree/4906fee/waterbox/waterboxhost)" used (if you can call it that) does not support relocations. As such, .got.plt sections appearing is a red flag potentially indicating something is wrong with the builds.
This setup isn't needed to reproduce the issue anyways, as it appears to be some problem caused by a combination of `-mcmodel=large` and `-flto`. A simple test.c file can be used to see this issue:
```c
void _start(void) {}
```
This will show a .got.plt section being created:
`clang-20 -mcmodel=large -nostdlib -flto -c ./test.c -o test.o ; clang-20 -nostdlib -fuse-ld=lld-20 ./test.o ; objdump -s --section=.got.plt ./a.out`
This omits `-mcmodel=large` and thus will not create the section (and show it is not being created):
`clang-20 -nostdlib -flto -c ./test.c -o test.o ; clang-20 -nostdlib -fuse-ld=lld-20 ./test.o ; objdump -s --section=.got.plt ./a.out`
This omits `-flto` and this will also not create the section (and show it is not being created):
`clang-20 -mcmodel=large -nostdlib -c ./test.c -o test.o ; clang-20 -nostdlib -fuse-ld=lld-20 ./test.o ; objdump -s --section=.got.plt ./a.out`
This is being done on clang 20.1.8 on Debian 11, fetched from llvm's apt repository.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVU2P4zYP_jXKhYjhyHESH3LI7LzB29sC3Z4L2WJs7cqiK1KTTX99ITuZnX5g2kOLFggQGyYpPh8iDbPrA-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