From d1e06dab7c23109be4b24912212fedf3b155bfc7 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Sun, 18 Nov 2012 02:47:17 +0800 Subject: [PATCH] runtime: don't assume AT_RANDOM provide 4-byte aligned ptr R=dave, remyoudompheng CC=golang-dev https://golang.org/cl/6854056 --- src/pkg/runtime/signal_linux_arm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pkg/runtime/signal_linux_arm.c b/src/pkg/runtime/signal_linux_arm.c index e12c54d9727..48336c0aff9 100644 --- a/src/pkg/runtime/signal_linux_arm.c +++ b/src/pkg/runtime/signal_linux_arm.c @@ -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]) {