diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-03-01 14:21:24 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-03-01 14:21:24 +0000 |
commit | 337f1caed6378294b8fe97347dbb0a5e6651a71b (patch) | |
tree | 945f05bdcac9f3317a9d0861b704cf221c60cc64 /libgo | |
parent | 1259cb6d0034f36cce26ca8fd3d22d40bafce04a (diff) | |
download | gcc-337f1caed6378294b8fe97347dbb0a5e6651a71b.zip gcc-337f1caed6378294b8fe97347dbb0a5e6651a71b.tar.gz gcc-337f1caed6378294b8fe97347dbb0a5e6651a71b.tar.bz2 |
runtime: call execname and getpagesize on Solaris
Interpreting auxv as []uintptr is incorrect on 64-bit big-endian,
as auxv alternates a 32-bit int with a 64-bit pointer.
Patch from Rainer Orth.
Reviewed-on: https://go-review.googlesource.com/c/164739
From-SVN: r269315
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/runtime/os3_solaris.go | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/libgo/go/runtime/os3_solaris.go b/libgo/go/runtime/os3_solaris.go index c19f797..e67d32c 100644 --- a/libgo/go/runtime/os3_solaris.go +++ b/libgo/go/runtime/os3_solaris.go @@ -4,45 +4,19 @@ package runtime -import ( - "runtime/internal/sys" - "unsafe" -) +import _ "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++ - } +//extern getexecname +func getexecname() *byte - // skip NULL separator - n++ +//extern getpagesize +func getpagesize() int32 - // 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))) - } - } +func sysargs(argc int32, argv **byte) { + physPageSize = uintptr(getpagesize()) + executablePath = gostringnocopy(getexecname()) } //go:linkname solarisExecutablePath os.solarisExecutablePath |