1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Redirect runtime.init to an empty stub

This commit is contained in:
Achilleas Anagnostopoulos 2017-07-12 23:24:51 +01:00
parent 8a0fd0ade4
commit 9d2e53bac4

View File

@ -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)