diff --git a/bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h b/bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h --- a/bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h +++ b/bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h @@ -24,7 +24,7 @@ private: uint8_t *allocateSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, - bool IsCode, bool IsReadOnly); + bool IsCode, bool IsWritable); BinaryContext &BC; bool AllowStubs; @@ -59,14 +59,14 @@ unsigned SectionID, StringRef SectionName) override { return allocateSection(Size, Alignment, SectionID, SectionName, - /*IsCode=*/true, true); + /*IsCode=*/true, false); } uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly) override { return allocateSection(Size, Alignment, SectionID, SectionName, - /*IsCode=*/false, IsReadOnly); + /*IsCode=*/false, !IsReadOnly); } // Ignore TLS sections by treating them as a regular data section diff --git a/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp --- a/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp +++ b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp @@ -23,7 +23,7 @@ uint8_t *ExecutableFileMemoryManager::allocateSection( uintptr_t Size, unsigned Alignment, unsigned SectionID, - StringRef SectionName, bool IsCode, bool IsReadOnly) { + StringRef SectionName, bool IsCode, bool IsWritable) { uint8_t *Ret = static_cast(llvm::allocate_buffer(Size, Alignment)); AllocatedSections.push_back(AllocInfo{Ret, Size, Alignment}); @@ -81,7 +81,7 @@ // sections in the input file. BinarySection &NewSection = BC.registerOrUpdateSection( UsePrefix ? NewSecPrefix + SectionName : SectionName, ELF::SHT_PROGBITS, - BinarySection::getFlags(!IsReadOnly, IsCode, true), Ret, Size, + BinarySection::getFlags(IsWritable, IsCode, true), Ret, Size, Alignment); if (UsePrefix) NewSection.setOutputName(SectionName); @@ -90,7 +90,7 @@ LLVM_DEBUG({ dbgs() << "BOLT: allocating " - << (IsCode ? "code" : (IsReadOnly ? "read-only data" : "data")) + << (IsCode ? "code" : (!IsWritable ? "read-only data" : "data")) << " section : " << Section->getOutputName() << " (" << Section->getName() << ")" << " with size " << Size << ", alignment " << Alignment << " at "