From: Jim Grosbach Date: Mon, 21 Apr 2014 19:23:59 +0000 (+0000) Subject: Revert "[rtdyld,c++11] Range'ify symbol table walking." X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=59b626b938925200c7df6c534e4736949490bd77;p=oota-llvm.git Revert "[rtdyld,c++11] Range'ify symbol table walking." Tentative revert for http://lab.llvm.org:8011/builders/llvm-mips-linux/builds/8305. This reverts commit c2a58efff07294fca724f89500538f2ddbcd12ff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206773 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index de84260ae2b..f9a81db4df0 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -53,7 +53,7 @@ void RuntimeDyldImpl::resolveRelocations() { // symbol for the relocation is located. The SectionID in the relocation // entry provides the section to which the relocation will be applied. uint64_t Addr = Sections[i].LoadAddress; - DEBUG(dbgs() << "Resolving relocations Section " << i << "\t" + DEBUG(dbgs() << "Resolving relocations Section #" << i << "\t" << format("%p", (uint8_t *)Addr) << "\n"); resolveRelocationList(Relocations[i], Addr); Relocations.erase(i); @@ -131,23 +131,24 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { // Parse symbols DEBUG(dbgs() << "Parse symbols:\n"); - for (const SymbolRef &Sym : Obj->symbols()) { + for (symbol_iterator I = Obj->begin_symbols(), E = Obj->end_symbols(); I != E; + ++I) { object::SymbolRef::Type SymType; StringRef Name; - Check(Sym.getType(SymType)); - Check(Sym.getName(Name)); + Check(I->getType(SymType)); + Check(I->getName(Name)); - uint32_t Flags = Sym.getFlags(); + uint32_t Flags = I->getFlags(); bool IsCommon = Flags & SymbolRef::SF_Common; if (IsCommon) { // Add the common symbols to a list. We'll allocate them all below. uint32_t Align; - Check(Sym.getAlignment(Align)); + Check(I->getAlignment(Align)); uint64_t Size = 0; - Check(Sym.getSize(Size)); + Check(I->getSize(Size)); CommonSize += Size + Align; - CommonSymbols[Sym] = CommonSymbolInfo(Size, Align); + CommonSymbols[*I] = CommonSymbolInfo(Size, Align); } else { if (SymType == object::SymbolRef::ST_Function || SymType == object::SymbolRef::ST_Data || @@ -156,8 +157,8 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { StringRef SectionData; bool IsCode; section_iterator SI = Obj->end_sections(); - Check(getOffset(Sym, SectOffset)); - Check(Sym.getSection(SI)); + Check(getOffset(*I, SectOffset)); + Check(I->getSection(SI)); if (SI == Obj->end_sections()) continue; Check(SI->getContents(SectionData)); @@ -179,13 +180,14 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { // Parse and process relocations DEBUG(dbgs() << "Parse relocations:\n"); - for (const SectionRef &Section : Obj->sections()) { + for (section_iterator SI = Obj->begin_sections(), SE = Obj->end_sections(); + SI != SE; ++SI) { unsigned SectionID = 0; StubMap Stubs; - section_iterator RelocatedSection = Section.getRelocatedSection(); + section_iterator RelocatedSection = SI->getRelocatedSection(); - relocation_iterator I = Section.relocation_begin(); - relocation_iterator E = Section.relocation_end(); + relocation_iterator I = SI->relocation_begin(); + relocation_iterator E = SI->relocation_end(); if (I == E && !ProcessAllSections) continue; @@ -214,8 +216,9 @@ static uint64_t computeAllocationSizeForSections(std::vector &SectionSizes, uint64_t Alignment) { uint64_t TotalSize = 0; - for (uint64_t Size : SectionSizes) { - uint64_t AlignedSize = (Size + Alignment - 1) / Alignment * Alignment; + for (size_t Idx = 0, Cnt = SectionSizes.size(); Idx < Cnt; Idx++) { + uint64_t AlignedSize = + (SectionSizes[Idx] + Alignment - 1) / Alignment * Alignment; TotalSize += AlignedSize; } return TotalSize; @@ -235,7 +238,10 @@ void RuntimeDyldImpl::computeTotalAllocSize(ObjectImage &Obj, // Collect sizes of all sections to be loaded; // also determine the max alignment of all sections - for (const SectionRef &Section : Obj.sections()) { + for (section_iterator SI = Obj.begin_sections(), SE = Obj.end_sections(); + SI != SE; ++SI) { + const SectionRef &Section = *SI; + bool IsRequired; Check(Section.isRequiredForExecution(IsRequired)); @@ -318,12 +324,13 @@ unsigned RuntimeDyldImpl::computeSectionStubBufSize(ObjectImage &Obj, // necessary section allocation size in loadObject by walking all the sections // once. unsigned StubBufSize = 0; - for (const SectionRef &Section : Obj.sections()) { - section_iterator RelSecI = Section.getRelocatedSection(); + for (section_iterator SI = Obj.begin_sections(), SE = Obj.end_sections(); + SI != SE; ++SI) { + section_iterator RelSecI = SI->getRelocatedSection(); if (!(RelSecI == Section)) continue; - for (const RelocationRef &Reloc : Section.relocations()) { + for (const RelocationRef &Reloc : SI->relocations()) { (void)Reloc; StubBufSize += StubSize; } @@ -362,11 +369,12 @@ void RuntimeDyldImpl::emitCommonSymbols(ObjectImage &Obj, << format("%p", Addr) << " DataSize: " << TotalSize << "\n"); // Assign the address of each symbol - for (const auto &Entry : CommonSymbols) { - uint64_t Size = Entry.second.first; - uint64_t Align = Entry.second.second; + for (CommonSymbolMap::const_iterator it = CommonSymbols.begin(), + itEnd = CommonSymbols.end(); it != itEnd; ++it) { + uint64_t Size = it->second.first; + uint64_t Align = it->second.second; StringRef Name; - Entry.first.getName(Name); + it->first.getName(Name); if (Align) { // This symbol has an alignment requirement. uint64_t AlignOffset = OffsetToAlignment((uint64_t)Addr, Align); @@ -375,7 +383,7 @@ void RuntimeDyldImpl::emitCommonSymbols(ObjectImage &Obj, DEBUG(dbgs() << "Allocating common symbol " << Name << " address " << format("%p\n", Addr)); } - Obj.updateSymbolAddress(Entry.first, (uint64_t)Addr); + Obj.updateSymbolAddress(it->first, (uint64_t)Addr); SymbolTable[Name.data()] = SymbolLoc(SectionID, Offset); Offset += Size; Addr += Size;