[ELF] - Restrict section offsets that exceeds file size.
authorGeorge Rimar <grimar@accesssoftek.com>
Tue, 13 Mar 2018 08:47:17 +0000 (08:47 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Tue, 13 Mar 2018 08:47:17 +0000 (08:47 +0000)
commit2313086726341dab02dc6381071327cb694eb57d
tree433d5fc6d24cc39f639516fcd479625fdc6fc0b7
parent5612bb292c861f41c71abf2cb3e48fff93a3f34f
[ELF] - Restrict section offsets that exceeds file size.

This is part of PR36515.

With some linkerscripts it is possible to get file offset overlaps
and overflows. Currently LLD checks overlaps in checkNoOverlappingSections().
And also we allow broken output with --no-inhibit-exec.
Problem is that sometimes final offset of sections is completely broken
and we calculate output file size wrong and might crash.

Patch implements check to verify that there is no output section
which offset exceeds file size.

Differential revision: https://reviews.llvm.org/D43819

llvm-svn: 327376
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/Inputs/sections-va-overflow.s [new file with mode: 0644]
lld/test/ELF/linkerscript/sections-va-overflow.test [new file with mode: 0644]