github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/runtime/os_linux_386.c (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  #include "runtime.h"
     6  #include "defs_GOOS_GOARCH.h"
     7  #include "os_GOOS.h"
     8  
     9  #define AT_NULL		0
    10  #define AT_RANDOM	25
    11  #define AT_SYSINFO	32
    12  extern uint32 runtime·_vdso;
    13  
    14  #pragma textflag 7
    15  void
    16  runtime·linux_setup_vdso(int32 argc, byte **argv)
    17  {
    18  	byte **envp;
    19  	uint32 *auxv;
    20  
    21  	// skip envp to get to ELF auxiliary vector.
    22  	for(envp = &argv[argc+1]; *envp != nil; envp++)
    23  		;
    24  	envp++;
    25  	
    26  	for(auxv=(uint32*)envp; auxv[0] != AT_NULL; auxv += 2) {
    27  		if(auxv[0] == AT_SYSINFO) {
    28  			runtime·_vdso = auxv[1];
    29  			continue;
    30  		}
    31  		if(auxv[0] == AT_RANDOM) {
    32  			runtime·startup_random_data = (byte*)auxv[1];
    33  			runtime·startup_random_data_len = 16;
    34  			continue;
    35  		}
    36  	}
    37  }