When a section placement (AT) command references the section itself, the physical address of the section in the ELF header was calculated incorrectly due to alignment happening right after the location pointer's value was captured.
Diff Detail
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
Comment Actions
This looks good, but I wonder in what situation you want to define a self-referencing LMA. (I just want to understand the problem better.)
Comment Actions
I ran into this problem when trying to link the Linux kernel with lld. There are a lot of sections defined like this in arm64:
.rodata : AT(ADDR(.rodata) - 0)
Since the linker script is generated, I guess there are situations where an offset is applied to the section address (zero in this case).
Comment Actions
Replaced the patch with Rafael's version, which avoids computing section alignment twice