diff options
author | Austin Clements <austin@google.com> | 2016-04-14 12:12:45 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2016-04-16 21:42:27 +0000 |
commit | c955bb2040e601c474e547b8badbe44677c9fbdf (patch) | |
tree | e5ef0398f9f19324560a1b23aa4ac03f4f12e284 /src/runtime/os_linux_arm64.go | |
parent | 26ecb42fb4c5ee1d8b64f12e5bb8df6549523d23 (diff) | |
download | go-c955bb2040e601c474e547b8badbe44677c9fbdf.tar.gz go-c955bb2040e601c474e547b8badbe44677c9fbdf.zip |
runtime: common auxv parser
Currently several different Linux architectures have separate copies
of the auxv parser. Bring these all together into a single copy of the
parser that calls out to a per-arch handler for each tag/value pair.
This is in preparation for handling common auxv tags in one place.
For #9993.
Change-Id: Iceebc3afad6b4133b70fca7003561ae370445c10
Reviewed-on: https://go-review.googlesource.com/22061
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Diffstat (limited to 'src/runtime/os_linux_arm64.go')
-rw-r--r-- | src/runtime/os_linux_arm64.go | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/runtime/os_linux_arm64.go b/src/runtime/os_linux_arm64.go index 57184b0d3a..aa9d4d9885 100644 --- a/src/runtime/os_linux_arm64.go +++ b/src/runtime/os_linux_arm64.go @@ -4,36 +4,22 @@ package runtime -import ( - "runtime/internal/sys" - "unsafe" -) +import "unsafe" const ( - _AT_NULL = 0 _AT_RANDOM = 25 // introduced in 2.6.29 ) var randomNumber uint32 -func sysargs(argc int32, argv **byte) { - // skip over argv, envv to get to auxv - n := argc + 1 - for argv_index(argv, n) != nil { - n++ - } - n++ - auxv := (*[1 << 29]uint64)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) - - 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 - startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:] - // the pointer provided may not be word aligned, so we must treat it - // as a byte array. - randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 | - uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24 - } +func archauxv(tag, val uintptr) { + switch tag { + case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data + startupRandomData = (*[16]byte)(unsafe.Pointer(val))[:] + // the pointer provided may not be word aligned, so we must treat it + // as a byte array. + randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 | + uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24 } } |