xref: /freebsd/lib/libc/gen/rtld_get_var.3 (revision e434c56fcd4f9eee04ac6bb5e0cf028db3006be3)
13820f784SKonstantin Belousov.\" Copyright (c) 2024 The FreeBSD Foundation
23820f784SKonstantin Belousov.\"
33820f784SKonstantin Belousov.\" This documentation was written by
43820f784SKonstantin Belousov.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
53820f784SKonstantin Belousov.\" from the FreeBSD Foundation.
63820f784SKonstantin Belousov.\"
73820f784SKonstantin Belousov.\" Redistribution and use in source and binary forms, with or without
83820f784SKonstantin Belousov.\" modification, are permitted provided that the following conditions
93820f784SKonstantin Belousov.\" are met:
103820f784SKonstantin Belousov.\" 1. Redistributions of source code must retain the above copyright
113820f784SKonstantin Belousov.\"    notice, this list of conditions and the following disclaimer.
123820f784SKonstantin Belousov.\" 2. Redistributions in binary form must reproduce the above copyright
133820f784SKonstantin Belousov.\"    notice, this list of conditions and the following disclaimer in the
143820f784SKonstantin Belousov.\"    documentation and/or other materials provided with the distribution.
153820f784SKonstantin Belousov.\"
163820f784SKonstantin Belousov.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
173820f784SKonstantin Belousov.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
183820f784SKonstantin Belousov.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
193820f784SKonstantin Belousov.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
203820f784SKonstantin Belousov.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
213820f784SKonstantin Belousov.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
223820f784SKonstantin Belousov.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
233820f784SKonstantin Belousov.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
243820f784SKonstantin Belousov.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
253820f784SKonstantin Belousov.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
263820f784SKonstantin Belousov.\" SUCH DAMAGE.
273820f784SKonstantin Belousov.\"
283820f784SKonstantin Belousov.Dd October 31, 2024
293820f784SKonstantin Belousov.Dt RTLD_GET_VAR 3
303820f784SKonstantin Belousov.Os
313820f784SKonstantin Belousov.Sh NAME
323820f784SKonstantin Belousov.Nm rtld_get_var ,
333820f784SKonstantin Belousov.Nm rtld_set_var
343820f784SKonstantin Belousov.Nd query or change run-time linker parameters after image activation
353820f784SKonstantin Belousov.Sh LIBRARY
363820f784SKonstantin Belousov.Lb libc
373820f784SKonstantin Belousov.Sh SYNOPSIS
383820f784SKonstantin Belousov.In sys/errno.h
393820f784SKonstantin Belousov.In link.h
403820f784SKonstantin Belousov.Ft const char *
413820f784SKonstantin Belousov.Fn rtld_get_var "const char *name"
423820f784SKonstantin Belousov.Ft int
433820f784SKonstantin Belousov.Fn rtld_set_var "const char *name" "const char *value"
443820f784SKonstantin Belousov.Sh DESCRIPTION
453820f784SKonstantin BelousovThe dynamic linker
463820f784SKonstantin Belousov.Xr rtld 1
47*e434c56fSKonstantin Belousovcan be configured by setting some environment variables for the process,
483820f784SKonstantin Belousovbefore image activation.
493820f784SKonstantin BelousovSometimes it is desirable to query the current effective settings or
503820f784SKonstantin Belousovchange them afterward.
513820f784SKonstantin Belousov.Pp
523820f784SKonstantin BelousovSince the process environment variables are maintained by higher-level
533820f784SKonstantin Belousovlibraries, the run-time linker cannot access them after the image
543820f784SKonstantin Belousovactivation.
553820f784SKonstantin BelousovThe described functions make it possible to operate on rtld settings.
563820f784SKonstantin Belousov.Pp
573820f784SKonstantin BelousovThe
583820f784SKonstantin Belousov.Fn rtld_get_var
593820f784SKonstantin Belousovfunction returns the current value of the named parameter.
603820f784SKonstantin Belousov.Pp
613820f784SKonstantin BelousovThe
623820f784SKonstantin Belousov.Fn rtld_set_var
633820f784SKonstantin Belousovfunctions changes the value of the parameter to the new
643820f784SKonstantin Belousov.Fa value
653820f784SKonstantin Belousovvalue, if possible.
663820f784SKonstantin BelousovThe
673820f784SKonstantin Belousov.Fa name
683820f784SKonstantin Belousovargument to both functions is the name of the parameter, which
693820f784SKonstantin Belousovis same as the corresponding environment variable
703820f784SKonstantin Belousov.Pq see Xr rtld 1
713820f784SKonstantin Belousovbut without the
723820f784SKonstantin Belousov.Ev LD_
733820f784SKonstantin Belousov(or
743820f784SKonstantin Belousov.Ev LD_32_
753820f784SKonstantin Belousovor any other ABI-specific) prefix.
763820f784SKonstantin Belousov.Sh RETURN VALUES
773820f784SKonstantin BelousovThe
783820f784SKonstantin Belousov.Fn rtld_get_var
793820f784SKonstantin Belousovreturns the current value of the named parameter, or
803820f784SKonstantin Belousov.Dv NULL
813820f784SKonstantin Belousovif the name is invalid.
823820f784SKonstantin Belousov.Pp
833820f784SKonstantin BelousovThe
843820f784SKonstantin Belousov.Fn rtld_set_var
853820f784SKonstantin Belousovreturns 0 on success, or an integer indicating the error condition
863820f784SKonstantin Belousovwhich prevented the operation.
873820f784SKonstantin Belousov.Sh ERRORS
883820f784SKonstantin BelousovPossible errors returned from
893820f784SKonstantin Belousov.Fn rtld_set_var :
903820f784SKonstantin Belousov.Bl -tag -width Er
913820f784SKonstantin Belousov.It Bq Er EPERM
923820f784SKonstantin BelousovThe requested change cannot be made at runtime, either because the
933820f784SKonstantin Belousovruntime linker can only take this parameter at initialization time,
943820f784SKonstantin Belousovor because the current process is executing with elevated privileges.
953820f784SKonstantin Belousov.It Bq ENOENT
963820f784SKonstantin BelousovThe supplied parameter
973820f784SKonstantin Belousov.Fa name
983820f784SKonstantin Belousovis unknown.
993820f784SKonstantin Belousov.El
1003820f784SKonstantin Belousov.Sh SEE ALSO
1013820f784SKonstantin Belousov.Xr rtld 1
1023820f784SKonstantin Belousov.Sh HISTORY
1033820f784SKonstantin BelousovThe
1043820f784SKonstantin Belousov.Nm
1053820f784SKonstantin Belousovfunction first appeared in
1063820f784SKonstantin Belousov.Fx 15.0 .
107