blob: e2120da905875bafa67c3f291894f46068ca2a06 [file] [log] [blame]
Russ Coxe785e3a2014-11-11 17:08:54 -05001// Copyright 2009 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package runtime
6
7import "unsafe"
8
9const (
10 _AT_NULL = 0
11 _AT_RANDOM = 25
12 _AT_SYSINFO = 32
13)
14
15var _vdso uint32
16
Russ Cox0fcf54b2014-11-15 08:00:38 -050017func sysargs(argc int32, argv **byte) {
Russ Coxe785e3a2014-11-11 17:08:54 -050018 // skip over argv, envv to get to auxv
19 n := argc + 1
20 for argv_index(argv, n) != nil {
21 n++
22 }
23 n++
24 auxv := (*[1 << 28]uint32)(add(unsafe.Pointer(argv), uintptr(n)*ptrSize))
25
26 for i := 0; auxv[i] != _AT_NULL; i += 2 {
27 switch auxv[i] {
28 case _AT_SYSINFO:
29 _vdso = auxv[i+1]
30
31 case _AT_RANDOM:
Keith Randall6820be22014-12-09 14:40:40 -080032 startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:]
Russ Coxe785e3a2014-11-11 17:08:54 -050033 }
34 }
35}