summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2019-06-23 21:36:31 +0000
committerpatrick <patrick@openbsd.org>2019-06-23 21:36:31 +0000
commit23f101f37937a1bd4a29726cab2f76e0fb038b35 (patch)
treef7da7d6b32c2e07114da399150bfa88d72187012 /gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
parentsort previous; ok deraadt (diff)
downloadwireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.tar.xz
wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.zip
Import LLVM 8.0.0 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp')
-rw-r--r--gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
index fa8906869b3..6eb6256080f 100644
--- a/gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
+++ b/gnu/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
@@ -14,8 +14,10 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
#include "llvm/MC/MCInst.h"
+#include "llvm/Support/MSVCErrorWorkarounds.h"
#include "llvm/Support/Path.h"
#include <cctype>
+#include <future>
#include <memory>
#include <utility>
@@ -729,15 +731,35 @@ bool RuntimeDyldCheckerImpl::checkAllRulesInBuffer(StringRef RulePrefix,
return DidAllTestsPass && (NumRules != 0);
}
+Expected<JITSymbolResolver::LookupResult> RuntimeDyldCheckerImpl::lookup(
+ const JITSymbolResolver::LookupSet &Symbols) const {
+
+#ifdef _MSC_VER
+ using ExpectedLookupResult = MSVCPExpected<JITSymbolResolver::LookupResult>;
+#else
+ using ExpectedLookupResult = Expected<JITSymbolResolver::LookupResult>;
+#endif
+
+ auto ResultP = std::make_shared<std::promise<ExpectedLookupResult>>();
+ auto ResultF = ResultP->get_future();
+
+ getRTDyld().Resolver.lookup(
+ Symbols, [=](Expected<JITSymbolResolver::LookupResult> Result) {
+ ResultP->set_value(std::move(Result));
+ });
+ return ResultF.get();
+}
+
bool RuntimeDyldCheckerImpl::isSymbolValid(StringRef Symbol) const {
if (getRTDyld().getSymbol(Symbol))
return true;
- JITSymbolResolver::LookupSet Symbols({Symbol});
- auto Result = getRTDyld().Resolver.lookup(Symbols);
+ auto Result = lookup({Symbol});
+
if (!Result) {
logAllUnhandledErrors(Result.takeError(), errs(), "RTDyldChecker: ");
return false;
}
+
assert(Result->count(Symbol) && "Missing symbol result");
return true;
}
@@ -751,8 +773,7 @@ uint64_t RuntimeDyldCheckerImpl::getSymbolRemoteAddr(StringRef Symbol) const {
if (auto InternalSymbol = getRTDyld().getSymbol(Symbol))
return InternalSymbol.getAddress();
- JITSymbolResolver::LookupSet Symbols({Symbol});
- auto Result = getRTDyld().Resolver.lookup(Symbols);
+ auto Result = lookup({Symbol});
if (!Result) {
logAllUnhandledErrors(Result.takeError(), errs(), "RTDyldChecker: ");
return 0;