Every output section should be added to the OutputSecitons vector.

Simplify.

llvm-svn: 247032
This commit is contained in:
Rafael Espindola
2015-09-08 17:39:39 +00:00
parent 52cd4eecac
commit 5f55387251

View File

@@ -174,6 +174,7 @@ private:
std::unique_ptr<llvm::FileOutputBuffer> Buffer;
llvm::SpecificBumpPtrAllocator<OutputSection<ELFT>> CAlloc;
std::vector<OutputSectionBase<ELFT::Is64Bits> *> OutputSections;
unsigned getNumSections() const { return OutputSections.size() + 1; }
uintX_t FileSize;
uintX_t SizeOfHeaders;
@@ -184,8 +185,6 @@ private:
SymbolTableSection<ELFT> SymTable;
unsigned NumSections;
void addOutputSection(OutputSectionBase<ELFT::Is64Bits> *Sec) {
OutputSections.push_back(Sec);
Sec->setSectionIndex(OutputSections.size());
@@ -525,17 +524,11 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
FileOff += RoundUpToAlignment(Size, Align);
}
// Regular sections.
NumSections = OutputSections.size();
// First dummy section.
NumSections++;
FileOff += OffsetToAlignment(FileOff, ELFT::Is64Bits ? 8 : 4);
// Add space for section headers.
SectionHeaderOff = FileOff;
FileOff += NumSections * sizeof(Elf_Shdr_Impl<ELFT>);
FileOff += getNumSections() * sizeof(Elf_Shdr_Impl<ELFT>);
FileSize = SizeOfHeaders + RoundUpToAlignment(FileOff - SizeOfHeaders, 8);
}
@@ -565,7 +558,7 @@ template <class ELFT> void Writer<ELFT>::writeHeader() {
EHdr->e_phentsize = sizeof(Elf_Phdr_Impl<ELFT>);
EHdr->e_phnum = 1;
EHdr->e_shentsize = sizeof(Elf_Shdr_Impl<ELFT>);
EHdr->e_shnum = NumSections;
EHdr->e_shnum = getNumSections();
EHdr->e_shstrndx = StringTableIndex;
auto PHdrs = reinterpret_cast<Elf_Phdr_Impl<ELFT> *>(Buf + EHdr->e_phoff);