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