diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-25 23:14:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-25 23:14:17 +0000 |
commit | a554c05d95dfe406de1613c78ab4eebf2c030adf (patch) | |
tree | 6ed75a7a5bbe9093d78fd9c364748b96b0156efe /llvm/lib/MC/MachObjectWriter.cpp | |
parent | 09266bad7f4d70c279c96c0d31ba365d350657e3 (diff) | |
download | llvm-a554c05d95dfe406de1613c78ab4eebf2c030adf.zip llvm-a554c05d95dfe406de1613c78ab4eebf2c030adf.tar.gz llvm-a554c05d95dfe406de1613c78ab4eebf2c030adf.tar.bz2 |
Turn MCSectionData into a field of MCSection.
This also changes MCAssembler to store a vector of MCSections instead of an
iplist of MCSectionData.
llvm-svn: 238159
Diffstat (limited to 'llvm/lib/MC/MachObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/MachObjectWriter.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index 79de0f9..240aa4d 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -540,7 +540,7 @@ void MachObjectWriter::ComputeSymbolTable( unsigned Index = 1; for (MCAssembler::iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it, ++Index) - SectionIndexMap[&it->getSection()] = Index; + SectionIndexMap[&*it] = Index; assert(Index <= 256 && "Too many sections!"); // Build the string table. @@ -622,7 +622,8 @@ void MachObjectWriter::ComputeSymbolTable( for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i) UndefinedSymbolData[i].Symbol->setIndex(Index++); - for (const MCSectionData &SD : Asm) { + for (const MCSection &Section : Asm) { + const MCSectionData &SD = Section.getSectionData(); std::vector<RelAndSymbol> &Relocs = Relocations[&SD]; for (RelAndSymbol &Rel : Relocs) { if (!Rel.Sym) @@ -801,7 +802,7 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm, uint64_t VMSize = 0; for (MCAssembler::const_iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it) { - const MCSectionData &SD = *it; + const MCSectionData &SD = it->getSectionData(); uint64_t Address = getSectionAddress(&SD); uint64_t Size = Layout.getSectionAddressSize(&SD); uint64_t FileSize = Layout.getSectionFileSize(&SD); @@ -832,10 +833,11 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm, uint64_t RelocTableEnd = SectionDataStart + SectionDataFileSize; for (MCAssembler::const_iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it) { - std::vector<RelAndSymbol> &Relocs = Relocations[it]; + const MCSectionData &SD = it->getSectionData(); + std::vector<RelAndSymbol> &Relocs = Relocations[&SD]; unsigned NumRelocs = Relocs.size(); - uint64_t SectionStart = SectionDataStart + getSectionAddress(it); - WriteSection(Asm, Layout, *it, SectionStart, RelocTableEnd, NumRelocs); + uint64_t SectionStart = SectionDataStart + getSectionAddress(&SD); + WriteSection(Asm, Layout, SD, SectionStart, RelocTableEnd, NumRelocs); RelocTableEnd += NumRelocs * sizeof(MachO::any_relocation_info); } @@ -911,9 +913,10 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm, // Write the actual section data. for (MCAssembler::const_iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it) { - Asm.writeSectionData(it, Layout); + const MCSectionData &SD = it->getSectionData(); + Asm.writeSectionData(&SD, Layout); - uint64_t Pad = getPaddingSize(it, Layout); + uint64_t Pad = getPaddingSize(&SD, Layout); WriteZeros(Pad); } @@ -925,7 +928,7 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm, ie = Asm.end(); it != ie; ++it) { // Write the section relocation entries, in reverse order to match 'as' // (approximately, the exact algorithm is more complicated than this). - std::vector<RelAndSymbol> &Relocs = Relocations[it]; + std::vector<RelAndSymbol> &Relocs = Relocations[&it->getSectionData()]; for (unsigned i = 0, e = Relocs.size(); i != e; ++i) { Write32(Relocs[e - i - 1].MRE.r_word0); Write32(Relocs[e - i - 1].MRE.r_word1); |