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