[lld] r303926 - When uncompressing sections, remove SHF_COMPRESSED bits. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 15:00:36 PDT 2017


Author: ruiu
Date: Thu May 25 17:00:36 2017
New Revision: 303926

URL: http://llvm.org/viewvc/llvm-project?rev=303926&view=rev
Log:
When uncompressing sections, remove SHF_COMPRESSED bits. NFC.

In this way, the content and the flag is always consistent, which I
think better than removing the bit when input sections reaches the Writer.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=303926&r1=303925&r2=303926&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu May 25 17:00:36 2017
@@ -173,7 +173,8 @@ void InputSectionBase::uncompress() {
   if (Error E = Dec.decompress({OutputBuf, Size}))
     fatal(toString(this) +
           ": decompress failed: " + llvm::toString(std::move(E)));
-  Data = ArrayRef<uint8_t>((uint8_t *)OutputBuf, Size);
+  this->Data = ArrayRef<uint8_t>((uint8_t *)OutputBuf, Size);
+  this->Flags &= ~(uint64_t)SHF_COMPRESSED;
 }
 
 uint64_t SectionBase::getOffset(const DefinedRegular &Sym) const {

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=303926&r1=303925&r2=303926&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu May 25 17:00:36 2017
@@ -259,10 +259,6 @@ void OutputSection::sortCtorsDtors() {
   std::stable_sort(Sections.begin(), Sections.end(), compCtors);
 }
 
-static uint64_t getOutFlags(InputSectionBase *S) {
-  return S->Flags & ~SHF_GROUP & ~SHF_COMPRESSED;
-}
-
 static SectionKey createKey(InputSectionBase *C, StringRef OutsecName) {
   //  The ELF spec just says
   // ----------------------------------------------------------------
@@ -359,7 +355,7 @@ void OutputSectionFactory::addInputSec(I
     return;
   }
 
-  uint64_t Flags = getOutFlags(IS);
+  uint64_t Flags = IS->Flags & ~(uint64_t)SHF_GROUP;
   if (Sec) {
     if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(IS->Flags))
       error("incompatible section flags for " + Sec->Name +

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=303926&r1=303925&r2=303926&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu May 25 17:00:36 2017
@@ -163,7 +163,7 @@ static void combineMergableSections() {
       continue;
 
     StringRef OutsecName = getOutputSectionName(MS->Name);
-    uint64_t Flags = MS->Flags & ~(uint64_t)(SHF_GROUP | SHF_COMPRESSED);
+    uint64_t Flags = MS->Flags & ~(uint64_t)SHF_GROUP;
     uint32_t Alignment = std::max<uint32_t>(MS->Alignment, MS->Entsize);
 
     auto I = llvm::find_if(MergeSections, [=](MergeSyntheticSection *Sec) {




More information about the llvm-commits mailing list