1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

Kernel: Move ELF-related files into Kernel/ELF/.

This commit is contained in:
Andreas Kling 2019-04-03 12:30:04 +02:00
parent 9fca94269e
commit 072ea7eece
7 changed files with 5 additions and 5 deletions

44
Kernel/ELF/ELFLoader.h Normal file
View file

@ -0,0 +1,44 @@
#pragma once
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/Vector.h>
#include "ELFImage.h"
class ELFLoader {
public:
explicit ELFLoader(const byte*);
~ELFLoader();
bool load();
Function<void*(LinearAddress, size_t, size_t, bool, bool, const String&)> alloc_section_hook;
Function<void*(LinearAddress, size_t, size_t, size_t, bool, bool, const String&)> map_section_hook;
char* symbol_ptr(const char* name);
bool allocate_section(LinearAddress, size_t, size_t alignment, bool is_readable, bool is_writable);
bool map_section(LinearAddress, size_t, size_t alignment, size_t offset_in_image, bool is_readable, bool is_writable);
LinearAddress entry() const { return m_image.entry(); }
private:
bool layout();
bool perform_relocations();
void* lookup(const ELFImage::Symbol&);
char* area_for_section(const ELFImage::Section&);
char* area_for_section_name(const char*);
struct PtrAndSize {
PtrAndSize() { }
PtrAndSize(char* p, unsigned s)
: ptr(p)
, size(s)
{
}
char* ptr { nullptr };
unsigned size { 0 };
};
ELFImage m_image;
HashMap<String, char*> m_sections;
};