Kernel: Process can now load 32 bit elf files on i386

We are page faulting on process exit but I'm investigating
the reason.
This commit is contained in:
Bananymous 2023-04-22 19:03:30 +03:00
parent 163d2e4ba8
commit 79e6de325f
1 changed files with 11 additions and 3 deletions

View File

@ -46,6 +46,11 @@ namespace Kernel
BAN::ErrorOr<Process*> Process::create_userspace(BAN::StringView path)
{
auto* elf = TRY(LibELF::ELF::load_from_file(path));
if (!elf->is_native())
{
derrorln("ELF has invalid architecture");
return BAN::Error::from_errno(EINVAL);
}
auto* process = create_process();
MUST(process->m_working_directory.push_back('/'));
@ -53,10 +58,10 @@ namespace Kernel
process->m_mmu = new MMU();
ASSERT(process->m_mmu);
auto& elf_file_header = elf->file_header64();
auto& elf_file_header = elf->file_header_native();
for (size_t i = 0; i < elf_file_header.e_phnum; i++)
{
auto& elf_program_header = elf->program_header64(i);
auto& elf_program_header = elf->program_header_native(i);
switch (elf_program_header.p_type)
{
@ -105,7 +110,10 @@ namespace Kernel
{
ASSERT(m_threads.empty());
if (m_mmu)
{
MMU::get().load();
delete m_mmu;
}
for (auto paddr : m_allocated_pages)
Memory::Heap::get().release_page(paddr);
}