EPCGenericDylibManager.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- EPCGenericDylibManager.h -- Generic EPC Dylib management -*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // Implements dylib loading and searching by making calls to
  15. // ExecutorProcessControl::callWrapper.
  16. //
  17. // This simplifies the implementaton of new ExecutorProcessControl instances,
  18. // as this implementation will always work (at the cost of some performance
  19. // overhead for the calls).
  20. //
  21. //===----------------------------------------------------------------------===//
  22. #ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
  23. #define LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
  24. #include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
  25. #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
  26. namespace llvm {
  27. namespace orc {
  28. class SymbolLookupSet;
  29. class EPCGenericDylibManager {
  30. public:
  31. /// Function addresses for memory access.
  32. struct SymbolAddrs {
  33. ExecutorAddr Instance;
  34. ExecutorAddr Open;
  35. ExecutorAddr Lookup;
  36. };
  37. /// Create an EPCGenericMemoryAccess instance from a given set of
  38. /// function addrs.
  39. static Expected<EPCGenericDylibManager>
  40. CreateWithDefaultBootstrapSymbols(ExecutorProcessControl &EPC);
  41. /// Create an EPCGenericMemoryAccess instance from a given set of
  42. /// function addrs.
  43. EPCGenericDylibManager(ExecutorProcessControl &EPC, SymbolAddrs SAs)
  44. : EPC(EPC), SAs(SAs) {}
  45. /// Loads the dylib with the given name.
  46. Expected<tpctypes::DylibHandle> open(StringRef Path, uint64_t Mode);
  47. /// Looks up symbols within the given dylib.
  48. Expected<std::vector<ExecutorAddr>> lookup(tpctypes::DylibHandle H,
  49. const SymbolLookupSet &Lookup);
  50. /// Looks up symbols within the given dylib.
  51. Expected<std::vector<ExecutorAddr>>
  52. lookup(tpctypes::DylibHandle H, const RemoteSymbolLookupSet &Lookup);
  53. private:
  54. ExecutorProcessControl &EPC;
  55. SymbolAddrs SAs;
  56. };
  57. } // end namespace orc
  58. } // end namespace llvm
  59. #endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
  60. #ifdef __GNUC__
  61. #pragma GCC diagnostic pop
  62. #endif