Commit 337f1cae by Ian Lance Taylor

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
parent 1259cb6d
d5e4595784fb744f5fa0e0f90e77de9b5448b793 805c82cc141c593ea2f27d8614ecd204e2b5e76e
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -4,45 +4,19 @@ ...@@ -4,45 +4,19 @@
package runtime package runtime
import ( import _ "unsafe"
"runtime/internal/sys"
"unsafe"
)
var executablePath string var executablePath string
func sysargs(argc int32, argv **byte) { //extern getexecname
n := argc + 1 func getexecname() *byte
// skip over argv, envp to get to auxv
for argv_index(argv, n) != nil {
n++
}
// skip NULL separator //extern getpagesize
n++ func getpagesize() int32
// now argv+n is auxv func sysargs(argc int32, argv **byte) {
auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) physPageSize = uintptr(getpagesize())
sysauxv(auxv[:]) executablePath = gostringnocopy(getexecname())
}
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 //go:linkname solarisExecutablePath os.solarisExecutablePath
......
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