[PATCH] D66658: [ELF] Align the first section of a PT_LOAD even if its type is SHT_NOBITS
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 08:19:30 PDT 2019
MaskRay created this revision.
MaskRay added reviewers: grimar, pcc, peter.smith, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
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 <https://reviews.llvm.org/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 <https://reviews.llvm.org/rL321657> (but the test linkerscript/nobits-offset.s
failed to test a SHT_NOBITS section), but broken by rL345154 <https://reviews.llvm.org/rL345154>.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D66658
Files:
ELF/Writer.cpp
test/ELF/linkerscript/nobits-offset.s
test/ELF/nobits-offset.s
test/ELF/relocatable.s
test/ELF/relocation-copy-align-common.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66658.216857.patch
Type: text/x-patch
Size: 4070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190823/f511daaf/attachment.bin>
More information about the llvm-commits
mailing list