1*4c33415eSBrooks Davis.\" 2*4c33415eSBrooks Davis.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org> 3*4c33415eSBrooks Davis.\" 4*4c33415eSBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*4c33415eSBrooks Davis.\" modification, are permitted provided that the following conditions 6*4c33415eSBrooks Davis.\" are met: 7*4c33415eSBrooks Davis.\" 8*4c33415eSBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 9*4c33415eSBrooks Davis.\" notice, this list of conditions and the following disclaimer. 10*4c33415eSBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 11*4c33415eSBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 12*4c33415eSBrooks Davis.\" documentation and/or other materials provided with the distribution. 13*4c33415eSBrooks Davis.\" 14*4c33415eSBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15*4c33415eSBrooks Davis.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16*4c33415eSBrooks Davis.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17*4c33415eSBrooks Davis.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18*4c33415eSBrooks Davis.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19*4c33415eSBrooks Davis.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20*4c33415eSBrooks Davis.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21*4c33415eSBrooks Davis.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22*4c33415eSBrooks Davis.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23*4c33415eSBrooks Davis.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24*4c33415eSBrooks Davis.\" 25*4c33415eSBrooks Davis.Dd September 16, 2022 26*4c33415eSBrooks Davis.Dt ELF_AUX_INFO 3 27*4c33415eSBrooks Davis.Os 28*4c33415eSBrooks Davis.Sh NAME 29*4c33415eSBrooks Davis.Nm elf_aux_info 30*4c33415eSBrooks Davis.Nd extract data from the elf auxiliary vector of the current process 31*4c33415eSBrooks Davis.Sh LIBRARY 32*4c33415eSBrooks Davis.Lb libc 33*4c33415eSBrooks Davis.Sh SYNOPSIS 34*4c33415eSBrooks Davis.In sys/auxv.h 35*4c33415eSBrooks Davis.Ft int 36*4c33415eSBrooks Davis.Fn elf_aux_info "int aux" "void *buf" "int buflen" 37*4c33415eSBrooks Davis.Sh DESCRIPTION 38*4c33415eSBrooks DavisThe 39*4c33415eSBrooks Davis.Fn elf_aux_info 40*4c33415eSBrooks Davisfunction retrieves the auxiliary info vector requested in 41*4c33415eSBrooks Davis.Va aux . 42*4c33415eSBrooks DavisThe information is stored into the provided buffer if it will fit. 43*4c33415eSBrooks DavisThe following values, defined in 44*4c33415eSBrooks Davis.In sys/elf_common.h 45*4c33415eSBrooks Daviscan be requested (corresponding buffer sizes are specified in parenthesis): 46*4c33415eSBrooks Davis.Bl -tag -width AT_OSRELDATE 47*4c33415eSBrooks Davis.It AT_CANARY 48*4c33415eSBrooks DavisThe canary value for SSP (arbitrary sized buffer, as many bytes are 49*4c33415eSBrooks Davisreturned as it fits into it, rest is zeroed). 50*4c33415eSBrooks Davis.It AT_EXECPATH 51*4c33415eSBrooks DavisThe path of executed program 52*4c33415eSBrooks Davis.Dv (MAXPATHLEN). 53*4c33415eSBrooks DavisThis may not be present if the process was initialized by 54*4c33415eSBrooks Davis.Xr fexecve 2 55*4c33415eSBrooks Davisand the namecache no longer contains the file's name. 56*4c33415eSBrooks Davis.It AT_HWCAP 57*4c33415eSBrooks DavisCPU / hardware feature flags 58*4c33415eSBrooks Davis.Dv (sizeof(u_long)). 59*4c33415eSBrooks Davis.It AT_HWCAP2 60*4c33415eSBrooks DavisCPU / hardware feature flags 61*4c33415eSBrooks Davis.Dv (sizeof(u_long)). 62*4c33415eSBrooks Davis.It AT_NCPUS 63*4c33415eSBrooks DavisNumber of CPUs 64*4c33415eSBrooks Davis.Dv (sizeof(int)). 65*4c33415eSBrooks Davis.It AT_OSRELDATE 66*4c33415eSBrooks DavisThe 67*4c33415eSBrooks Davis.Dv OSRELDATE 68*4c33415eSBrooks Davisof the kernel or jail the program is running on 69*4c33415eSBrooks Davis.Dv (sizeof(int)). 70*4c33415eSBrooks Davis.It AT_PAGESIZES 71*4c33415eSBrooks DavisVector of page sizes (arbitrary sized buffer, as many elements of the 72*4c33415eSBrooks Davis.Dv pagesizes 73*4c33415eSBrooks Davisarray are returned as it fits). 74*4c33415eSBrooks Davis.It AT_PAGESZ 75*4c33415eSBrooks DavisPage size in bytes 76*4c33415eSBrooks Davis.Dv (sizeof(int)). 77*4c33415eSBrooks Davis.It AT_TIMEKEEP 78*4c33415eSBrooks DavisPointer to VDSO timehands (for library internal use, 79*4c33415eSBrooks Davis.Dv sizeof(void *)). 80*4c33415eSBrooks Davis.It AT_USRSTACKBASE 81*4c33415eSBrooks DavisTop of the user stack for main thread. 82*4c33415eSBrooks Davis.It AT_USRSTACKLIM 83*4c33415eSBrooks DavisLimit for grow of the user stack for main thread. 84*4c33415eSBrooks Davis.El 85*4c33415eSBrooks Davis.Sh RETURN VALUES 86*4c33415eSBrooks DavisReturns zero on success, or an error number on failure. 87*4c33415eSBrooks Davis.Sh ERRORS 88*4c33415eSBrooks Davis.Bl -tag -width Er 89*4c33415eSBrooks Davis.It Bq Er EINVAL 90*4c33415eSBrooks DavisAn unknown item was requested. 91*4c33415eSBrooks Davis.It Bq Er EINVAL 92*4c33415eSBrooks DavisThe provided buffer was not the right size for the requested item. 93*4c33415eSBrooks Davis.It Bq Er ENOENT 94*4c33415eSBrooks DavisThe requested item is not available. 95*4c33415eSBrooks Davis.El 96*4c33415eSBrooks Davis.Sh HISTORY 97*4c33415eSBrooks DavisThe 98*4c33415eSBrooks Davis.Fn elf_aux_info 99*4c33415eSBrooks Davisfunction appeared in 100*4c33415eSBrooks Davis.Fx 12.0 . 101*4c33415eSBrooks Davis.Sh BUGS 102*4c33415eSBrooks DavisOnly a small subset of available auxiliary info vector items are 103*4c33415eSBrooks Davisaccessible with this function. 104*4c33415eSBrooks DavisSome items require a "right-sized" buffer while others just require a 105*4c33415eSBrooks Davis"big enough" buffer. 106