mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibELF: Move ELF classes into namespace ELF
This is for consistency with other namespace changes that were made a while back to the other libraries :)
This commit is contained in:
parent
6b0f47683c
commit
21b5909dc6
18 changed files with 203 additions and 169 deletions
|
@ -38,12 +38,12 @@
|
|||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibELF/ELFDynamicLoader.h>
|
||||
#include <LibELF/DynamicLoader.h>
|
||||
|
||||
// NOTE: The string here should never include a trailing newline (according to POSIX)
|
||||
String g_dlerror_msg;
|
||||
|
||||
HashMap<String, RefPtr<ELFDynamicLoader>> g_elf_objects;
|
||||
HashMap<String, RefPtr<ELF::DynamicLoader>> g_elf_objects;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -74,7 +74,7 @@ void* dlopen(const char* filename, int flags)
|
|||
|
||||
auto existing_elf_object = g_elf_objects.get(file_path.basename());
|
||||
if (existing_elf_object.has_value()) {
|
||||
return const_cast<ELFDynamicLoader*>(existing_elf_object.value());
|
||||
return const_cast<ELF::DynamicLoader*>(existing_elf_object.value());
|
||||
}
|
||||
|
||||
int fd = open(filename, O_RDONLY);
|
||||
|
@ -93,7 +93,7 @@ void* dlopen(const char* filename, int flags)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto loader = ELFDynamicLoader::construct(filename, fd, file_stats.st_size);
|
||||
auto loader = ELF::DynamicLoader::construct(filename, fd, file_stats.st_size);
|
||||
|
||||
if (!loader->is_valid()) {
|
||||
g_dlerror_msg = String::format("%s is not a valid ELF dynamic shared object!", filename);
|
||||
|
@ -109,14 +109,14 @@ void* dlopen(const char* filename, int flags)
|
|||
g_dlerror_msg = "Successfully loaded ELF object.";
|
||||
|
||||
// we have one refcount already
|
||||
return const_cast<ELFDynamicLoader*>(g_elf_objects.get(file_path.basename()).value());
|
||||
return const_cast<ELF::DynamicLoader*>(g_elf_objects.get(file_path.basename()).value());
|
||||
}
|
||||
|
||||
void* dlsym(void* handle, const char* symbol_name)
|
||||
{
|
||||
// FIXME: When called with a NULL handle we're supposed to search every dso in the process... that'll get expensive
|
||||
ASSERT(handle);
|
||||
auto* dso = reinterpret_cast<ELFDynamicLoader*>(handle);
|
||||
auto* dso = reinterpret_cast<ELF::DynamicLoader*>(handle);
|
||||
void* symbol = dso->symbol_for_name(symbol_name);
|
||||
if (!symbol) {
|
||||
g_dlerror_msg = "Symbol not found";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue