mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
ELFLoader works inside the kernel!
We load /_hello.o which just prints out a simple message. It executes inside the kernel itself, so no fancy userspace process or anything, but this is still so cool!
This commit is contained in:
parent
6ab0649ad6
commit
97e0d75bcb
Notes:
sideshowbarker
2024-07-19 18:46:15 +09:00
Author: https://github.com/awesomekling
Commit: 97e0d75bcb
10 changed files with 72 additions and 15 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <VirtualFileSystem/FileHandle.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include "MemoryManager.h"
|
||||
#include <ELFLoader/ELFLoader.h>
|
||||
|
||||
#if 0
|
||||
/* Keyboard LED disco task ;^) */
|
||||
|
@ -82,6 +83,8 @@ static void user_kprintf_main()
|
|||
DO_SYSCALL_A1(0x4000, 0);
|
||||
kprintf("This should not work!\n");
|
||||
HANG;
|
||||
for (;;) {
|
||||
}
|
||||
}
|
||||
|
||||
system_t system;
|
||||
|
@ -179,6 +182,25 @@ void init()
|
|||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
auto testExecutable = vfs->open("/_hello.o");
|
||||
ASSERT(testExecutable);
|
||||
auto testExecutableData = testExecutable->readEntireFile();
|
||||
ASSERT(testExecutableData);
|
||||
|
||||
ExecSpace space;
|
||||
space.loadELF(move(testExecutableData));
|
||||
auto* elf_entry = space.symbolPtr("elf_entry");
|
||||
ASSERT(elf_entry);
|
||||
|
||||
typedef int (*MainFunctionPtr)(void);
|
||||
kprintf("elf_entry: %p\n", elf_entry);
|
||||
int rc = reinterpret_cast<MainFunctionPtr>(elf_entry)();
|
||||
kprintf("it returned %d\n", rc);
|
||||
|
||||
HANG;
|
||||
}
|
||||
|
||||
// The idle task will spend its eternity here for now.
|
||||
for (;;) {
|
||||
asm("hlt");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue