[PATCH] D43819: [ELF] - Restrict section offsets that exceeds file size.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 02:08:42 PST 2018
grimar added inline comments.
================
Comment at: ELF/Writer.cpp:1907
+ for (OutputSection *Sec : OutputSections) {
+ bool Overflow = Sec->Offset >= FileSize;
+ if (Sec->Type != SHT_NOBITS)
----------------
jhenderson wrote:
> I don't have a strong feeling here either way, but I wonder if we should worry about empty sections at all? Maybe they shouldn't cause the file to be resized? Also, why do we care whether the start of a NOBITS section is in the file?
>
> Also, assuming the intended behaviour is that the section can start at the end of the file, if it is empty or NOBITS, I think the Overflow check is slightly wrong. If a NOBITS or empty section starts at the very end of the file (i.e. Sec->Offset == FileSize), it will be treated as overflowing as things stand.
Your right. I think we should just ignore all SHT_NOBITS sections in this loop as we newer write them and they can
not be a reason of crash.
https://reviews.llvm.org/D43819
More information about the llvm-commits
mailing list