[ELF] - Treat .openbsd.randomdata as relro section
authorGeorge Rimar <grimar@accesssoftek.com>
Tue, 20 Dec 2016 11:28:54 +0000 (11:28 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Tue, 20 Dec 2016 11:28:54 +0000 (11:28 +0000)
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
lld/test/ELF/relro.s

index c7ed590..f0563c4 100644 (file)
@@ -500,7 +500,7 @@ template <class ELFT> 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 <class ELFT>
index 5dbf897..b21e514 100644 (file)
@@ -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