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 $
22 .Nd iterate over program headers
24 For the dynamically linked binaries, the service is provided by
27 Statically linked programs use an implementation of
33 .Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void *)" "void *data"
37 function iterates over all ELF objects loaded into a process's
38 address space, calling
40 for each object, passing it information about the object's
41 program headers and the
44 The iteration is aborted when all objects are passed, or when the next
46 call returns non-zero value.
47 The information about the program headers is passed in a structure
52 const char *dlpi_name;
53 const Elf_Phdr *dlpi_phdr;
55 unsigned long long int dlpi_adds;
56 unsigned long long int dlpi_subs;
57 size_t dlpi_tls_modid;
63 .Li struct dl_phdr_info
64 have the following meaning:
65 .Bl -tag -width dlpi_tls_modid
67 The base address at which the object is mapped into the address
68 space of the calling process.
70 The pathname of the ELF object.
72 A pointer to the object's program headers.
74 The number of program headers in the object.
76 The counter of the object loads performed by the dynamic linker.
78 The counter of the object unloads performed by the dynamic linker.
80 The TLS index of the object.
82 A pointer to the calling thread' TLS data segment for this module,
90 might add more members to this structure.
91 To make it possible for programs to check whether any new members have
92 been added, the size of the structure is passed as an second argument to
95 The third argument to callback is the
97 value passed to the call to
105 returns the value returned by the last
116 function first appeared in