<div dir="ltr">No reason - that was a think-o. Thanks for catching it!<div><br></div><div>Fixed in r243476.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 28, 2015 at 12:32 PM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
> On 28.07.2015, at 19:52, Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:<br>
><br>
> Author: lhames<br>
> Date: Tue Jul 28 12:52:11 2015<br>
> New Revision: 243456<br>
><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243456-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=zoePdJKvUkUpF98Olzrgk-58EZVeC0Z8r-NZONz_gLI&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=243456&view=rev</a><br>
> Log:<br>
> [RuntimeDyld] Make LoadedObjectInfo::getLoadedSectionAddress take a SectionRef<br>
> rather than a string section name.<br>
><br>
><br>
> Modified:<br>
>    llvm/trunk/include/llvm/DebugInfo/DIContext.h<br>
>    llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h<br>
>    llvm/trunk/include/llvm/Object/SymbolicFile.h<br>
>    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
>    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
>    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp<br>
>    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp<br>
>    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h<br>
>    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
>    llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_DebugInfo_DIContext.h-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=3inO1OB1K9SZPByC_JUKcPdv9v79E3ZcWwo8BDCa4o4&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Tue Jul 28 12:52:11 2015<br>
> @@ -145,12 +145,12 @@ public:<br>
><br>
>   /// Obtain the Load Address of a section by Name.<br>
>   ///<br>
> -  /// Calculate the address of the section identified by the passed in Name.<br>
> +  /// Calculate the address of the given section.<br>
>   /// The section need not be present in the local address space. The addresses<br>
> -  /// need to be consistent with the addresses used to query the DIContext and<br>
> +  /// needs to be consistent with the addresses used to query the DIContext and<br>
>   /// the output of this function should be deterministic, i.e. repeated calls with<br>
> -  /// the same Name should give the same address.<br>
> -  virtual uint64_t getSectionLoadAddress(StringRef Name) const = 0;<br>
> +  /// the same Sec should give the same address.<br>
> +  virtual uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const = 0;<br>
><br>
>   /// If conveniently available, return the content of the given Section.<br>
>   ///<br>
> @@ -162,7 +162,8 @@ public:<br>
>   /// local (unrelocated) object file and applied on the fly. Note that this method<br>
>   /// is used purely for optimzation purposes in the common case of JITting in the<br>
>   /// local address space, so returning false should always be correct.<br>
> -  virtual bool getLoadedSectionContents(StringRef Name, StringRef &Data) const {<br>
> +  virtual bool getLoadedSectionContents(const object::SectionRef &Sec,<br>
> +                                        StringRef &Data) const {<br>
>     return false;<br>
>   }<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_ExecutionEngine_RuntimeDyld.h-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=huTg8W_fZ9vu_RtgpW-koJ5GuGje-lUM6cjDfSUvms8&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h (original)<br>
> +++ llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h Tue Jul 28 12:52:11 2015<br>
> @@ -17,8 +17,10 @@<br>
> #include "JITSymbolFlags.h"<br>
> #include "llvm/ADT/STLExtras.h"<br>
> #include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/Object/ObjectFile.h"<br>
> #include "llvm/Support/Memory.h"<br>
> #include "llvm/DebugInfo/DIContext.h"<br>
> +#include <map><br>
> #include <memory><br>
><br>
> namespace llvm {<br>
> @@ -59,26 +61,27 @@ public:<br>
>   class LoadedObjectInfo : public llvm::LoadedObjectInfo {<br>
>     friend class RuntimeDyldImpl;<br>
>   public:<br>
> -    LoadedObjectInfo(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,<br>
> -                     unsigned EndIdx)<br>
> -      : RTDyld(RTDyld), BeginIdx(BeginIdx), EndIdx(EndIdx) { }<br>
> +    typedef std::map<object::SectionRef, unsigned> ObjSectionToIDMap;<br>
> +<br>
> +    LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)<br>
> +      : RTDyld(RTDyld), ObjSecToIDMap(ObjSecToIDMap) { }<br>
><br>
>     virtual object::OwningBinary<object::ObjectFile><br>
>     getObjectForDebug(const object::ObjectFile &Obj) const = 0;<br>
><br>
> -    uint64_t getSectionLoadAddress(StringRef Name) const;<br>
> +    uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const;<br>
><br>
>   protected:<br>
>     virtual void anchor();<br>
><br>
>     RuntimeDyldImpl &RTDyld;<br>
> -    unsigned BeginIdx, EndIdx;<br>
> +    ObjSectionToIDMap ObjSecToIDMap;<br>
>   };<br>
><br>
>   template <typename Derived> struct LoadedObjectInfoHelper : LoadedObjectInfo {<br>
> -    LoadedObjectInfoHelper(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,<br>
> -                           unsigned EndIdx)<br>
> -        : LoadedObjectInfo(RTDyld, BeginIdx, EndIdx) {}<br>
> +    LoadedObjectInfoHelper(RuntimeDyldImpl &RTDyld,<br>
> +                           LoadedObjectInfo::ObjSectionToIDMap ObjSecToIDMap)<br>
> +        : LoadedObjectInfo(RTDyld, std::move(ObjSecToIDMap)) {}<br>
>     std::unique_ptr<llvm::LoadedObjectInfo> clone() const override {<br>
>       return llvm::make_unique<Derived>(static_cast<const Derived &>(*this));<br>
>     }<br>
><br>
> Modified: llvm/trunk/include/llvm/Object/SymbolicFile.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Object_SymbolicFile.h-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=Co48kBvwKJ8PWfYG6JdQZ-YB1rZQ46k8QlMOvftF7bQ&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/SymbolicFile.h?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/Object/SymbolicFile.h (original)<br>
> +++ llvm/trunk/include/llvm/Object/SymbolicFile.h Tue Jul 28 12:52:11 2015<br>
> @@ -15,6 +15,7 @@<br>
> #define LLVM_OBJECT_SYMBOLICFILE_H<br>
><br>
> #include "llvm/Object/Binary.h"<br>
> +#include "llvm/Support/Format.h"<br>
><br>
> namespace llvm {<br>
> namespace object {<br>
> @@ -29,6 +30,12 @@ union DataRefImpl {<br>
>   DataRefImpl() { std::memset(this, 0, sizeof(DataRefImpl)); }<br>
> };<br>
><br>
> +template <typename OStream><br>
> +OStream& operator<<(OStream &OS, const DataRefImpl &D) {<br>
> +  OS << "(" << format("0x%x8", D.p) << " (" << format("0x%x8", D.d.a) << ", " << format("0x%x8", D.d.b) << "))";<br>
> +  return OS;<br>
> +}<br>
> +<br>
> inline bool operator==(const DataRefImpl &a, const DataRefImpl &b) {<br>
>   // Check bitwise identical. This is the only legal way to compare a union w/o<br>
>   // knowing which member is in use.<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_DebugInfo_DWARF_DWARFContext.cpp-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=P1HlPROiXQ6U8wzHRncHcthlwx5J4ZQOIdrYY_iLGLg&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Tue Jul 28 12:52:11 2015<br>
> @@ -556,10 +556,11 @@ DWARFContextInMemory::DWARFContextInMemo<br>
>       continue;<br>
>     StringRef data;<br>
><br>
> +    section_iterator RelocatedSection = Section.getRelocatedSection();<br>
>     // Try to obtain an already relocated version of this section.<br>
>     // Else use the unrelocated section from the object file. We'll have to<br>
>     // apply relocations ourselves later.<br>
> -    if (!L || !L->getLoadedSectionContents(name,data))<br>
> +    if (!L || !L->getLoadedSectionContents(*RelocatedSection,data))<br>
>       Section.getContents(data);<br>
><br>
>     name = name.substr(name.find_first_not_of("._")); // Skip . and _ prefixes.<br>
> @@ -623,7 +624,6 @@ DWARFContextInMemory::DWARFContextInMemo<br>
>       TypesDWOSections[Section].Data = data;<br>
>     }<br>
><br>
> -    section_iterator RelocatedSection = Section.getRelocatedSection();<br>
>     if (RelocatedSection == Obj.section_end())<br>
>       continue;<br>
><br>
> @@ -634,7 +634,7 @@ DWARFContextInMemory::DWARFContextInMemo<br>
>     // If the section we're relocating was relocated already by the JIT,<br>
>     // then we used the relocated version above, so we do not need to process<br>
>     // relocations for it now.<br>
> -    if (L && L->getLoadedSectionContents(RelSecName,RelSecData))<br>
> +    if (L && L->getLoadedSectionContents(*RelocatedSection,RelSecData))<br>
>       continue;<br>
><br>
>     RelSecName = RelSecName.substr(<br>
> @@ -704,7 +704,10 @@ DWARFContextInMemory::DWARFContextInMemo<br>
>           // we need to perform the same computation.<br>
>           StringRef SecName;<br>
>           RSec->getName(SecName);<br>
> -          SectionLoadAddress = L->getSectionLoadAddress(SecName);<br>
> +//           llvm::dbgs() << "Name: '" << SecName<br>
> +//                        << "', RSec: " << RSec->getRawDataRefImpl()<br>
> +//                        << ", Section: " << Section.getRawDataRefImpl() << "\n";<br>
> +          SectionLoadAddress = L->getSectionLoadAddress(*RSec);<br>
>           if (SectionLoadAddress != 0)<br>
>             SymAddr += SectionLoadAddress - RSec->getAddress();<br>
>         }<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_ExecutionEngine_RuntimeDyld_RuntimeDyld.cpp-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=nCxLtlkBY_WQg6Zr4FVZT2t6sGWkyHml-GeFlDUCz4g&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Tue Jul 28 12:52:11 2015<br>
> @@ -122,14 +122,10 @@ static std::error_code getOffset(const S<br>
>   return std::error_code();<br>
> }<br>
><br>
> -std::pair<unsigned, unsigned><br>
> +RuntimeDyldImpl::ObjSectionToIDMap<br>
> RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {<br>
>   MutexGuard locked(lock);<br>
><br>
> -  // Grab the first Section ID. We'll use this later to construct the underlying<br>
> -  // range for the returned LoadedObjectInfo.<br>
> -  unsigned SectionsAddedBeginIdx = Sections.size();<br>
> -<br>
>   // Save information about our target<br>
>   Arch = (Triple::ArchType)Obj.getArch();<br>
>   IsTargetLittleEndian = Obj.isLittleEndian();<br>
> @@ -231,9 +227,10 @@ RuntimeDyldImpl::loadObjectImpl(const ob<br>
>   // Give the subclasses a chance to tie-up any loose ends.<br>
>   finalizeLoad(Obj, LocalSections);<br>
><br>
> -  unsigned SectionsAddedEndIdx = Sections.size();<br>
> +//   for (auto E : LocalSections)<br>
> +//     llvm::dbgs() << "Added: " << E.first.getRawDataRefImpl() << " -> " << E.second << "\n";<br>
><br>
> -  return std::make_pair(SectionsAddedBeginIdx, SectionsAddedEndIdx);<br>
> +  return LocalSections;<br>
> }<br>
><br>
> // A helper method for computeTotalAllocSize.<br>
> @@ -818,10 +815,19 @@ void RuntimeDyldImpl::resolveExternalSym<br>
> // RuntimeDyld class implementation<br>
><br>
> uint64_t RuntimeDyld::LoadedObjectInfo::getSectionLoadAddress(<br>
> -                                                  StringRef SectionName) const {<br>
> -  for (unsigned I = BeginIdx; I != EndIdx; ++I)<br>
> -    if (RTDyld.Sections[I].Name == SectionName)<br>
> -      return RTDyld.Sections[I].LoadAddress;<br>
> +                                          const object::SectionRef &Sec) const {<br>
> +<br>
> +//   llvm::dbgs() << "Searching for " << Sec.getRawDataRefImpl() << " in:\n";<br>
> +//   for (auto E : ObjSecToIDMap)<br>
> +//     llvm::dbgs() << "Added: " << E.first.getRawDataRefImpl() << " -> " << E.second << "\n";<br>
> +<br>
> +  auto I = ObjSecToIDMap.find(Sec);<br>
> +  if (I != ObjSecToIDMap.end()) {<br>
> +//    llvm::dbgs() << "Found ID " << I->second << " for Sec: " << Sec.getRawDataRefImpl() << ", LoadAddress = " << RTDyld.Sections[I->second].LoadAddress << "\n";<br>
> +    return RTDyld.Sections[I->second].LoadAddress;<br>
> +  } else {<br>
> +//    llvm::dbgs() << "Not found.\n";<br>
> +  }<br>
><br>
>   return 0;<br>
> }<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_ExecutionEngine_RuntimeDyld_RuntimeDyldCOFF.cpp-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=bDl-OFspceMf9hCl5Li1qVy5OoP8plmPAblsI8RmpzU&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp Tue Jul 28 12:52:11 2015<br>
> @@ -27,9 +27,8 @@ namespace {<br>
> class LoadedCOFFObjectInfo<br>
>     : public RuntimeDyld::LoadedObjectInfoHelper<LoadedCOFFObjectInfo> {<br>
> public:<br>
> -  LoadedCOFFObjectInfo(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,<br>
> -                       unsigned EndIdx)<br>
> -      : LoadedObjectInfoHelper(RTDyld, BeginIdx, EndIdx) {}<br>
> +  LoadedCOFFObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)<br>
> +      : LoadedObjectInfoHelper(RTDyld, std::move(ObjSecToIDMap)) {}<br>
><br>
>   OwningBinary<ObjectFile><br>
>   getObjectForDebug(const ObjectFile &Obj) const override {<br>
> @@ -55,10 +54,7 @@ llvm::RuntimeDyldCOFF::create(Triple::Ar<br>
><br>
> std::unique_ptr<RuntimeDyld::LoadedObjectInfo><br>
> RuntimeDyldCOFF::loadObject(const object::ObjectFile &O) {<br>
> -  unsigned SectionStartIdx, SectionEndIdx;<br>
> -  std::tie(SectionStartIdx, SectionEndIdx) = loadObjectImpl(O);<br>
> -  return llvm::make_unique<LoadedCOFFObjectInfo>(*this, SectionStartIdx,<br>
> -                                                 SectionEndIdx);<br>
> +  return llvm::make_unique<LoadedCOFFObjectInfo>(*this, loadObjectImpl(O));<br>
> }<br>
><br>
> uint64_t RuntimeDyldCOFF::getSymbolOffset(const SymbolRef &Sym) {<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_ExecutionEngine_RuntimeDyld_RuntimeDyldELF.cpp-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=-r9OaXIvBmYVNszKzp6hIeer2zSLfDC5XYZHhMyXDNU&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Tue Jul 28 12:52:11 2015<br>
> @@ -107,9 +107,8 @@ void DyldELFObject<ELFT>::updateSymbolAd<br>
> class LoadedELFObjectInfo<br>
>     : public RuntimeDyld::LoadedObjectInfoHelper<LoadedELFObjectInfo> {<br>
> public:<br>
> -  LoadedELFObjectInfo(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,<br>
> -                      unsigned EndIdx)<br>
> -      : LoadedObjectInfoHelper(RTDyld, BeginIdx, EndIdx) {}<br>
> +  LoadedELFObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)<br>
> +      : LoadedObjectInfoHelper(RTDyld, std::move(ObjSecToIDMap)) {}<br>
><br>
>   OwningBinary<ObjectFile><br>
>   getObjectForDebug(const ObjectFile &Obj) const override;<br>
> @@ -118,6 +117,7 @@ public:<br>
> template <typename ELFT><br>
> std::unique_ptr<DyldELFObject<ELFT>><br>
> createRTDyldELFObject(MemoryBufferRef Buffer,<br>
> +                      const ObjectFile &SourceObject,<br>
>                       const LoadedELFObjectInfo &L,<br>
>                       std::error_code &ec) {<br>
>   typedef typename ELFFile<ELFT>::Elf_Shdr Elf_Shdr;<br>
> @@ -127,6 +127,7 @@ createRTDyldELFObject(MemoryBufferRef Bu<br>
>     llvm::make_unique<DyldELFObject<ELFT>>(Buffer, ec);<br>
><br>
>   // Iterate over all sections in the object.<br>
> +  auto SI = SourceObject.section_begin();<br>
>   for (const auto &Sec : Obj->sections()) {<br>
>     StringRef SectionName;<br>
>     Sec.getName(SectionName);<br>
> @@ -135,12 +136,13 @@ createRTDyldELFObject(MemoryBufferRef Bu<br>
>       Elf_Shdr *shdr = const_cast<Elf_Shdr *>(<br>
>           reinterpret_cast<const Elf_Shdr *>(ShdrRef.p));<br>
><br>
> -      if (uint64_t SecLoadAddr = L.getSectionLoadAddress(SectionName)) {<br>
> +      if (uint64_t SecLoadAddr = L.getSectionLoadAddress(*SI)) {<br>
>         // This assumes that the address passed in matches the target address<br>
>         // bitness. The template-based type cast handles everything else.<br>
>         shdr->sh_addr = static_cast<addr_type>(SecLoadAddr);<br>
>       }<br>
>     }<br>
> +    ++SI;<br>
>   }<br>
><br>
>   return Obj;<br>
> @@ -158,16 +160,20 @@ OwningBinary<ObjectFile> createELFDebugO<br>
>   std::unique_ptr<ObjectFile> DebugObj;<br>
>   if (Obj.getBytesInAddress() == 4 && Obj.isLittleEndian()) {<br>
>     typedef ELFType<support::little, false> ELF32LE;<br>
> -    DebugObj = createRTDyldELFObject<ELF32LE>(Buffer->getMemBufferRef(), L, ec);<br>
> +    DebugObj = createRTDyldELFObject<ELF32LE>(Buffer->getMemBufferRef(), Obj, L,<br>
> +                                              ec);<br>
>   } else if (Obj.getBytesInAddress() == 4 && !Obj.isLittleEndian()) {<br>
>     typedef ELFType<support::big, false> ELF32BE;<br>
> -    DebugObj = createRTDyldELFObject<ELF32BE>(Buffer->getMemBufferRef(), L, ec);<br>
> +    DebugObj = createRTDyldELFObject<ELF32BE>(Buffer->getMemBufferRef(), Obj, L,<br>
> +                                              ec);<br>
>   } else if (Obj.getBytesInAddress() == 8 && !Obj.isLittleEndian()) {<br>
>     typedef ELFType<support::big, true> ELF64BE;<br>
> -    DebugObj = createRTDyldELFObject<ELF64BE>(Buffer->getMemBufferRef(), L, ec);<br>
> +    DebugObj = createRTDyldELFObject<ELF64BE>(Buffer->getMemBufferRef(), Obj, L,<br>
> +                                              ec);<br>
>   } else if (Obj.getBytesInAddress() == 8 && Obj.isLittleEndian()) {<br>
>     typedef ELFType<support::little, true> ELF64LE;<br>
> -    DebugObj = createRTDyldELFObject<ELF64LE>(Buffer->getMemBufferRef(), L, ec);<br>
> +    DebugObj = createRTDyldELFObject<ELF64LE>(Buffer->getMemBufferRef(), Obj, L,<br>
> +                                              ec);<br>
>   } else<br>
>     llvm_unreachable("Unexpected ELF format");<br>
><br>
> @@ -215,10 +221,7 @@ void RuntimeDyldELF::deregisterEHFrames(<br>
><br>
> std::unique_ptr<RuntimeDyld::LoadedObjectInfo><br>
> RuntimeDyldELF::loadObject(const object::ObjectFile &O) {<br>
> -  unsigned SectionStartIdx, SectionEndIdx;<br>
> -  std::tie(SectionStartIdx, SectionEndIdx) = loadObjectImpl(O);<br>
> -  return llvm::make_unique<LoadedELFObjectInfo>(*this, SectionStartIdx,<br>
> -                                                SectionEndIdx);<br>
> +  return llvm::make_unique<LoadedELFObjectInfo>(*this, loadObjectImpl(O));<br>
> }<br>
><br>
> void RuntimeDyldELF::resolveX86_64Relocation(const SectionEntry &Section,<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_ExecutionEngine_RuntimeDyld_RuntimeDyldImpl.h-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=51oE7GNz8hWhcZSPmhspXjM6etTb6_73_oTBj1Djfqg&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h Tue Jul 28 12:52:11 2015<br>
> @@ -378,7 +378,7 @@ protected:<br>
>                                      const SectionRef &Section);<br>
><br>
>   // \brief Implementation of the generic part of the loadObject algorithm.<br>
> -  std::pair<unsigned, unsigned> loadObjectImpl(const object::ObjectFile &Obj);<br>
> +  ObjSectionToIDMap loadObjectImpl(const object::ObjectFile &Obj);<br>
><br>
> public:<br>
>   RuntimeDyldImpl(RuntimeDyld::MemoryManager &MemMgr,<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_ExecutionEngine_RuntimeDyld_RuntimeDyldMachO.cpp-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=RMtw-VxLnwft-vBYSQG2OrMNZ9_rjmVCPdu2J24kpXc&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Tue Jul 28 12:52:11 2015<br>
> @@ -29,9 +29,9 @@ namespace {<br>
> class LoadedMachOObjectInfo<br>
>     : public RuntimeDyld::LoadedObjectInfoHelper<LoadedMachOObjectInfo> {<br>
> public:<br>
> -  LoadedMachOObjectInfo(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,<br>
> -                        unsigned EndIdx)<br>
> -      : LoadedObjectInfoHelper(RTDyld, BeginIdx, EndIdx) {}<br>
> +  LoadedMachOObjectInfo(RuntimeDyldImpl &RTDyld,<br>
> +                        ObjSectionToIDMap ObjSecToIDMap)<br>
> +      : LoadedObjectInfoHelper(RTDyld, std::move(ObjSecToIDMap)) {}<br>
><br>
>   OwningBinary<ObjectFile><br>
>   getObjectForDebug(const ObjectFile &Obj) const override {<br>
> @@ -334,10 +334,7 @@ RuntimeDyldMachO::create(Triple::ArchTyp<br>
><br>
> std::unique_ptr<RuntimeDyld::LoadedObjectInfo><br>
> RuntimeDyldMachO::loadObject(const object::ObjectFile &O) {<br>
> -  unsigned SectionStartIdx, SectionEndIdx;<br>
> -  std::tie(SectionStartIdx, SectionEndIdx) = loadObjectImpl(O);<br>
> -  return llvm::make_unique<LoadedMachOObjectInfo>(*this, SectionStartIdx,<br>
> -                                                  SectionEndIdx);<br>
> +  return llvm::make_unique<LoadedMachOObjectInfo>(*this, loadObjectImpl(O));<br>
> }<br>
><br>
> } // end namespace llvm<br>
><br>
> Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_tools_llvm-2Drtdyld_llvm-2Drtdyld.cpp-3Frev-3D243456-26r1-3D243455-26r2-3D243456-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=KADGXLITBsEg4sKEz-2LX_9qooCDT47OH5Hoiq2hQKU&s=fn2wEiGbvAt-D1Vgfl0bpZoE7EKh2WaPr8VXg6qTqac&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=243456&r1=243455&r2=243456&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Tue Jul 28 12:52:11 2015<br>
> @@ -277,6 +277,7 @@ static int printLineInfoForInput(bool Lo<br>
>       if (UseDebugObj) {<br>
>         DebugObj = LoadedObjInfo->getObjectForDebug(Obj);<br>
>         SymbolObj = DebugObj.getBinary();<br>
> +        LoadedObjInfo.release();<br>
<br>
</div></div>Why are you leaking LoadedObjInfo here?<br>
<br>
- Ben<br>
<div class="HOEnZb"><div class="h5"><br>
>       }<br>
>     }<br>
><br>
> @@ -308,7 +309,7 @@ static int printLineInfoForInput(bool Lo<br>
>           StringRef SecName;<br>
>           Sec->getName(SecName);<br>
>           uint64_t SectionLoadAddress =<br>
> -            LoadedObjInfo->getSectionLoadAddress(SecName);<br>
> +            LoadedObjInfo->getSectionLoadAddress(*Sec);<br>
>           if (SectionLoadAddress != 0)<br>
>             Addr += SectionLoadAddress - Sec->getAddress();<br>
>         }<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
</div></div></blockquote></div><br></div>