[ELF] Give error message when relro sections are not contiguous.
authorPeter Smith <peter.smith@linaro.org>
Thu, 23 Nov 2017 14:53:10 +0000 (14:53 +0000)
committerPeter Smith <peter.smith@linaro.org>
Thu, 23 Nov 2017 14:53:10 +0000 (14:53 +0000)
commitdc3bd88b22b459144a48ef87a78dca1b9e513d58
tree9ec79f27bf697e747282ae62ac18ae3f400f8f1e
parent2365c7814a6481dfcc29306a9e882f7957dbed90
[ELF] Give error message when relro sections are not contiguous.

If a linker script is used that names linker generated synthetic sections
it is possible that the OutputSections for which isRelroSection() is true
are not contiguous. When the relro sections are not contiguous we cannot
describe them with a single PT_GNU_RELRO PHDR. Unfortunately at least one
contemporary dynamic loader only supports one PT_GNU_RELRO PHDR so we
cannot output more than one of these PHDRs. As not including relro
sections in the PHDR will lead to security sensitive sections being
writeable we choose to give an error message instead.

Differential Revision: https://reviews.llvm.org/D40359

[ELF] Skip over empty sections when checking for contiguous relro

llvm-svn: 318920
lld/ELF/Writer.cpp
lld/test/ELF/relro-non-contiguous.s [new file with mode: 0644]