From d003c7f39401ba2ca259f2ebee6874a38282616f Mon Sep 17 00:00:00 2001 From: George Rimar Date: Tue, 20 Dec 2016 11:28:54 +0000 Subject: [PATCH] [ELF] - Treat .openbsd.randomdata as relro section That was requested by Mark Kettenis in llvm-dev: "It is the intention that .openbsd.randomdata sections are made read-only after initialization. The native (ld.bfd based) OpenBSD toolchain accomplishes this by including .openbsd.randomdata into the PT_GNU_RELRO segment." He suggested code change, I added testcase. Differential revision: https://reviews.llvm.org/D27974 llvm-svn: 290174 --- lld/ELF/Writer.cpp | 2 +- lld/test/ELF/relro.s | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index c7ed590..f0563c4 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -500,7 +500,7 @@ template bool elf::isRelroSection(const OutputSectionBase *Sec) { return true; StringRef S = Sec->getName(); return S == ".data.rel.ro" || S == ".ctors" || S == ".dtors" || S == ".jcr" || - S == ".eh_frame"; + S == ".eh_frame" || S == ".openbsd.randomdata"; } template diff --git a/lld/test/ELF/relro.s b/lld/test/ELF/relro.s index 5dbf897..b21e514 100644 --- a/lld/test/ELF/relro.s +++ b/lld/test/ELF/relro.s @@ -19,8 +19,8 @@ // CHECK-NEXT: GNU_RELRO // CHECK: Section to Segment mapping: -// FULLRELRO: 05 .dynamic .got .got.plt {{$}} -// PARTRELRO: 05 .dynamic .got {{$}} +// FULLRELRO: 05 .openbsd.randomdata .dynamic .got .got.plt {{$}} +// PARTRELRO: 05 .openbsd.randomdata .dynamic .got {{$}} // NORELRO-NOT: GNU_RELRO @@ -36,3 +36,6 @@ _start: .zero 4 .section .foo,"aw" .section .bss,"",@nobits + +.section .openbsd.randomdata, "aw" +.quad 0 -- 2.7.4