diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-09-26 03:29:07 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-09-26 03:29:07 +0000 |
commit | 201054a7f042f5f175605ca64accb2a812b27bfe (patch) | |
tree | 324a23e4c2f0dc50fd84d9525e2f3c6249a4f302 /libgo | |
parent | a1f9402ebd8935321a013695409772bac5715cde (diff) | |
download | gcc-201054a7f042f5f175605ca64accb2a812b27bfe.zip gcc-201054a7f042f5f175605ca64accb2a812b27bfe.tar.gz gcc-201054a7f042f5f175605ca64accb2a812b27bfe.tar.bz2 |
runtime, os: fix the build on Solaris
Reviewed-on: https://go-review.googlesource.com/137535
From-SVN: r264593
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/os/executable_solaris.go | 10 | ||||
-rw-r--r-- | libgo/go/runtime/os3_solaris.go | 54 | ||||
-rw-r--r-- | libgo/go/runtime/stubs3.go | 1 |
3 files changed, 61 insertions, 4 deletions
diff --git a/libgo/go/os/executable_solaris.go b/libgo/go/os/executable_solaris.go index b145980..a2ad62a 100644 --- a/libgo/go/os/executable_solaris.go +++ b/libgo/go/os/executable_solaris.go @@ -4,14 +4,18 @@ package os -import "syscall" +import ( + "syscall" + _ "unsafe" // for go:linkname +) -var executablePath string // set by sysauxv in ../runtime/os3_solaris.go +// solarisExecutablePath is defined in the runtime package. +func solarisExecutablePath() string var initCwd, initCwdErr = Getwd() func executable() (string, error) { - path := executablePath + path := solarisExecutablePath() if len(path) == 0 { path, err := syscall.Getexecname() if err != nil { diff --git a/libgo/go/runtime/os3_solaris.go b/libgo/go/runtime/os3_solaris.go new file mode 100644 index 0000000..c19f797 --- /dev/null +++ b/libgo/go/runtime/os3_solaris.go @@ -0,0 +1,54 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +import ( + "runtime/internal/sys" + "unsafe" +) + +var executablePath string + +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)) + sysauxv(auxv[:]) +} + +const ( + _AT_NULL = 0 // Terminates the vector + _AT_PAGESZ = 6 // Page size in bytes + _AT_SUN_EXECNAME = 2014 // exec() path name +) + +func sysauxv(auxv []uintptr) { + for i := 0; auxv[i] != _AT_NULL; i += 2 { + tag, val := auxv[i], auxv[i+1] + switch tag { + case _AT_PAGESZ: + physPageSize = val + case _AT_SUN_EXECNAME: + executablePath = gostringnocopy((*byte)(unsafe.Pointer(val))) + } + } +} + +//go:linkname solarisExecutablePath os.solarisExecutablePath + +// solarisExecutablePath is called from the os package to fetch the +// saved executable path. +func solarisExecutablePath() string { + return executablePath +} diff --git a/libgo/go/runtime/stubs3.go b/libgo/go/runtime/stubs3.go index 5c0786e..1af693b 100644 --- a/libgo/go/runtime/stubs3.go +++ b/libgo/go/runtime/stubs3.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // +build !plan9 -// +build !solaris // +build !windows // +build !nacl // +build !freebsd |