[ELF] Set header flags to 0 by default
authorShankar Easwaran <shankare@codeaurora.org>
Thu, 28 Feb 2013 18:36:34 +0000 (18:36 +0000)
committerShankar Easwaran <shankare@codeaurora.org>
Thu, 28 Feb 2013 18:36:34 +0000 (18:36 +0000)
llvm-svn: 176279

lld/lib/ReaderWriter/ELF/DefaultLayout.h
lld/lib/ReaderWriter/ELF/HeaderChunks.h

index 93c23f3..0719b41 100644 (file)
@@ -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(
index 561d3f1..4c81b12 100644 (file)
@@ -72,7 +72,7 @@ Header<ELFT>::Header(const ELFTargetInfo &ti)
   e_ident(llvm::ELF::EI_MAG2, 'L');
   e_ident(llvm::ELF::EI_MAG3, 'F');
   e_ehsize(sizeof(Elf_Ehdr));
-  e_flags(2);
+  e_flags(0);
 }
 
 template <class ELFT>