xref: /freebsd/lib/libc/gen/rtld_get_var.3 (revision e434c56fcd4f9eee04ac6bb5e0cf028db3006be3)
1.\" Copyright (c) 2024 The FreeBSD Foundation
2.\"
3.\" This documentation was written by
4.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
5.\" from the FreeBSD Foundation.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd October 31, 2024
29.Dt RTLD_GET_VAR 3
30.Os
31.Sh NAME
32.Nm rtld_get_var ,
33.Nm rtld_set_var
34.Nd query or change run-time linker parameters after image activation
35.Sh LIBRARY
36.Lb libc
37.Sh SYNOPSIS
38.In sys/errno.h
39.In link.h
40.Ft const char *
41.Fn rtld_get_var "const char *name"
42.Ft int
43.Fn rtld_set_var "const char *name" "const char *value"
44.Sh DESCRIPTION
45The dynamic linker
46.Xr rtld 1
47can be configured by setting some environment variables for the process,
48before image activation.
49Sometimes it is desirable to query the current effective settings or
50change them afterward.
51.Pp
52Since the process environment variables are maintained by higher-level
53libraries, the run-time linker cannot access them after the image
54activation.
55The described functions make it possible to operate on rtld settings.
56.Pp
57The
58.Fn rtld_get_var
59function returns the current value of the named parameter.
60.Pp
61The
62.Fn rtld_set_var
63functions changes the value of the parameter to the new
64.Fa value
65value, if possible.
66The
67.Fa name
68argument to both functions is the name of the parameter, which
69is same as the corresponding environment variable
70.Pq see Xr rtld 1
71but without the
72.Ev LD_
73(or
74.Ev LD_32_
75or any other ABI-specific) prefix.
76.Sh RETURN VALUES
77The
78.Fn rtld_get_var
79returns the current value of the named parameter, or
80.Dv NULL
81if the name is invalid.
82.Pp
83The
84.Fn rtld_set_var
85returns 0 on success, or an integer indicating the error condition
86which prevented the operation.
87.Sh ERRORS
88Possible errors returned from
89.Fn rtld_set_var :
90.Bl -tag -width Er
91.It Bq Er EPERM
92The requested change cannot be made at runtime, either because the
93runtime linker can only take this parameter at initialization time,
94or because the current process is executing with elevated privileges.
95.It Bq ENOENT
96The supplied parameter
97.Fa name
98is unknown.
99.El
100.Sh SEE ALSO
101.Xr rtld 1
102.Sh HISTORY
103The
104.Nm
105function first appeared in
106.Fx 15.0 .
107