mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-14 22:31:29 +03:00
b824f15619
This is so cool! It's a bit messy now with two Task constructors, but eventually they should fold into a single constructor somehow.
61 lines
1.1 KiB
C++
61 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <AK/Function.h>
|
|
#include <AK/HashMap.h>
|
|
#include <AK/MappedFile.h>
|
|
#include <AK/OwnPtr.h>
|
|
#include <AK/Vector.h>
|
|
|
|
class ELFLoader;
|
|
|
|
class ExecSpace {
|
|
public:
|
|
struct Area {
|
|
Area(String&& n, char* m, unsigned s)
|
|
: name(move(n))
|
|
, memory(m)
|
|
, size(s)
|
|
{
|
|
}
|
|
|
|
String name;
|
|
char* memory { 0 };
|
|
unsigned size { 0 };
|
|
};
|
|
|
|
struct PtrAndSize {
|
|
PtrAndSize() { }
|
|
PtrAndSize(char* p, unsigned s)
|
|
: ptr(p)
|
|
, size(s)
|
|
{
|
|
}
|
|
|
|
char* ptr { nullptr };
|
|
unsigned size { 0 };
|
|
};
|
|
|
|
ExecSpace();
|
|
~ExecSpace();
|
|
|
|
Function<void*(const String&, size_t)> hookableAlloc;
|
|
|
|
#ifdef SERENITY
|
|
bool loadELF(ByteBuffer&&);
|
|
#else
|
|
bool loadELF(MappedFile&&);
|
|
#endif
|
|
|
|
char* symbolPtr(const char* name);
|
|
|
|
char* allocateArea(String&& name, unsigned size);
|
|
void addSymbol(String&& name, char* ptr, unsigned size);
|
|
|
|
private:
|
|
void initializeBuiltins();
|
|
|
|
Vector<OwnPtr<Area>> m_areas;
|
|
HashMap<String, PtrAndSize> m_symbols;
|
|
};
|
|
|