SimpleExecutorDylibManager.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--------------- SimpleExecutorDylibManager.h ---------------*- 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. // A simple dynamic library management class. Allows dynamic libraries to be
  15. // loaded and searched.
  16. //
  17. // FIXME: The functionality in this file should be moved to the ORC runtime.
  18. //
  19. //===----------------------------------------------------------------------===//
  20. #ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORDYLIBMANAGER_H
  21. #define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORDYLIBMANAGER_H
  22. #include "llvm/ADT/DenseSet.h"
  23. #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
  24. #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
  25. #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
  26. #include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
  27. #include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h"
  28. #include "llvm/Support/DynamicLibrary.h"
  29. #include "llvm/Support/Error.h"
  30. #include <mutex>
  31. namespace llvm {
  32. namespace orc {
  33. namespace rt_bootstrap {
  34. /// Simple page-based allocator.
  35. class SimpleExecutorDylibManager : public ExecutorBootstrapService {
  36. public:
  37. virtual ~SimpleExecutorDylibManager();
  38. Expected<tpctypes::DylibHandle> open(const std::string &Path, uint64_t Mode);
  39. Expected<std::vector<ExecutorAddr>> lookup(tpctypes::DylibHandle H,
  40. const RemoteSymbolLookupSet &L);
  41. Error shutdown() override;
  42. void addBootstrapSymbols(StringMap<ExecutorAddr> &M) override;
  43. private:
  44. using DylibSet = DenseSet<void *>;
  45. static llvm::orc::shared::CWrapperFunctionResult
  46. openWrapper(const char *ArgData, size_t ArgSize);
  47. static llvm::orc::shared::CWrapperFunctionResult
  48. lookupWrapper(const char *ArgData, size_t ArgSize);
  49. std::mutex M;
  50. DylibSet Dylibs;
  51. };
  52. } // end namespace rt_bootstrap
  53. } // end namespace orc
  54. } // end namespace llvm
  55. #endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORDYLIBMANAGER_H
  56. #ifdef __GNUC__
  57. #pragma GCC diagnostic pop
  58. #endif