24ea14660b
[ELF] Align the first section of a PT_LOAD even if its type is SHT_NOBITS Reported at https://reviews.llvm.org/D64930#1642223 If the only section of a PT_LOAD is a SHT_NOBITS section (e.g. .bss), we may not align its sh_offset. p_offset of the PT_LOAD will be set to sh_offset, and we will get p_offset!=p_vaddr (mod p_align). If such executable is mapped by the Linux kernel, it will segfault. After D64906, this may happen the non-linker script case. The linker script case has had this issue for a long time. This was fixed by rL321657 (but the test linkerscript/nobits-offset.s failed to test a SHT_NOBITS section), but broken by rL345154. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D66658 Pull in r371013 from upstream lld trunk (by Rui Ueyama): Align output segments correctly Previously, segments were aligned according to their first section's alignment requirements. That was not correct, but segments are also aligned to a page boundary, and a page boundary is usually much larger than a section alignment requirement, so no one noticed this bug before. Now, lld has --nmagic option which sets maxPageSize to 1 to effectively disable page alignment, which reveals the issue. Fixes https://bugs.llvm.org/show_bug.cgi?id=43212 Differential Revision: https://reviews.llvm.org/D67152 Together, these should ensure gpboot.out gets a correctly aligned offset for its .rodata section, and fix "layout constraint violation" errors from objcopy. |
||
---|---|---|
.. | ||
include | ||
lib | ||
tools | ||
utils/TableGen | ||
FREEBSD-Xlist | ||
LICENSE.TXT |