SimpleExecutorDylibManager.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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/DenseMap.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 DylibsMap = DenseMap<uint64_t, sys::DynamicLibrary>;
  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. uint64_t NextId = 0;
  51. DylibsMap Dylibs;
  52. };
  53. } // end namespace rt_bootstrap
  54. } // end namespace orc
  55. } // end namespace llvm
  56. #endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORDYLIBMANAGER_H
  57. #ifdef __GNUC__
  58. #pragma GCC diagnostic pop
  59. #endif