summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/DefaultLayout.h
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/DefaultLayout.h')
-rw-r--r--lld/lib/ReaderWriter/ELF/DefaultLayout.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/ELF/DefaultLayout.h b/lld/lib/ReaderWriter/ELF/DefaultLayout.h
index 93c23f3fbd8..0719b41b964 100644
--- a/lld/lib/ReaderWriter/ELF/DefaultLayout.h
+++ b/lld/lib/ReaderWriter/ELF/DefaultLayout.h
@@ -566,7 +566,10 @@ template <class ELFT> void DefaultLayout<ELFT>::assignSectionsToSegments() {
section->setSegmentType(segmentType);
StringRef segmentName = section->segmentKindToStr();
- int64_t sectionFlag = msi->flags();
+ int64_t lookupSectionFlag = msi->flags();
+ if (!(lookupSectionFlag & llvm::ELF::SHF_WRITE))
+ lookupSectionFlag &= ~llvm::ELF::SHF_EXECINSTR;
+ lookupSectionFlag &= ~(llvm::ELF::SHF_STRINGS | llvm::ELF::SHF_MERGE);
Segment<ELFT> *segment;
// We need a seperate segment for sections that dont have
@@ -589,7 +592,7 @@ template <class ELFT> void DefaultLayout<ELFT>::assignSectionsToSegments() {
}
// Use the flags of the merged Section for the segment
- const SegmentKey key("PT_LOAD", sectionFlag);
+ const SegmentKey key("PT_LOAD", lookupSectionFlag);
const std::pair<SegmentKey, Segment<ELFT> *> currentSegment(key,
nullptr);
std::pair<typename SegmentMapT::iterator, bool> segmentInsert(
OpenPOWER on IntegriCloud