aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_linux.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-04-14 12:12:45 -0400
committerAustin Clements <austin@google.com>2016-04-16 21:42:27 +0000
commitc955bb2040e601c474e547b8badbe44677c9fbdf (patch)
treee5ef0398f9f19324560a1b23aa4ac03f4f12e284 /src/runtime/os_linux.go
parent26ecb42fb4c5ee1d8b64f12e5bb8df6549523d23 (diff)
downloadgo-c955bb2040e601c474e547b8badbe44677c9fbdf.tar.xz
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.go')
-rw-r--r--src/runtime/os_linux.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
index 7d8cc7e5c4..eeb30c7dd9 100644
--- a/src/runtime/os_linux.go
+++ b/src/runtime/os_linux.go
@@ -176,6 +176,29 @@ func newosproc0(stacksize uintptr, fn unsafe.Pointer) {
var failallocatestack = []byte("runtime: failed to allocate stack for the new OS thread\n")
var failthreadcreate = []byte("runtime: failed to create new OS thread\n")
+const (
+ _AT_NULL = 0 // End of vector
+)
+
+func sysargs(argc int32, argv **byte) {
+ n := argc + 1
+
+ // skip over argv, envp to get to auxv
+ for argv_index(argv, n) != nil {
+ n++
+ }
+
+ // skip NULL separator
+ n++
+
+ // now argv+n is auxv
+ auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize))
+ for i := 0; auxv[i] != _AT_NULL; i += 2 {
+ tag, val := auxv[i], auxv[i+1]
+ archauxv(tag, val)
+ }
+}
+
func osinit() {
ncpu = getproccount()
}