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:
parent
8a0fd0ade4
commit
9d2e53bac4
@ -51,6 +51,16 @@ func mSysStatInc(*uint64, uintptr)
|
|||||||
//go:linkname initGoPackages main.init
|
//go:linkname initGoPackages main.init
|
||||||
func initGoPackages()
|
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
|
// sysReserve reserves address space without allocating any memory or
|
||||||
// establishing any page mappings.
|
// establishing any page mappings.
|
||||||
//
|
//
|
||||||
@ -188,6 +198,7 @@ func init() {
|
|||||||
zeroPtr = unsafe.Pointer(uintptr(0))
|
zeroPtr = unsafe.Pointer(uintptr(0))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
runtimeInit()
|
||||||
sysReserve(zeroPtr, 0, &reserved)
|
sysReserve(zeroPtr, 0, &reserved)
|
||||||
sysMap(zeroPtr, 0, reserved, &stat)
|
sysMap(zeroPtr, 0, reserved, &stat)
|
||||||
sysAlloc(0, &stat)
|
sysAlloc(0, &stat)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user