Don't create a MCSectionData when we don't have to.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236260 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-04-30 21:10:06 +00:00
parent 3b15669938
commit d80f5165d1

View File

@@ -226,8 +226,8 @@ class ELFObjectWriter : public MCObjectWriter {
void CompressDebugSections(MCAssembler &Asm, MCAsmLayout &Layout); void CompressDebugSections(MCAssembler &Asm, MCAsmLayout &Layout);
const MCSectionELF *createSectionHeaderStringTable(MCAssembler &Asm); const MCSectionELF *createSectionHeaderStringTable();
const MCSectionELF *createStringTable(MCAssembler &Asm); const MCSectionELF *createStringTable(MCContext &Ctx);
void ExecutePostLayoutBinding(MCAssembler &Asm, void ExecutePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override; const MCAsmLayout &Layout) override;
@@ -1308,20 +1308,16 @@ void ELFObjectWriter::writeRelocations(const MCAssembler &Asm,
} }
} }
const MCSectionELF * const MCSectionELF *ELFObjectWriter::createSectionHeaderStringTable() {
ELFObjectWriter::createSectionHeaderStringTable(MCAssembler &Asm) {
const MCSectionELF *ShstrtabSection = SectionTable[ShstrtabIndex - 1]; const MCSectionELF *ShstrtabSection = SectionTable[ShstrtabIndex - 1];
Asm.getOrCreateSectionData(*ShstrtabSection);
ShStrTabBuilder.finalize(StringTableBuilder::ELF); ShStrTabBuilder.finalize(StringTableBuilder::ELF);
OS << ShStrTabBuilder.data(); OS << ShStrTabBuilder.data();
return ShstrtabSection; return ShstrtabSection;
} }
const MCSectionELF *ELFObjectWriter::createStringTable(MCAssembler &Asm) { const MCSectionELF *ELFObjectWriter::createStringTable(MCContext &Ctx) {
MCContext &Ctx = Asm.getContext();
const MCSectionELF *StrtabSection = const MCSectionELF *StrtabSection =
Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0); Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0);
Asm.getOrCreateSectionData(*StrtabSection);
StringTableIndex = addToSectionTable(StrtabSection); StringTableIndex = addToSectionTable(StrtabSection);
OS << StrTabBuilder.data(); OS << StrTabBuilder.data();
return StrtabSection; return StrtabSection;
@@ -1384,7 +1380,7 @@ void ELFObjectWriter::writeSectionHeader(
MCAssembler &Asm, const MCAsmLayout &Layout, MCAssembler &Asm, const MCAsmLayout &Layout,
const SectionIndexMapTy &SectionIndexMap, const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets) { const SectionOffsetsTy &SectionOffsets) {
const unsigned NumSections = Asm.size(); const unsigned NumSections = SectionTable.size();
// Null section first. // Null section first.
uint64_t FirstSectionSize = uint64_t FirstSectionSize =
@@ -1497,14 +1493,14 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
{ {
uint64_t SecStart = OS.tell(); uint64_t SecStart = OS.tell();
const MCSectionELF *Sec = createStringTable(Asm); const MCSectionELF *Sec = createStringTable(Ctx);
uint64_t SecEnd = OS.tell(); uint64_t SecEnd = OS.tell();
SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd); SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd);
} }
{ {
uint64_t SecStart = OS.tell(); uint64_t SecStart = OS.tell();
const MCSectionELF *Sec = createSectionHeaderStringTable(Asm); const MCSectionELF *Sec = createSectionHeaderStringTable();
uint64_t SecEnd = OS.tell(); uint64_t SecEnd = OS.tell();
SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd); SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd);
} }