-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/unix: access to ELF auxiliary vector #67839
Comments
If we do this I think it should be in the golang.org/x/sys/unix package. The os package is mainly aimed at OS-independent functionality, but auxv is specific to ELF-based systems. |
so, in the current state of art, is there no way to get the full aux vector? |
As far as I know there is not. |
Not from Go. In C you can usually derive it from the address of the |
I see runtime has an internal |
could you provide a minimal example on how to retrieve auxv values? |
#68089 advocated to expose An alternative, also mentioned in #67839 (comment) and go.dev/cl/458256, could be an exposure of the auxiliary vector via golang.org/x/sys. golang.org/x/sys is OS specific and therefore a perfect fit. The unknown for me in this approach is how golang.org/x/sys can get access to something, that only |
golang.org/x/sys/cpu already reaches into the runtime to fetch the auxiliary vector, using Reaching in from packages in x/sys is better than reaching in from arbitrary external packages, because we can change the x/sys packages ourselves, and then drop the support in runtime when we no longer support older versions of the x/sys packages. |
Thanks for the clarification. I really wasn't sure about x/sys, as I considered x/sys as an external package, "just" in a more controlled manner. If it helps, I can open a CL against x/sys for |
Thanks, may as well wait for the proposal process. |
/proc is tricky because it has additional permission checks and interacts with capabilities. See https://dxuuu.xyz/filecaps.html. Using auxv from the runtime really is a lot less error prone. |
Is there something I can help with to get feedback on this proposal or continue with the proposal process? |
We should drop the "Get" but |
This proposal has been added to the active column of the proposals project |
Auxv is a sequence of key/value pairs, so I'd lean toward a slightly more structured API: |
There should probably be an error result as well, since there are corner cases where we just can't get the auxv (e.g., in c-shared mode on Android where /proc/self/auxv is unreadable). |
Have all remaining concerns about this proposal been addressed? The proposal is to add the following to golang.org/x/sys/unix: // Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.
// The returned slice is always a fresh copy, owned by the caller.
// It returns an error on non-ELF platforms, of if the auxiliary vector cannot be accessed,
// which happens in some locked-down environments and build modes.
func Auxv() ([][2]uintptr, error) |
Based on the discussion above, this proposal seems like a likely accept. The proposal is to add the following to golang.org/x/sys/unix: // Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.
// The returned slice is always a fresh copy, owned by the caller.
// It returns an error on non-ELF platforms, of if the auxiliary vector cannot be accessed,
// which happens in some locked-down environments and build modes.
func Auxv() ([][2]uintptr, error) |
No change in consensus, so accepted. 🎉 The proposal is to add the following to golang.org/x/sys/unix: // Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.
// The returned slice is always a fresh copy, owned by the caller.
// It returns an error on non-ELF platforms, of if the auxiliary vector cannot be accessed,
// which happens in some locked-down environments and build modes.
func Auxv() ([][2]uintptr, error) |
|
Change https://go.dev/cl/644295 mentions this issue: |
Change https://go.dev/cl/646535 mentions this issue: |
github.com/cilium/ebpf no longer accesses getAuxv using linkname but now uses the golang.org/x/sys/unix.Auxv wrapper introduced in go.dev/cl/644295. Also adjust the list of users to include x/sys/unix. Updates #67839 Updates #67401 Change-Id: Ieee266360b22cc0bc4be8f740e0302afd7dbd14f Reviewed-on: https://go-review.googlesource.com/c/go/+/646535 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
Proposal Details
like
os.Args
andos.Environ
, I was wondering why there is neither an API to get ELF auxiliary vector nor Aux type. C does provide them inElf.h
The text was updated successfully, but these errors were encountered: