xref: /openbsd/share/man/man3/dl_iterate_phdr.3 (revision 09467b48)
1.\"   $OpenBSD: dl_iterate_phdr.3,v 1.5 2018/08/24 13:14:14 edd Exp $
2.\"
3.\" Copyright (c) 2005 Mark Kettenis
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 24 2018 $
18.Dt DL_ITERATE_PHDR 3
19.Os
20.Sh NAME
21.Nm dl_iterate_phdr
22.Nd iterate over program headers
23.Sh SYNOPSIS
24.In link.h
25.Ft int
26.Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void*)" "void *data"
27.Sh DESCRIPTION
28The
29.Fn dl_iterate_phdr
30function iterates over all shared objects loaded into a process's
31address space, calling
32.Fa callback
33for each shared object, passing it information about the object's
34program headers and the
35.Fa data
36argument.
37Iteration continues until either there are no more objects to
38iterate over or
39.Fa callback
40returns a non-zero value.
41.Pp
42The information about the program headers is passed in a structure
43that is defined as:
44.Bd -literal
45struct dl_phdr_info {
46	Elf_Addr	dlpi_addr;
47	const char	*dlpi_name;
48	const Elf_Phdr	*dlpi_phdr;
49	Elf_Half	dlpi_phnum;
50};
51.Ed
52.Pp
53The members of
54.Li struct dl_phdr_info
55have the following meaning:
56.Bl -tag -width XXXdlpi_phdr
57.It Fa dlpi_addr
58The base address at which the shared object is mapped into the address
59space of the calling process.
60.It Fa dlpi_name
61The name of the shared object.
62.It Fa dlpi_phdr
63A pointer to the shared object's program headers.
64.It Fa dlpi_phnum
65The number of program headers in the shared object.
66.El
67.Pp
68Future versions of
69.Ox
70might add more members to this structure.
71To make it possible for programs to check whether any new members have
72been added, the size of the structure is passed as an argument to
73.Fa callback .
74.Sh SEE ALSO
75.Xr ld 1 ,
76.Xr ld.so 1 ,
77.Xr dlfcn 3 ,
78.Xr elf 5
79.Sh HISTORY
80The
81.Nm
82function first appeared in
83.Ox 3.7 .
84