[PATCH] D18691: [ELF] - Split Writer::assignAddresses(): extract code for initializing dummies sections
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 1 10:23:57 PDT 2016
grimar updated this revision to Diff 52392.
grimar added a comment.
- Rebased
http://reviews.llvm.org/D18691
Files:
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -130,6 +130,7 @@
template <class ELFT> void elf::writeResult(SymbolTable<ELFT> *Symtab) {
typedef typename ELFT::uint uintX_t;
+ typedef typename ELFT::Ehdr Elf_Ehdr;
// Create singleton output sections.
DynamicSection<ELFT> Dynamic(*Symtab);
@@ -205,6 +206,7 @@
Out<ELFT>::TlsPhdr = nullptr;
Out<ELFT>::ElfHeader = &ElfHeader;
Out<ELFT>::ProgramHeaders = &ProgramHeaders;
+ Out<ELFT>::ElfHeader->setSize(sizeof(Elf_Ehdr));
Writer<ELFT>(*Symtab).run();
}
@@ -1328,6 +1330,9 @@
if (Note.First)
Phdrs.push_back(std::move(Note));
+
+ size_t PhdrSize = sizeof(Elf_Phdr) * Phdrs.size();
+ Out<ELFT>::ProgramHeaders->setSize(PhdrSize);
}
// The first section of each PT_LOAD and the first section after PT_GNU_RELRO
@@ -1359,10 +1364,6 @@
// Assign VAs (addresses at run-time) to output sections.
template <class ELFT> void Writer<ELFT>::assignAddresses() {
- Out<ELFT>::ElfHeader->setSize(sizeof(Elf_Ehdr));
- size_t PhdrSize = sizeof(Elf_Phdr) * Phdrs.size();
- Out<ELFT>::ProgramHeaders->setSize(PhdrSize);
-
uintX_t ThreadBssOffset = 0;
uintX_t VA = Target->getVAStart();
@@ -1387,7 +1388,6 @@
// Assign file offsets to output sections.
template <class ELFT> void Writer<ELFT>::assignFileOffsets() {
- Out<ELFT>::ElfHeader->setSize(sizeof(Elf_Ehdr));
uintX_t Off = 0;
for (OutputSectionBase<ELFT> *Sec : OutputSections) {
if (Sec->getType() == SHT_NOBITS) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18691.52392.patch
Type: text/x-patch
Size: 1565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160401/b768ae8b/attachment.bin>
More information about the llvm-commits
mailing list