summaryrefslogtreecommitdiffstats
path: root/man3/dl_iterate_phdr.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/dl_iterate_phdr.3')
-rw-r--r--man3/dl_iterate_phdr.339
1 files changed, 19 insertions, 20 deletions
diff --git a/man3/dl_iterate_phdr.3 b/man3/dl_iterate_phdr.3
index dc15758..b5cbb86 100644
--- a/man3/dl_iterate_phdr.3
+++ b/man3/dl_iterate_phdr.3
@@ -3,7 +3,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH dl_iterate_phdr 3 2023-07-20 "Linux man-pages 6.05.01"
+.TH dl_iterate_phdr 3 2023-10-31 "Linux man-pages 6.7"
.SH NAME
dl_iterate_phdr \- walk through list of shared objects
.SH LIBRARY
@@ -13,7 +13,7 @@ Standard C library
.nf
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
.B #include <link.h>
-.PP
+.P
.B int dl_iterate_phdr(
.BI " int (*" callback ")(struct dl_phdr_info *" info ,
.BI " size_t " size ", void *" data ),
@@ -25,7 +25,7 @@ The
function allows an application to inquire at run time to find
out which shared objects it has loaded,
and the order in which they were loaded.
-.PP
+.P
The
.BR dl_iterate_phdr ()
function walks through the list of an
@@ -35,7 +35,7 @@ once for each object,
until either all shared objects have been processed or
.I callback
returns a nonzero value.
-.PP
+.P
Each call to
.I callback
receives three arguments:
@@ -52,11 +52,11 @@ program as the second argument (also named
.IR data )
in the call to
.BR dl_iterate_phdr ().
-.PP
+.P
The
.I info
argument is a structure of the following type:
-.PP
+.P
.in +4n
.EX
struct dl_phdr_info {
@@ -90,7 +90,7 @@ struct dl_phdr_info {
};
.EE
.in
-.PP
+.P
(The
.IR ElfW ()
macro definition turns its argument into the name of an ELF data
@@ -102,7 +102,7 @@ yields the data type name
Further information on these types can be found in the
.IR <elf.h> " and " <link.h>
header files.)
-.PP
+.P
The
.I dlpi_addr
field indicates the base address of the shared object
@@ -113,7 +113,7 @@ The
.I dlpi_name
field is a null-terminated string giving the pathname
from which the shared object was loaded.
-.PP
+.P
To understand the meaning of the
.I dlpi_phdr
and
@@ -128,9 +128,9 @@ shared object.
The
.I dlpi_phnum
field indicates the size of this array.
-.PP
+.P
These program headers are structures of the following form:
-.PP
+.P
.in +4n
.EX
typedef struct {
@@ -145,23 +145,23 @@ typedef struct {
} Elf32_Phdr;
.EE
.in
-.PP
+.P
Note that we can calculate the location of a particular program header,
.IR x ,
in virtual memory using the formula:
-.PP
+.P
.in +4n
.EX
addr == info\->dlpi_addr + info\->dlpi_phdr[x].p_vaddr;
.EE
.in
-.PP
+.P
Possible values for
.I p_type
include the following (see
.I <elf.h>
for further details):
-.PP
+.P
.in +4n
.EX
#define PT_LOAD 1 /* Loadable program segment */
@@ -196,7 +196,6 @@ T{
.BR dl_iterate_phdr ()
T} Thread safety MT-Safe
.TE
-.sp 1
.SH VERSIONS
Various other systems provide a version of this function,
although details of the returned
@@ -209,7 +208,7 @@ On the BSDs and Solaris, the structure includes the fields
and
.I dlpi_phnum
in addition to other implementation-specific fields.
-.PP
+.P
Future versions of the C library may add further fields to the
.I dl_phdr_info
structure; in that event, the
@@ -233,13 +232,13 @@ shared objects it has loaded.
For each shared object, the program lists some information
(virtual address, size, flags, and type)
for each of the objects ELF segments.
-.PP
+.P
The following shell session demonstrates the output
produced by the program on an x86-64 system.
The first shared object for which output is displayed
(where the name is an empty string)
is the main program.
-.PP
+.P
.in +4n
.EX
$ \fB./a.out\fP
@@ -341,6 +340,6 @@ main(void)
.BR dlopen (3),
.BR elf (5),
.BR ld.so (8)
-.PP
+.P
.IR "Executable and Linking Format Specification" ,
available at various locations online.