From 494f112fbc67f053f2e11d0d1397da30c07d1a99 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 30 Apr 2015 20:57:14 +0000 Subject: [PATCH] Avoid an extra loop over the sections. Add string to the section header string table as we add sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236257 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/ELFObjectWriter.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 12950584fc7..98d6c77698a 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -263,6 +263,7 @@ class ELFObjectWriter : public MCObjectWriter { unsigned ELFObjectWriter::addToSectionTable(const MCSectionELF *Sec) { SectionTable.push_back(Sec); + ShStrTabBuilder.add(Sec->getSectionName()); return SectionTable.size(); } @@ -1310,14 +1311,7 @@ void ELFObjectWriter::writeRelocations(const MCAssembler &Asm, const MCSectionELF * ELFObjectWriter::createSectionHeaderStringTable(MCAssembler &Asm) { const MCSectionELF *ShstrtabSection = SectionTable[ShstrtabIndex - 1]; - Asm.getOrCreateSectionData(*ShstrtabSection); - - for (MCSectionData &SD : Asm) { - const MCSectionELF &Section = - static_cast(SD.getSection()); - ShStrTabBuilder.add(Section.getSectionName()); - } ShStrTabBuilder.finalize(StringTableBuilder::ELF); OS << ShStrTabBuilder.data(); return ShstrtabSection; -- 2.34.1