dlfcn_integration.h 982 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021, Gunnar Beutner <gunnar@beutner.name>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Result.h>
  8. #include <AK/String.h>
  9. struct DlErrorMessage {
  10. DlErrorMessage(String&& other)
  11. : text(move(other))
  12. {
  13. }
  14. // The virtual destructor is required because we're passing this
  15. // struct to the dynamic loader - whose operator delete differs
  16. // from the one in libc.so
  17. virtual ~DlErrorMessage() { }
  18. String text;
  19. };
  20. struct __Dl_info;
  21. typedef struct __Dl_info Dl_info;
  22. typedef Result<void, DlErrorMessage> (*DlCloseFunction)(void*);
  23. typedef Result<void*, DlErrorMessage> (*DlOpenFunction)(const char*, int);
  24. typedef Result<void*, DlErrorMessage> (*DlSymFunction)(void*, const char*);
  25. typedef Result<void, DlErrorMessage> (*DlAddrFunction)(void*, Dl_info*);
  26. extern "C" {
  27. extern DlCloseFunction __dlclose;
  28. extern DlOpenFunction __dlopen;
  29. extern DlSymFunction __dlsym;
  30. extern DlAddrFunction __dladdr;
  31. }