[lld] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 02:50:51 PDT 2024
smithp35 wrote:
I have sympathy with MaskRay's position in that it is a somewhat arbitrary rule that OutputSections can't affect orphan placement, and may result in surprise given the existing GNU ld documentation (https://sourceware.org/binutils/docs/ld/Orphan-Sections.html).
Having said that I think we may want to define what type and flags our OutputSections without InputSections get their type to given people more stability.
My understanding of GNU ld is that it will by default give the OutputSection SHT_PROGBITS type and "RAW" flags. This can be altered to READONLY with recent releses, although I don't think LLD supports that.
```
READONLY ( TYPE = type )
This form of the syntax combines the READONLY type with the type specified by type.
```
Empiricially LLD seems to inherit the type and flags from a previous OutputSection (I've not checked the code). This largely seems to do the right thing although I'm not convinced that inheriting the "x" flag is the right thing to do.
My, little thought, opening bid would be something like:
* By default, inherit type and flags from the previous output section excluding SHF_EXECINSTR
* If any explicit OutputSection type is used https://sourceware.org/binutils/docs/ld/Output-Section-Type.html default to GNU ld behaviour of "awr" unless READONLY is used.
However that is separate from this pull request. To progress this one do we have an example of one of these sample linker scripts having a problematic Output Section acting as an anchor for orphans, or is it a theoretical risk?
https://github.com/llvm/llvm-project/pull/93761
More information about the llvm-commits
mailing list