[lld] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 15:46:31 PDT 2024
MaskRay wrote:
> > What's the problem? `.other` has a rank of read-only sections. `.orphan` has the same rank and is placed after `.other` with the simplified condition.
>
> Oh, I see, I was too concise. I meant that input sections `.other` if they exist, would also be executable. But, under certain conditions, there might be no `.other` sections in any input files, so the corresponding output section would just be 'A', not 'AX', which would result in the unexpected placement of orphan sections.
>
> Our usage scenario is not a dedicated linker script carefully prepared for a particular application. It is rather a platform/SDK that provides a set of predefined linker scripts, and all developers should use one of them for their applications; it is generally not possible for a developer to tune the linker scripts they use. Also, it doesn't seem feasible to specify all possible input sections in the linker scripts, so we rely on a predictable placement of orphan sections. Thus, I would prefer not to fix what is not broken, unless there is a clear benefit to doing so.
OK, your argument is that .other (`hasInputSection==false`) might be A or AX and you would prefer that an orphan is not placed after it.
My argument is that as long as .other (`hasInputSection==false`) is A, whether or not it has an input section should not change the orphan placement behavior.
I think both arguments are reasonable and no one is significantly better than the other.
I believe we should follow Occam's razor and make the simplification... It's useful to make the rules easier to explain.
.dynsym has a different rank than PROGBITS read-only sections and deserves an explicit output section to make a portable script.
https://github.com/llvm/llvm-project/pull/93761
More information about the llvm-commits
mailing list