[lld] [LLD][ELF] Do not emit __start/__stop for empty sections (PR #96213)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 21 11:34:23 PDT 2024
MaskRay wrote:
> > Behaviors of different visibilities are unified, even if the behavior differs from GNU ld.
>
> Your suggested alternative causes the test `ELF/linkerscript/sections-gc2.s` to fail. How important this is, I'm not sure. Also the emission of the empty section in this test case doesn't feel quite right either.
>
> If the concern is the performance impact of the addition of `if (sym->isLocal() && sym->isUndefined())` to the `.symtab` loop, then perhaps that can be dropped? However, doing so would leave behind the `LOCAL HIDDEN UND` `__start/__stop` symbols, but that's still better than symbols with invalid section indices.
Dropping `if (sym->isLocal() && sym->isUndefined())` helps. With more thinking, I believe we should do #96343 instead. That patch simplifies the code, fixes the incorrect section indexes, and unified the behavior with `__init_array_start`.
Aligning empty section behavior with GNU ld in this particular case isn't useful IMO.
https://github.com/llvm/llvm-project/pull/96213
More information about the llvm-commits
mailing list