uint64_t MCJIT::getSymbolAddress(const std::string &Name, bool CheckFunctionsOnly) { MutexGuard locked(lock); // First, check to see if we already have this symbol. uint64_t Addr = getExistingSymbolAddress(Name); if (Addr) return Addr; SmallVector<object::Archive*, 2>::iterator I, E; for (I = Archives.begin(), E = Archives.end(); I != E; ++I) { object::Archive *A = *I; // Look for our symbols in each Archive object::Archive::child_iterator ChildIt = A->findSym(Name); if (ChildIt != A->child_end()) { OwningPtr<object::Binary> ChildBin; // FIXME: Support nested archives? if (!ChildIt->getAsBinary(ChildBin) && ChildBin->isObject()) { object::ObjectFile *OF = reinterpret_cast<object::ObjectFile *>( ChildBin.take()); // This causes the object file to be loaded. addObjectFile(OF); // The address should be here now. Addr = getExistingSymbolAddress(Name); if (Addr) return Addr; } } } // If it hasn't already been generated, see if it's in one of our modules. Module *M = findModuleForSymbol(Name, CheckFunctionsOnly); if (!M) return 0; generateCodeForModule(M); // Check the RuntimeDyld table again, it should be there now. return getExistingSymbolAddress(Name); }