[lld] r295283 - Add comments.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 20:51:46 PST 2017
Author: ruiu
Date: Wed Feb 15 22:51:46 2017
New Revision: 295283
URL: http://llvm.org/viewvc/llvm-project?rev=295283&view=rev
Log:
Add comments.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=295283&r1=295282&r2=295283&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Feb 15 22:51:46 2017
@@ -567,18 +567,27 @@ static int getMipsSectionRank(const Outp
return 2;
}
+// Today's loaders have a feature to make segments read-only after
+// processing dynamic relocations to enhance security. PT_GNU_RELRO
+// is defined for that.
+//
+// This function returns true if a section needs to be put into a
+// PT_GNU_RELRO segment.
template <class ELFT> bool elf::isRelroSection(const OutputSectionBase *Sec) {
if (!Config->ZRelro)
return false;
+
uint64_t Flags = Sec->Flags;
if (!(Flags & SHF_ALLOC) || !(Flags & SHF_WRITE))
return false;
if (Flags & SHF_TLS)
return true;
+
uint32_t Type = Sec->Type;
if (Type == SHT_INIT_ARRAY || Type == SHT_FINI_ARRAY ||
Type == SHT_PREINIT_ARRAY)
return true;
+
if (Sec == In<ELFT>::GotPlt->OutSec)
return Config->ZNow;
if (Sec == In<ELFT>::Dynamic->OutSec)
@@ -587,6 +596,7 @@ template <class ELFT> bool elf::isRelroS
return true;
if (Sec == Out<ELFT>::BssRelRo)
return true;
+
StringRef S = Sec->getName();
return S == ".data.rel.ro" || S == ".ctors" || S == ".dtors" || S == ".jcr" ||
S == ".eh_frame" || S == ".openbsd.randomdata";
More information about the llvm-commits
mailing list