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.

llvm-svn: 303926
This commit is contained in:
Rui Ueyama 2017-05-25 22:00:36 +00:00
parent 1c2baad6dd
commit 2f106b4690
3 changed files with 4 additions and 7 deletions

View File

@ -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 {

View File

@ -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(InputSectionBase *IS,
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 +

View File

@ -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) {