Commit 3aba41d6 authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

runtime: source startupRandomData from auxv AT_RANDOM on linux/arm.

Fixes #9541.

Change-Id: I5d659ad50d7c3d1c92ed9feb86cda4c1a6e62054
Reviewed-on: https://go-review.googlesource.com/2584Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent a3876ac2
...@@ -51,12 +51,11 @@ func setup_auxv(argc int32, argv **byte) { ...@@ -51,12 +51,11 @@ func setup_auxv(argc int32, argv **byte) {
for i := 0; auxv[i] != _AT_NULL; i += 2 { for i := 0; auxv[i] != _AT_NULL; i += 2 {
switch auxv[i] { switch auxv[i] {
case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data
if auxv[i+1] != 0 { startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:]
// the pointer provided may not be word alined, so we must to treat it // the pointer provided may not be word alined, so we must to treat it
// as a byte array. // as a byte array.
rnd := (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1]))) randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
randomNumber = uint32(rnd[0]) | uint32(rnd[1])<<8 | uint32(rnd[2])<<16 | uint32(rnd[3])<<24 uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
}
case _AT_PLATFORM: // v5l, v6l, v7l case _AT_PLATFORM: // v5l, v6l, v7l
t := *(*uint8)(unsafe.Pointer(uintptr(auxv[i+1] + 1))) t := *(*uint8)(unsafe.Pointer(uintptr(auxv[i+1] + 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