1.\" $OpenBSD: dl_iterate_phdr.3,v 1.2 2005/03/07 21:06:43 kettenis 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 January 17, 2005 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.Fd #include <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. 37The information about the program headers is passed in a structure 38that is defined as: 39.Bd -literal 40struct dl_phdr_info { 41 Elf_Addr dlpi_addr; 42 const char *dlpi_name; 43 const Elf_Phdr *dlpi_phdr; 44 Elf_Half dlpi_phnum; 45}; 46.Ed 47.Pp 48The members of 49.Li struct dl_phdr_info 50have the following meaning: 51.Bl -tag -width XXXdlpi_phdr 52.It Fa dlpi_addr 53The base address at which the shared object is mapped into the address 54space of the calling process. 55.It Fa dlpi_name 56The name of the shared object. 57.It Fa dlpi_phdr 58A pointer to the shared object's program headers. 59.It Fa dlpi_phnum 60The number of program headers in the shared object. 61.El 62.Pp 63Future versions of 64.Ox 65might add more members to this structure. 66To make it possible for programs to check whether any new members have 67been added, the size of the structure is passed as an argument to 68.Fa callback . 69.Sh SEE ALSO 70.Xr ld 1 , 71.Xr ld.so 1 , 72.Xr dlfcn 3 , 73.Xr elf 5 74.Sh HISTORY 75The 76.Nm 77function first appeared in 78.Ox 3.7 . 79