xref: /freebsd/lib/libsys/kldsym.2 (revision 5036d9652a5701d00e9e40ea942c278e9f77d33d)
1.\" Copyright (c) 2001 Chris Costello <chris@FreeBSD.org>
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.Dd October 17, 2016
26.Dt KLDSYM 2
27.Os
28.Sh NAME
29.Nm kldsym
30.Nd look up address by symbol name in a KLD
31.Sh LIBRARY
32.Lb libc
33.Sh SYNOPSIS
34.In sys/linker.h
35.Ft int
36.Fn kldsym "int fileid" "int cmd" "void *data"
37.Sh DESCRIPTION
38The
39.Fn kldsym
40system call returns the address of the symbol specified in
41.Fa data
42in the module specified by
43.Fa fileid .
44If
45.Fa fileid
46is 0, all loaded modules are searched.
47Currently, the only
48.Fa cmd
49implemented is
50.Dv KLDSYM_LOOKUP .
51.Pp
52The
53.Fa data
54argument is of the following structure:
55.Bd -literal -offset indent
56struct kld_sym_lookup {
57    int         version;        /* sizeof(struct kld_sym_lookup) */
58    char        *symname;       /* Symbol name we are looking up */
59    u_long      symvalue;
60    size_t      symsize;
61};
62.Ed
63.Pp
64The
65.Va version
66member is to be set
67by the code calling
68.Fn kldsym
69to
70.Fn sizeof "struct kld_sym_lookup" .
71The next two members,
72.Va version
73and
74.Va symname ,
75are specified by the user.
76The last two,
77.Va symvalue
78and
79.Va symsize ,
80are filled in by
81.Fn kldsym
82and contain the address associated with
83.Va symname
84and the size of the data it points to, respectively.
85.Sh RETURN VALUES
86.Rv -std kldsym
87.Sh ERRORS
88The
89.Fn kldsym
90system call will fail if:
91.Bl -tag -width Er
92.It Bq Er EINVAL
93Invalid value in
94.Fa data->version
95or
96.Fa cmd .
97.It Bq Er ENOENT
98The
99.Fa fileid
100argument
101is invalid,
102or the specified symbol could not be found.
103.El
104.Sh SEE ALSO
105.Xr kldfind 2 ,
106.Xr kldfirstmod 2 ,
107.Xr kldload 2 ,
108.Xr kldnext 2 ,
109.Xr kldunload 2 ,
110.Xr modfind 2 ,
111.Xr modnext 2 ,
112.Xr modstat 2 ,
113.Xr kld 4
114.Sh HISTORY
115The
116.Fn kldsym
117system call first appeared in
118.Fx 3.0 .
119