1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:47:35 +00:00

UserspaceEmulator: Load the target executable ELF semi-properly :^)

This patch adds a basic ELF program loader to the UserspaceEmulator and
creates MMU regions for each PT_LOAD header. (Note that we don't yet
respect the R/W/X flags etc.)

We also turn the SoftCPU into an X86::InstructionStream and give it an
EIP register so we can actually execute code by fetching memory through
our MMU abstraction.
This commit is contained in:
Andreas Kling 2020-07-11 16:45:48 +02:00
parent 0eab5659f8
commit ae1d14bc7a
5 changed files with 68 additions and 22 deletions

View file

@ -29,6 +29,7 @@
#include "SoftCPU.h"
#include "SoftMMU.h"
#include <AK/Types.h>
#include <LibELF/Loader.h>
#include <LibX86/Instruction.h>
#include <sys/types.h>
@ -38,7 +39,9 @@ class Emulator {
public:
Emulator();
int exec(X86::SimpleInstructionStream&, u32 base);
bool load_elf(const ELF::Loader&);
int exec();
u32 virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3);
SoftMMU& mmu() { return m_mmu; }