diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-04-28 15:26:21 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-04-28 15:26:21 +0000 |
commit | a820169711755d637fe1e5c9c046ef61981cd923 (patch) | |
tree | 8c05027788b19165779738b91d19533073f17c43 /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | b64175076fec06606792615f59672e0509dd9c5b (diff) | |
download | bcm5719-llvm-a820169711755d637fe1e5c9c046ef61981cd923.tar.gz bcm5719-llvm-a820169711755d637fe1e5c9c046ef61981cd923.zip |
Use a std::vector to record the offsets of the sections. NFC.
llvm-svn: 235995
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 5abdd971809..8a41654a8eb 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -221,9 +221,8 @@ class ELFObjectWriter : public MCObjectWriter { typedef DenseMap<const MCSectionELF*, const MCSymbol*> GroupMapTy; // Map from a signature symbol to the group section typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy; - // Map from a section to its start and end offset - typedef DenseMap<const MCSectionELF *, std::pair<uint64_t, uint64_t>> - SectionOffsetMapTy; + // Start and end offset of each section + typedef std::vector<std::pair<uint64_t, uint64_t>> SectionOffsetsTy; /// Compute the symbol table data /// @@ -259,7 +258,7 @@ class ELFObjectWriter : public MCObjectWriter { MCAssembler &Asm, const GroupMapTy &GroupMap, const MCAsmLayout &Layout, const SectionIndexMapTy &SectionIndexMap, - const SectionOffsetMapTy &SectionOffsetMap); + const SectionOffsetsTy &SectionOffsets); void WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags, uint64_t Address, uint64_t Offset, @@ -1550,7 +1549,7 @@ void ELFObjectWriter::writeSectionHeader( ArrayRef<const MCSectionELF *> Sections, MCAssembler &Asm, const GroupMapTy &GroupMap, const MCAsmLayout &Layout, const SectionIndexMapTy &SectionIndexMap, - const SectionOffsetMapTy &SectionOffsetMap) { + const SectionOffsetsTy &SectionOffsets) { const unsigned NumSections = Asm.size(); // Null section first. @@ -1570,8 +1569,7 @@ void ELFObjectWriter::writeSectionHeader( GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm, GroupMap.lookup(&Section)); - const std::pair<uint64_t, uint64_t> &Offsets = - SectionOffsetMap.lookup(&Section); + const std::pair<uint64_t, uint64_t> &Offsets = SectionOffsets[i]; uint64_t Size = Section.getType() == ELF::SHT_NOBITS ? Layout.getSectionAddressSize(&SD) : Offsets.second - Offsets.first; @@ -1607,7 +1605,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, for (auto &Pair : SectionIndexMap) Sections[Pair.second - 1] = Pair.first; - SectionOffsetMapTy SectionOffsetMap; + SectionOffsetsTy SectionOffsets; // Write out the ELF header ... WriteHeader(Asm, NumSections + 1); @@ -1623,7 +1621,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, uint64_t SecStart = OS.tell(); writeDataSectionData(Asm, Layout, SD); uint64_t SecEnd = OS.tell(); - SectionOffsetMap[&Section] = std::make_pair(SecStart, SecEnd); + SectionOffsets.push_back(std::make_pair(SecStart, SecEnd)); } uint64_t NaturalAlignment = is64Bit() ? 8 : 4; @@ -1634,7 +1632,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, // ... then the section header table ... writeSectionHeader(Sections, Asm, GroupMap, Layout, SectionIndexMap, - SectionOffsetMap); + SectionOffsets); if (is64Bit()) { uint64_t Val = SectionHeaderOffset; |