[lld] [ELF] adjustOutputSections: don't copy SHF_EXECINSTR when an output does not contain input sections (PR #70911)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 1 02:27:37 PDT 2023
https://github.com/smithp35 approved this pull request.
I think this is an improvement and the code-changes look good to achieve what is in the specification.
I don't think that this change would fully address the change in https://discourse.llvm.org/t/lld-output-section-flag-assignment-behavior/74359 as that had:
```
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .code PROGBITS 0000000010000000 001000 000003 00 AX 0 0 1
[ 2] .CPU0.heap NOBITS 0000000010000040 001003 000400 00 AX 0 0 64
[ 3] .CPU1.heap NOBITS 0000000010000440 001003 000400 00 AX 0 0 64
[ 4] .CPU2.heap NOBITS 0000000010000840 001003 000400 00 AX 0 0 64
```
With this change I think we would have flags of A instead of AX. Leaving a non writeable BSS section which looks a bit odd.
If we start from the assumption that OutputSections with just symbol assignments are most likely to be data then dropping SHF_EXECINSTR makes sense. In the general case (SHT_PROGBITS) we can't tell if the user intended them to be read-only or read-write so we can't justify adding SHF_WRITE. However if the user has used NOLOAD or TYPE=SHT_NOBITS then I think there is a case for adding SHF_WRITE.
I don't have a particularly strong opinion here so happy to go with your original patch if you prefer.
https://github.com/llvm/llvm-project/pull/70911
More information about the llvm-commits
mailing list