Path: blob/main/vendor/golang.org/x/sys/unix/auxv.go
2880 views
// Copyright 2025 The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34//go:build go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)56package unix78import (9"syscall"10"unsafe"11)1213//go:linkname runtime_getAuxv runtime.getAuxv14func runtime_getAuxv() []uintptr1516// Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.17// The returned slice is always a fresh copy, owned by the caller.18// It returns an error on non-ELF platforms, or if the auxiliary vector cannot be accessed,19// which happens in some locked-down environments and build modes.20func Auxv() ([][2]uintptr, error) {21vec := runtime_getAuxv()22vecLen := len(vec)2324if vecLen == 0 {25return nil, syscall.ENOENT26}2728if vecLen%2 != 0 {29return nil, syscall.EINVAL30}3132result := make([]uintptr, vecLen)33copy(result, vec)34return unsafe.Slice((*[2]uintptr)(unsafe.Pointer(&result[0])), vecLen/2), nil35}363738