Example #1
0
void JuliaOJIT::DebugObjectRegistrar::operator()(ObjectLinkingLayerBase::ObjSetHandleT H, const ObjSetT &Objects,
                const LoadResult &LOS)
{
#ifndef LLVM38
    notifyObjectLoaded(JIT.MemMgr, H);
#endif
    auto oit = Objects.begin();
    auto lit = LOS.begin();
    for (; oit != Objects.end(); ++oit, ++lit) {
#ifdef LLVM39
        const auto &Object = (*oit)->getBinary();
#else
        auto &Object = *oit;
#endif
        auto &LO = *lit;

        OwningBinary<object::ObjectFile> SavedObject = LO->getObjectForDebug(*Object);

        // If the debug object is unavailable, save (a copy of) the original object
        // for our backtraces
        if (!SavedObject.getBinary()) {
            // This is unfortunate, but there doesn't seem to be a way to take
            // ownership of the original buffer
            auto NewBuffer = MemoryBuffer::getMemBufferCopy(Object->getData(), Object->getFileName());
            auto NewObj = ObjectFile::createObjectFile(NewBuffer->getMemBufferRef());
            assert(NewObj);
            SavedObject = OwningBinary<object::ObjectFile>(std::move(*NewObj),std::move(NewBuffer));
        }
        else {
            NotifyGDB(SavedObject);
        }

        SavedObjects.push_back(std::move(SavedObject));

        ORCNotifyObjectEmitted(JuliaListener.get(),
                *Object,
                *SavedObjects.back().getBinary(),
                *LO, JIT.MemMgr);

        // record all of the exported symbols defined in this object
        // in the primary hash table for the enclosing JIT
        for (auto &Symbol : Object->symbols()) {
            auto Flags = Symbol.getFlags();
            if (Flags & object::BasicSymbolRef::SF_Undefined)
                continue;
            if (!(Flags & object::BasicSymbolRef::SF_Exported))
                continue;
            auto NameOrError = Symbol.getName();
            assert(NameOrError);
            auto Name = NameOrError.get();
            orc::JITSymbol Sym = JIT.CompileLayer.findSymbolIn(H, Name, true);
            assert(Sym);
            // note: calling getAddress here eagerly finalizes H
            // as an alternative, we could store the JITSymbol instead
            // (which would present a lazy-initializer functor interface instead)
            JIT.LocalSymbolTable[Name] = (void*)(uintptr_t)Sym.getAddress();
        }
    }
}
Example #2
0
void JuliaOJIT::DebugObjectRegistrar::operator()(RTDyldObjHandleT H,
                const ObjSetT &Objects, const LoadResult &LOS)
{
#if JL_LLVM_VERSION >= 50000
    registerObject(H, Objects->getBinary(),
                   static_cast<const RuntimeDyld::LoadedObjectInfo*>(&LOS));
#else
    auto oit = Objects.begin();
    auto lit = LOS.begin();
    for (; oit != Objects.end(); ++oit, ++lit) {
        const auto &Object = (*oit)->getBinary();
        auto &LO = *lit;

        registerObject(H, Object, LO);
    }
#endif
}