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
This commit is contained in:
Rafael Espindola 2015-04-30 20:57:14 +00:00
parent b65870f3f5
commit 494f112fbc

View File

@ -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<const MCSectionELF &>(SD.getSection());
ShStrTabBuilder.add(Section.getSectionName());
}
ShStrTabBuilder.finalize(StringTableBuilder::ELF);
OS << ShStrTabBuilder.data();
return ShstrtabSection;