[PATCH] D111717: [ELF] Avoid adding orphan sections to a less fit segment
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 15 11:23:49 PDT 2021
MaskRay added a comment.
Adding an orphan before the (previously) first section of a segment can create unintended effects (say the user specifies output section address for the first section).
We have quite refined `RankFlags`. If the needle section `sec` mostly matches the first section but has a refined rank, it makes sense to ignore the additional bits in this case.
It may be useful to strengthen the test by leveraging non-PROGBITS and PROGBITS read-only sections (`RF_RODATA`).
Am I right that this makes our behavior closer to ld.bfd? If yes, this looks quite nice.
---
As of PT_GNU_RELRO, this may be another fallout of our default `-z relro`. We probably shouldn't change it now.
If a generic improvement like this patch makes the relro issue moot, that is certainly great.
================
Comment at: lld/test/ELF/linkerscript/orphan-phdrs2.test:12
+# CHECK: LOAD {{.*}} R E
+# CHECK: LOAD {{.*}} RW
+
----------------
CHECK-NEXT:
================
Comment at: lld/test/ELF/linkerscript/orphan-phdrs2.test:15
+# CHECK: Segment Sections...
+# CHECK-NOT: 00{{.*}} .dynamic
+# CHECK: 01 .data .dynamic
----------------
NOT is not needed. A positive CHECK exists.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111717/new/
https://reviews.llvm.org/D111717
More information about the llvm-commits
mailing list