From bd5969fc876a10b18613302db7087ef3c40f18e1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:00 -0500 Subject: lib: Add mlibc Signed-off-by: Ian Moffett --- lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp | 28 ++++++++++++++++++++++ .../options/rtdl/include/mlibc/rtdl-config.hpp | 24 +++++++++++++++++++ .../options/rtdl/include/mlibc/rtdl-sysdeps.hpp | 12 ++++++++++ 3 files changed, 64 insertions(+) create mode 100644 lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp create mode 100644 lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp create mode 100644 lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp (limited to 'lib/mlibc/options/rtdl/include') diff --git a/lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp b/lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp new file mode 100644 index 0000000..135b461 --- /dev/null +++ b/lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp @@ -0,0 +1,28 @@ +#ifndef MLIBC_RTDL_ABI +#define MLIBC_RTDL_ABI + +#include + +#if defined(__x86_64__) || defined(__aarch64__) || defined(__i386__) || defined(__riscv) + +struct __abi_tls_entry { + struct SharedObject *object; + size_t offset; +}; +static_assert(sizeof(__abi_tls_entry) == sizeof(size_t) * 2, "Bad __abi_tls_entry size"); + +extern "C" void *__dlapi_get_tls(struct __abi_tls_entry *); + +#else +#error "Missing architecture specific code." +#endif + +#if defined(__riscv) +constexpr inline unsigned long TLS_DTV_OFFSET = 0x800; +#elif defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) +constexpr inline unsigned long TLS_DTV_OFFSET = 0; +#else +#error "Missing architecture specific code." +#endif + +#endif // MLIBC_RTDL_ABI diff --git a/lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp b/lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp new file mode 100644 index 0000000..4838880 --- /dev/null +++ b/lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp @@ -0,0 +1,24 @@ +#ifndef MLIBC_RTDL_CONFIG +#define MLIBC_RTDL_CONFIG + +namespace mlibc { + +struct RtdlConfig { + bool secureRequired; +}; + +} + +extern "C" const mlibc::RtdlConfig &__dlapi_get_config(); + +#ifndef MLIBC_BUILDING_RTDL +namespace mlibc { + +inline const RtdlConfig &rtdlConfig() { + return __dlapi_get_config(); +} + +} +#endif + +#endif // MLIBC_RTDL_CONFIG diff --git a/lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp b/lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp new file mode 100644 index 0000000..c35271c --- /dev/null +++ b/lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp @@ -0,0 +1,12 @@ +#ifndef MLIBC_RTDL_SYSDEPS +#define MLIBC_RTDL_SYSDEPS + +namespace [[gnu::visibility("hidden")]] mlibc { + +int sys_tcb_set(void *pointer); + +[[gnu::weak]] int sys_vm_readahead(void *pointer, size_t size); + +} // namespace mlibc + +#endif // MLIBC_RTDL_SYSDEPS -- cgit v1.2.3