1 .\" Copyright (c) 2005 Mark Kettenis
2 .\" Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\" $OpenBSD: dl_iterate_phdr.3,v 1.3 2007/05/31 19:19:48 jmc Exp $
23 .Nd iterate over program headers
25 For the dynamically linked binaries, the service is provided by
28 Statically linked programs use an implementation of
34 .Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void *)" "void *data"
38 function iterates over all ELF objects loaded into a process's
39 address space, calling
41 for each object, passing it information about the object's
42 program headers and the
45 The iteration is aborted when all objects are passed, or when the next
47 call returns non-zero value.
48 The information about the program headers is passed in a structure
53 const char *dlpi_name;
54 const Elf_Phdr *dlpi_phdr;
56 unsigned long long int dlpi_adds;
57 unsigned long long int dlpi_subs;
58 size_t dlpi_tls_modid;
64 .Li struct dl_phdr_info
65 have the following meaning:
66 .Bl -tag -width dlpi_tls_modid
68 The base address at which the object is mapped into the address
69 space of the calling process.
71 The name of the ELF object.
73 A pointer to the object's program headers.
75 The number of program headers in the object.
77 The counter of the object loads performed by the dynamic linker.
79 The counter of the object unloads performed by the dynamic linker.
81 The TLS index of the object.
83 A pointer to the initialization data for the object TLS segment.
88 might add more members to this structure.
89 To make it possible for programs to check whether any new members have
90 been added, the size of the structure is passed as an second argument to
93 The third argument to callback is the
95 value passed to the call to
103 returns the value returned by the last
114 function first appeared in