DynamicLinker: Implement RTLD_NOLOAD
This commit is contained in:
@@ -11,6 +11,7 @@ __BEGIN_DECLS
|
||||
#define RTLD_NOW 0x1
|
||||
#define RTLD_GLOBAL 0x0
|
||||
#define RTLD_LOCAL 0x2
|
||||
#define RTLD_NOLOAD 0x4
|
||||
|
||||
#define _RTLD_LAZY_NOW_MASK 0x1
|
||||
#define _RTLD_GLOBAL_LOCAL_MASK 0x2
|
||||
|
||||
@@ -1591,6 +1591,21 @@ void* __dlopen(const char* file, int mode)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mode & RTLD_NOLOAD)
|
||||
{
|
||||
lock_global_lock();
|
||||
for (size_t i = 0; i < s_loaded_file_count; i++)
|
||||
{
|
||||
if (strcmp(s_loaded_files[i].path, path_buffer) == 0)
|
||||
{
|
||||
unlock_global_lock();
|
||||
return &s_loaded_files[i];
|
||||
}
|
||||
}
|
||||
unlock_global_lock();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const size_t old_loaded_count = s_loaded_file_count;
|
||||
|
||||
init_random();
|
||||
@@ -1609,12 +1624,16 @@ void* __dlopen(const char* file, int mode)
|
||||
syscall(SYS_CLOSE, elf.fd);
|
||||
}
|
||||
|
||||
#if DEBUG_DLOPEN
|
||||
print(STDERR_FILENO, "\e[31m-> success\e[m\n");
|
||||
#endif
|
||||
|
||||
return &elf;
|
||||
}
|
||||
|
||||
void* __dlsym(void* __restrict handle, const char* __restrict name)
|
||||
{
|
||||
if (handle == nullptr)
|
||||
if (handle == RTLD_DEFAULT)
|
||||
{
|
||||
for (size_t i = 0; i < s_loaded_file_count; i++)
|
||||
if (auto* sym = __dlsym(&s_loaded_files[i], name))
|
||||
|
||||
Reference in New Issue
Block a user