Currently both sections will be placed in the same PT_LOAD and therefore
lld generates a contiguous output file containing both sections.
By marking the .vectors section as writable, it will be placed in a
separate PT_LOAD and the resulting file is now only a few kilobytes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for spotting that. I'd personally prefer to fix in the linker script, rather than make the code RW but I don't have a strong preference.
In a magical world where there is spare time, it would be great to make the LLD program header generation more like BFD which I believe will generate separate program headers when the distance between OutputSections is large. Not for this patch though.
lld/test/ELF/arm-exidx-range.s | ||
---|---|---|
6 | This can be also be fixed by replacing this line: |
lld/test/ELF/arm-exidx-range.s | ||
---|---|---|
6 | Thanks, that's a better solution. I thought I'd have to add custom PHDRS to fix this so I used the attribute mismatch to force a new PT_LOAD. |
This reminds me of D79254 and a previous discussion about why RISC-V relaxation is difficult to implement in LLD.
BFD does program header allocation and address assignments in a loop while we don't. We could allocate a new header whenever an output section address is specified but that could waste lots of program header space if we ended up merging many PT_LOAD segments. If we have a loop as well, we can indeed behave more like BFD. The additional complexity needs a lot of thoughts.
This can be also be fixed by replacing this line:
.vectors 0xffff0000 : AT(0xffff0000) : { *(.vectors) } \