Kernel: Big commit. Rewrite ELF loading code
We now load ELF files to VirtualRanges instead of using kmalloc. We have only a fixed 1 MiB kmalloc for big allocations and this allows loading files even when they don't fit in there. This caused me to rewrite the whole ELF loading process since the loaded ELF is not in memory mapped by every process. Virtual ranges allow you to zero out the memory and to copy into them from arbitary byte buffers.
This commit is contained in:
@@ -23,11 +23,15 @@ namespace Kernel
|
||||
size_t size() const { return m_size; }
|
||||
uint8_t flags() const { return m_flags; }
|
||||
|
||||
void set_zero();
|
||||
void copy_from(size_t offset, const uint8_t* buffer, size_t bytes);
|
||||
|
||||
private:
|
||||
VirtualRange(PageTable&);
|
||||
|
||||
private:
|
||||
PageTable& m_page_table;
|
||||
bool m_kmalloc { false };
|
||||
vaddr_t m_vaddr { 0 };
|
||||
size_t m_size { 0 };
|
||||
uint8_t m_flags { 0 };
|
||||
|
||||
@@ -49,8 +49,6 @@ namespace Kernel
|
||||
|
||||
pid_t pid() const { return m_pid; }
|
||||
|
||||
static BAN::ErrorOr<LibELF::ELF*> load_elf_for_exec(BAN::StringView file_path, const BAN::String& cwd, const BAN::Vector<BAN::StringView>& path_env);
|
||||
|
||||
BAN::ErrorOr<Process*> fork(uintptr_t rsp, uintptr_t rip);
|
||||
BAN::ErrorOr<void> exec(BAN::StringView path, const char* const* argv, const char* const* envp);
|
||||
|
||||
@@ -96,7 +94,11 @@ namespace Kernel
|
||||
static Process* create_process();
|
||||
static void register_process(Process*);
|
||||
|
||||
void load_elf(LibELF::ELF&);
|
||||
// Load an elf file to virtual address space of the current page table
|
||||
static BAN::ErrorOr<BAN::UniqPtr<LibELF::ELF>> load_elf_for_exec(BAN::StringView file_path, const BAN::String& cwd, const BAN::Vector<BAN::StringView>& path_env);
|
||||
|
||||
// Copy an elf file from the current page table to the processes own
|
||||
void load_elf_to_memory(LibELF::ELF&);
|
||||
|
||||
BAN::ErrorOr<BAN::String> absolute_path_of(BAN::StringView) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user