Add a comment for PPC64 .toc and GNU relro.
authorRui Ueyama <ruiu@google.com>
Wed, 24 Oct 2018 21:59:48 +0000 (21:59 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 24 Oct 2018 21:59:48 +0000 (21:59 +0000)
llvm-svn: 345204

lld/ELF/Writer.cpp

index 1962e7c20dea67e9a94a222b5a0a390e313c333d..4f764593b6ba47ffb6835cd70a6a3040f7c65d25 100644 (file)
@@ -673,6 +673,11 @@ static bool isRelroSection(const OutputSection *Sec) {
   if (In.Got && Sec == In.Got->getParent())
     return true;
 
+  // .toc is a GOT-ish section for PowerPC64. Their contents are accessed
+  // through r2 register, which is reserved for that purpose. Since r2 is used
+  // for accessing .got as well, .got and .toc need to be close enough in the
+  // virtual address space. Usually, .toc comes just after .got. Since we place
+  // .got into RELRO, .toc needs to be placed into RELRO too.
   if (Sec->Name.equals(".toc"))
     return true;