[ELF] Rename .bss.rel.ro to .data.rel.ro.bss for some Linker Scripts.
authorPeter Smith <peter.smith@linaro.org>
Fri, 24 Nov 2017 08:48:29 +0000 (08:48 +0000)
committerPeter Smith <peter.smith@linaro.org>
Fri, 24 Nov 2017 08:48:29 +0000 (08:48 +0000)
commit80e4be7eae8e91de6485efbcc5f105d4ddab617b
treee5e0ec1017a044704c607a4a7daee69c84f323b3
parentd95c74ec81738b99e2497b89bcb55ee41d20c980
[ELF] Rename .bss.rel.ro to .data.rel.ro.bss for some Linker Scripts.

LLD uses .bss.rel.ro for read-only copy relocations whereas the ld.bfd and
gold linkers use .data.rel.ro. In some linker scripts including ld.bfd's
internal linker script, the relro sections are placed sequentially assuming
.data.rel.ro is used. LLD's use of .bss.rel.ro means that the copy
relocations get matched into the .bss section causing the relro sections to
be non-contiguous.

This change checks for a .data.rel.ro OutputSection when a linker script
with the SECTIONS command is used. The section will match in the
.data.rel.ro output section and will maintain contiguous relro.

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

Fixes PR35265

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