C->setFileOff(C->getFileOff() + Off);
}
+template <class ELFT>
void OutputSection::addChunk(Chunk *C) {
Chunks.push_back(C);
C->setOutputSection(this);
C->setFileOff(Off);
Off += C->getSize();
Header.sh_size = Off;
- if (auto SC = dyn_cast<SectionChunk<ELF64LE>>(C))
+ if (auto SC = dyn_cast<SectionChunk<ELFT>>(C)) {
Header.sh_type = SC->getSectionHdr()->sh_type;
+ Header.sh_flags |= SC->getSectionHdr()->sh_flags;
+ }
}
template <class ELFT>
Sec = new (CAlloc.Allocate()) OutputSection(C->getSectionName());
OutputSections.push_back(Sec);
}
- Sec->addChunk(C);
+ Sec->addChunk<ELFT>(C);
}
}
template class Writer<ELF32BE>;
template class Writer<ELF64LE>;
template class Writer<ELF64BE>;
+
+template void OutputSection::addChunk<ELF32LE>(Chunk *);
+template void OutputSection::addChunk<ELF32BE>(Chunk *);
+template void OutputSection::addChunk<ELF64LE>(Chunk *);
+template void OutputSection::addChunk<ELF64BE>(Chunk *);
}
}
OutputSection(StringRef Name) : Name(Name), Header({}) {}
void setVA(uint64_t);
void setFileOffset(uint64_t);
- void addChunk(Chunk *C);
+ template <class ELFT> void addChunk(Chunk *C);
std::vector<Chunk *> &getChunks() { return Chunks; }
template <class ELFT>
void writeHeaderTo(llvm::object::Elf_Shdr_Impl<ELFT> *SHdr);
# CHECK-NEXT: Index: 1
# CHECK-NEXT: Name: (0)
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT: Flags [ (0x0)
+# CHECK-NEXT: Flags [ (0x6)
+# CHECK-NEXT: SHF_ALLOC (0x2)
+# CHECK-NEXT: SHF_EXECINSTR (0x4)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x1000
# CHECK-NEXT: Offset: 0x1000
# CHECK-NEXT: Index: 2
# CHECK-NEXT: Name: (0)
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT: Flags [ (0x0)
+# CHECK-NEXT: Flags [ (0x3)
+# CHECK-NEXT: SHF_ALLOC (0x2)
+# CHECK-NEXT: SHF_WRITE (0x1)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x2000
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: Index: 3
# CHECK-NEXT: Name: (0)
# CHECK-NEXT: Type: SHT_NOBITS (0x8)
-# CHECK-NEXT: Flags [ (0x0)
+# CHECK-NEXT: Flags [ (0x3)
+# CHECK-NEXT: SHF_ALLOC (0x2)
+# CHECK-NEXT: SHF_WRITE (0x1)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x2000
# CHECK-NEXT: Offset: 0x0