[lld] r243579 - [ELF2] Templatize addChunk and handle section flags.
Michael J. Spencer
bigcheesegs at gmail.com
Wed Jul 29 15:14:50 PDT 2015
Author: mspencer
Date: Wed Jul 29 17:14:50 2015
New Revision: 243579
URL: http://llvm.org/viewvc/llvm-project?rev=243579&view=rev
Log:
[ELF2] Templatize addChunk and handle section flags.
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/ELF/Writer.h
lld/trunk/test/elf2/basic.test
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=243579&r1=243578&r2=243579&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Jul 29 17:14:50 2015
@@ -48,6 +48,7 @@ void OutputSection::setFileOffset(uint64
C->setFileOff(C->getFileOff() + Off);
}
+template <class ELFT>
void OutputSection::addChunk(Chunk *C) {
Chunks.push_back(C);
C->setOutputSection(this);
@@ -57,8 +58,10 @@ void OutputSection::addChunk(Chunk *C) {
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>
@@ -84,7 +87,7 @@ template <class ELFT> void Writer<ELFT>:
Sec = new (CAlloc.Allocate()) OutputSection(C->getSectionName());
OutputSections.push_back(Sec);
}
- Sec->addChunk(C);
+ Sec->addChunk<ELFT>(C);
}
}
@@ -169,5 +172,10 @@ template class Writer<ELF32LE>;
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 *);
}
}
Modified: lld/trunk/ELF/Writer.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.h?rev=243579&r1=243578&r2=243579&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.h (original)
+++ lld/trunk/ELF/Writer.h Wed Jul 29 17:14:50 2015
@@ -25,7 +25,7 @@ public:
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);
Modified: lld/trunk/test/elf2/basic.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.test?rev=243579&r1=243578&r2=243579&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic.test (original)
+++ lld/trunk/test/elf2/basic.test Wed Jul 29 17:14:50 2015
@@ -54,7 +54,9 @@ _start:
# 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
@@ -68,7 +70,9 @@ _start:
# 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
@@ -82,7 +86,9 @@ _start:
# 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
More information about the llvm-commits
mailing list