github.com/mdempsky/go@v0.0.0-20151201204031-5dd372bd1e70/src/runtime/os_linux_386.go (about)

     1  // 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  
     5  package runtime
     6  
     7  import (
     8  	"runtime/internal/sys"
     9  	"unsafe"
    10  )
    11  
    12  const (
    13  	_AT_NULL    = 0
    14  	_AT_RANDOM  = 25
    15  	_AT_SYSINFO = 32
    16  )
    17  
    18  var _vdso uint32
    19  
    20  func sysargs(argc int32, argv **byte) {
    21  	// skip over argv, envv to get to auxv
    22  	n := argc + 1
    23  	for argv_index(argv, n) != nil {
    24  		n++
    25  	}
    26  	n++
    27  	auxv := (*[1 << 28]uint32)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize))
    28  
    29  	for i := 0; auxv[i] != _AT_NULL; i += 2 {
    30  		switch auxv[i] {
    31  		case _AT_SYSINFO:
    32  			_vdso = auxv[i+1]
    33  
    34  		case _AT_RANDOM:
    35  			startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:]
    36  		}
    37  	}
    38  }