From 182ad75161c77b4a75d48275979ce44cde213e3f Mon Sep 17 00:00:00 2001 From: Nathan Lee Date: Sat, 3 Oct 2026 18:07:37 -0500 Subject: add support for elf executables (PIE + no dynamic + no relocations) --- website-kernel/fs/exec.S | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 website-kernel/fs/exec.S (limited to 'website-kernel/fs/exec.S') diff --git a/website-kernel/fs/exec.S b/website-kernel/fs/exec.S new file mode 100644 index 0000000..745761d --- /dev/null +++ b/website-kernel/fs/exec.S @@ -0,0 +1,27 @@ +.section .text +.global __userspace_invoke +.type __userspace_invoke, @function + +# __userspace_invoke(fn exec *entry) +__userspace_invoke: + csrw mepc, a0 + csrw mie, zero + + csrr t0, mstatus + li t1, (3 << 11) + not t1, t1 + and t0, t0, t1 + + li t1, (1 << 7) + not t1, t1 + and t0, t0, t1 + + li t1, (1 << 3) + not t1, t1 + and t0, t0, t1 + + csrw mstatus, t0 + + mret + + -- cgit v1.2.3