xref: /freebsd-13.1/lib/libc/sys/kldsym.2 (revision 3abf45a1)
1.\" Copyright (c) 2001 Chris Costello <[email protected]>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd October 17, 2016
28.Dt KLDSYM 2
29.Os
30.Sh NAME
31.Nm kldsym
32.Nd look up address by symbol name in a KLD
33.Sh LIBRARY
34.Lb libc
35.Sh SYNOPSIS
36.In sys/param.h
37.In sys/linker.h
38.Ft int
39.Fn kldsym "int fileid" "int cmd" "void *data"
40.Sh DESCRIPTION
41The
42.Fn kldsym
43system call returns the address of the symbol specified in
44.Fa data
45in the module specified by
46.Fa fileid .
47If
48.Fa fileid
49is 0, all loaded modules are searched.
50Currently, the only
51.Fa cmd
52implemented is
53.Dv KLDSYM_LOOKUP .
54.Pp
55The
56.Fa data
57argument is of the following structure:
58.Bd -literal -offset indent
59struct kld_sym_lookup {
60    int         version;        /* sizeof(struct kld_sym_lookup) */
61    char        *symname;       /* Symbol name we are looking up */
62    u_long      symvalue;
63    size_t      symsize;
64};
65.Ed
66.Pp
67The
68.Va version
69member is to be set
70by the code calling
71.Fn kldsym
72to
73.Fn sizeof "struct kld_sym_lookup" .
74The next two members,
75.Va version
76and
77.Va symname ,
78are specified by the user.
79The last two,
80.Va symvalue
81and
82.Va symsize ,
83are filled in by
84.Fn kldsym
85and contain the address associated with
86.Va symname
87and the size of the data it points to, respectively.
88.Sh RETURN VALUES
89.Rv -std kldsym
90.Sh ERRORS
91The
92.Fn kldsym
93system call will fail if:
94.Bl -tag -width Er
95.It Bq Er EINVAL
96Invalid value in
97.Fa data->version
98or
99.Fa cmd .
100.It Bq Er ENOENT
101The
102.Fa fileid
103argument
104is invalid,
105or the specified symbol could not be found.
106.El
107.Sh SEE ALSO
108.Xr kldfind 2 ,
109.Xr kldfirstmod 2 ,
110.Xr kldload 2 ,
111.Xr kldnext 2 ,
112.Xr kldunload 2 ,
113.Xr modfind 2 ,
114.Xr modnext 2 ,
115.Xr modstat 2 ,
116.Xr kld 4
117.Sh HISTORY
118The
119.Fn kldsym
120system call first appeared in
121.Fx 3.0 .
122