aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_linux_arm.go
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2015-01-08 19:09:56 -0500
committerMinux Ma <minux@golang.org>2015-01-09 06:50:11 +0000
commit3aba41d6c3ee7a74cde724a2740896978ae81d89 (patch)
tree0af78d8741368e22705b6ff5c5142089fcb8ece3 /src/runtime/os_linux_arm.go
parenta3876ac21ce4e8e5afbcee69df3cdd51e2919548 (diff)
downloadgo-3aba41d6c3ee7a74cde724a2740896978ae81d89.tar.gz
go-3aba41d6c3ee7a74cde724a2740896978ae81d89.zip
runtime: source startupRandomData from auxv AT_RANDOM on linux/arm.
Fixes #9541. Change-Id: I5d659ad50d7c3d1c92ed9feb86cda4c1a6e62054 Reviewed-on: https://go-review.googlesource.com/2584 Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/os_linux_arm.go')
-rw-r--r--src/runtime/os_linux_arm.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/runtime/os_linux_arm.go b/src/runtime/os_linux_arm.go
index d5b37d6ab5..fea5dcafd4 100644
--- a/src/runtime/os_linux_arm.go
+++ b/src/runtime/os_linux_arm.go
@@ -51,12 +51,11 @@ func setup_auxv(argc int32, argv **byte) {
for i := 0; auxv[i] != _AT_NULL; i += 2 {
switch auxv[i] {
case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data
- if auxv[i+1] != 0 {
- // the pointer provided may not be word alined, so we must to treat it
- // as a byte array.
- rnd := (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))
- randomNumber = uint32(rnd[0]) | uint32(rnd[1])<<8 | uint32(rnd[2])<<16 | uint32(rnd[3])<<24
- }
+ startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:]
+ // the pointer provided may not be word alined, so we must to treat it
+ // as a byte array.
+ randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
+ uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
case _AT_PLATFORM: // v5l, v6l, v7l
t := *(*uint8)(unsafe.Pointer(uintptr(auxv[i+1] + 1)))