dlfcn_integration.h 1.0 KB

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