LibC: Define Dl_info_t and add stub for dladdr

This commit is contained in:
Bananymous 2025-08-17 22:56:16 +03:00
parent 0bece8a54c
commit 36cb3d56fe
2 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,13 @@
#include <dlfcn.h>
extern "C" int __dladdr(const void*, Dl_info_t*) __attribute__((weak));
int dladdr(const void* __restrict addr, Dl_info_t* __restrict dlip)
{
if (&__dladdr == nullptr) [[unlikely]]
return 0;
return __dladdr(addr, dlip);
}
extern "C" int __dlclose(void*) __attribute__((weak));
int dlclose(void* handle)
{

View File

@ -15,6 +15,18 @@ __BEGIN_DECLS
#define RTLD_NEXT ((void*)-1)
#define RTLD_DEFAULT ((void*) 0)
struct Dl_info
{
const char* dli_fname; /* Pathname of mapped object file. */
void* dli_fbase; /* Base of mapped address range. */
const char* dli_sname; /* Sumbol name or null pointer. */
void* dli_saddr; /* Symbol address or null pointer. */
};
typedef struct Dl_info Dl_info_t; /* POSIX type */
typedef struct Dl_info Dl_info; /* Linux type */
int dladdr(const void* __restrict addr, Dl_info_t* __restrict dlip);
int dlclose(void* handle);
char* dlerror(void);
void* dlopen(const char* file, int mode);