diff --git a/src/runtime/vdso_none.go b/src/runtime/auxv_none.go similarity index 93% rename from src/runtime/vdso_none.go rename to src/runtime/auxv_none.go index a709758f64..96fcbdc2fe 100644 --- a/src/runtime/vdso_none.go +++ b/src/runtime/auxv_none.go @@ -5,6 +5,7 @@ // +build !linux // +build !darwin // +build !freebsd +// +build !netbsd package runtime diff --git a/src/runtime/os_netbsd.go b/src/runtime/os_netbsd.go index abd6512dc3..4a4dfa56bf 100644 --- a/src/runtime/os_netbsd.go +++ b/src/runtime/os_netbsd.go @@ -6,6 +6,7 @@ package runtime import ( "runtime/internal/atomic" + "runtime/internal/sys" "unsafe" ) @@ -223,7 +224,9 @@ func netbsdMstart() { func osinit() { ncpu = getncpu() - physPageSize = getPageSize() + if physPageSize == 0 { + physPageSize = getPageSize() + } } var urandom_dev = []byte("/dev/urandom\x00") @@ -325,3 +328,34 @@ func sigdelset(mask *sigset, i int) { func (c *sigctxt) fixsigcode(sig uint32) { } + +func sysargs(argc int32, argv **byte) { + n := argc + 1 + + // skip over argv, envp to get to auxv + for argv_index(argv, n) != nil { + n++ + } + + // skip NULL separator + n++ + + // now argv+n is auxv + auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) + sysauxv(auxv[:]) +} + +const ( + _AT_NULL = 0 // Terminates the vector + _AT_PAGESZ = 6 // Page size in bytes +) + +func sysauxv(auxv []uintptr) { + for i := 0; auxv[i] != _AT_NULL; i += 2 { + tag, val := auxv[i], auxv[i+1] + switch tag { + case _AT_PAGESZ: + physPageSize = val + } + } +}