lld: Improve LMARegion handling.
authoremaste <emaste@FreeBSD.org>
Mon, 29 Jan 2018 13:52:42 +0000 (13:52 +0000)
committeremaste <emaste@FreeBSD.org>
Mon, 29 Jan 2018 13:52:42 +0000 (13:52 +0000)
commit8c7b18046db40139fada38da26f81457b5de39d7
treecf8e59b7ee761e3f50762cae121a1e53d69e0675
parentced1ee68d5ea73b07999500291134cfae820c5e2
lld: Improve LMARegion handling.

This fixes the crash reported at [LLVM] PR36083.

The issue is that we were trying to put all the sections in the same
PT_LOAD and crashing trying to write past the end of the file.

This also adds accounting for used space in LMARegion, without it all
3 PT_LOADs would have the same physical address.

Obtained from: LLVM r323449 by Rafael Espindola
contrib/llvm/tools/lld/ELF/LinkerScript.cpp
contrib/llvm/tools/lld/ELF/LinkerScript.h
contrib/llvm/tools/lld/ELF/Writer.cpp