From 9d2e53bac477d4c9a6b87ae2a3b189e63edee311 Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Wed, 12 Jul 2017 23:24:51 +0100 Subject: [PATCH] Redirect runtime.init to an empty stub --- src/gopheros/kernel/goruntime/bootstrap.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gopheros/kernel/goruntime/bootstrap.go b/src/gopheros/kernel/goruntime/bootstrap.go index 06d06b4..1010a18 100644 --- a/src/gopheros/kernel/goruntime/bootstrap.go +++ b/src/gopheros/kernel/goruntime/bootstrap.go @@ -51,6 +51,16 @@ func mSysStatInc(*uint64, uintptr) //go:linkname initGoPackages main.init func initGoPackages() +// Some of the package init functions (e.g reflect.init) call runtime.init +// which attempts to create a new process and eventually crashes the kernel. +// Since the kernel does its own initialization, we can safely redirect +// runtime.init +// to this empty stub. +//go:redirect-from runtime.init +//go:noinline +func runtimeInit() { +} + // sysReserve reserves address space without allocating any memory or // establishing any page mappings. // @@ -188,6 +198,7 @@ func init() { zeroPtr = unsafe.Pointer(uintptr(0)) ) + runtimeInit() sysReserve(zeroPtr, 0, &reserved) sysMap(zeroPtr, 0, reserved, &stat) sysAlloc(0, &stat)