Commit d1e06dab authored by Shenghou Ma's avatar Shenghou Ma

runtime: don't assume AT_RANDOM provide 4-byte aligned ptr

R=dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854056
parent 80dcc434
......@@ -173,11 +173,14 @@ runtime·checkgoarm(void)
void
runtime·setup_auxv(int32 argc, void *argv_list)
{
byte **argv = &argv_list;
byte **argv;
byte **envp;
byte *rnd;
uint32 *auxv;
uint32 t;
argv = &argv_list;
// skip envp to get to ELF auxiliary vector.
for(envp = &argv[argc+1]; *envp != nil; envp++)
;
......@@ -186,8 +189,10 @@ runtime·setup_auxv(int32 argc, void *argv_list)
for(auxv=(uint32*)envp; auxv[0] != AT_NULL; auxv += 2) {
switch(auxv[0]) {
case AT_RANDOM: // kernel provided 16-byte worth of random data
if(auxv[1])
runtime·randomNumber = *(uint32*)(auxv[1] + 4);
if(auxv[1]) {
rnd = (byte*)auxv[1];
runtime·randomNumber = rnd[4] | rnd[5]<<8 | rnd[6]<<16 | rnd[7]<<24;
}
break;
case AT_PLATFORM: // v5l, v6l, v7l
if(auxv[1]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment