1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 04:34:58 +00:00
serenity/Userland/Libraries/LibDl/dlfcn_integration.h
Gunnar Beutner f40ee1b03f LibC+LibELF: Implement more fully-features dlfcn functionality
This implements more of the dlfcn functionality. Most notably:

* It's now possible to dlopen() libraries which were already
  loaded at program startup time. This does not cause those
  libraries to be loaded twice.
* Errors are reported via dlerror() rather than by crashing
  the program.
* Calls to the dl*() functions are thread-safe.
2021-04-25 10:14:50 +02:00

34 lines
824 B
C

/*
* Copyright (c) 2021, Gunnar Beutner <gunnar@beutner.name>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Result.h>
#include <AK/String.h>
struct DlErrorMessage {
DlErrorMessage(String&& other)
: text(move(other))
{
}
// The virtual destructor is required because we're passing this
// struct to the dynamic loader - whose operator delete differs
// from the one in libc.so
virtual ~DlErrorMessage() { }
String text;
};
typedef Result<void, DlErrorMessage> (*DlCloseFunction)(void*);
typedef Result<void*, DlErrorMessage> (*DlOpenFunction)(const char*, int);
typedef Result<void*, DlErrorMessage> (*DlSymFunction)(void*, const char*);
extern "C" {
extern DlCloseFunction __dlclose;
extern DlOpenFunction __dlopen;
extern DlSymFunction __dlsym;
}