{"id":6767,"date":"2022-12-20T19:33:37","date_gmt":"2022-12-20T22:33:37","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/dl_iterate_phdr-man3\/"},"modified":"2022-12-20T19:33:37","modified_gmt":"2022-12-20T22:33:37","slug":"dl_iterate_phdr-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/dl_iterate_phdr-man3\/","title":{"rendered":"DL_ITERATE_PHDR (man3)"},"content":{"rendered":"<h1 align=\"center\">DL_ITERATE_PHDR<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#VERSIONS\">VERSIONS<\/a><br \/> <a href=\"#ATTRIBUTES\">ATTRIBUTES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">dl_iterate_phdr \u2212 walk through list of shared objects<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#define _GNU_SOURCE<\/b> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var See feature_test_macros(7) bodies\/ usr\/ <b><br \/> #include <link.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int dl_iterate_phdr( <br \/> int (*<\/b><i>callback<\/i><b>) (struct dl_phdr_info *<\/b><i>info<\/i><b>, <br \/> size_t<\/b> <i>size<\/i><b>, void *<\/b><i>data<\/i><b>), <br \/> void *<\/b><i>data<\/i><b>);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>dl_iterate_phdr<\/b>() 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.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>dl_iterate_phdr<\/b>() function walks through the list of an application\u2019s shared objects and calls the function <i>callback<\/i> once for each object, until either all shared objects have been processed or <i>callback<\/i> returns a nonzero value.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Each call to <i>callback<\/i> receives three arguments: <i>info<\/i>, which is a pointer to a structure containing information about the shared object; <i>size<\/i>, which is the size of the structure pointed to by <i>info<\/i>; and <i>data<\/i>, which is a copy of whatever value was passed by the calling program as the second argument (also named <i>data<\/i>) in the call to <b>dl_iterate_phdr<\/b>().<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>info<\/i> argument is a structure of the following type:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">struct dl_phdr_info { <br \/> ElfW(Addr) dlpi_addr; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Base address of object bodies\/ usr\/ <br \/> const char *dlpi_name; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var (Null-terminated) name of <br \/> object bodies\/ usr\/ <br \/> const ElfW(Phdr) *dlpi_phdr; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Pointer to array of <br \/> ELF program headers <br \/> for this object bodies\/ usr\/ <br \/> ElfW(Half) dlpi_phnum; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var # of items in <i>dlpi_phdr<\/i> *\/<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* The following fields were added in glibc 2.4, after the first <br \/> version of this structure was available. Check the <i>size<\/i> <br \/> argument passed to the dl_iterate_phdr callback to determine <br \/> whether or not each later member is available. *\/<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">unsigned long long dlpi_adds; <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Incremented when a new object may <br \/> have been added bodies\/ usr\/ <br \/> unsigned long long dlpi_subs; <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Incremented when an object may <br \/> have been removed bodies\/ usr\/ <br \/> size_t dlpi_tls_modid; <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var If there is a PT_TLS segment, its module <br \/> ID as used in TLS relocations, else zero bodies\/ usr\/ <br \/> void *dlpi_tls_data; <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var The address of the calling thread&#8217;s instance <br \/> of this module&#8217;s PT_TLS segment, if it has <br \/> one and it has been allocated in the calling <br \/> thread, otherwise a null pointer bodies\/ usr\/ <br \/> };<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">(The <i>ElfW<\/i>() macro definition turns its argument into the name of an ELF data type suitable for the hardware architecture. For example, on a 32-bit platform, <i>ElfW(Addr)<\/i> yields the data type name <i>Elf32_Addr<\/i>. Further information on these types can be found in the <i><elf.h><\/i> and <i><link.h><\/i> header files.)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>dlpi_addr<\/i> field indicates the base address of the shared object (i.e., the difference between the virtual memory address of the shared object and the offset of that object in the file from which it was loaded). The <i>dlpi_name<\/i> field is a null-terminated string giving the pathname from which the shared object was loaded.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To understand the meaning of the <i>dlpi_phdr<\/i> and <i>dlpi_phnum<\/i> fields, we need to be aware that an ELF shared object consists of a number of segments, each of which has a corresponding program header describing the segment. The <i>dlpi_phdr<\/i> field is a pointer to an array of the program headers for this shared object. The <i>dlpi_phnum<\/i> field indicates the size of this array.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">These program headers are structures of the following form:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">typedef struct { <br \/> Elf32_Word p_type; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment type bodies\/ usr\/ <br \/> Elf32_Off p_offset; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment file offset bodies\/ usr\/ <br \/> Elf32_Addr p_vaddr; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment virtual address bodies\/ usr\/ <br \/> Elf32_Addr p_paddr; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment physical address bodies\/ usr\/ <br \/> Elf32_Word p_filesz; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment size in file bodies\/ usr\/ <br \/> Elf32_Word p_memsz; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment size in memory bodies\/ usr\/ <br \/> Elf32_Word p_flags; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment flags bodies\/ usr\/ <br \/> Elf32_Word p_align; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Segment alignment bodies\/ usr\/ <br \/> } Elf32_Phdr;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that we can calculate the location of a particular program header, <i>x<\/i>, in virtual memory using the formula:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">addr == info\u2212>dlpi_addr + info\u2212>dlpi_phdr[x].p_vaddr;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Possible values for <i>p_type<\/i> include the following (see <i><elf.h><\/i> for further details):<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#define PT_LOAD 1 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Loadable program segment bodies\/ usr\/ <br \/> #define PT_DYNAMIC 2 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Dynamic linking information bodies\/ usr\/ <br \/> #define PT_INTERP 3 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Program interpreter bodies\/ usr\/ <br \/> #define PT_NOTE 4 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Auxiliary information bodies\/ usr\/ <br \/> #define PT_SHLIB 5 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Reserved bodies\/ usr\/ <br \/> #define PT_PHDR 6 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Entry for header table itself bodies\/ usr\/ <br \/> #define PT_TLS 7 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Thread-local storage segment bodies\/ usr\/ <br \/> #define PT_GNU_EH_FRAME 0x6474e550 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var GCC .eh_frame_hdr segment bodies\/ usr\/ <br \/> #define PT_GNU_STACK 0x6474e551 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Indicates stack executability bodies\/ usr\/ <br \/> #define PT_GNU_RELRO 0x6474e552 \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Read-only after relocation *\/<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>dl_iterate_phdr<\/b>() function returns whatever value was returned by the last call to <i>callback<\/i>.<\/p>\n<h2>VERSIONS <a name=\"VERSIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>dl_iterate_phdr<\/b>() has been supported in glibc since version 2.2.4.<\/p>\n<h2>ATTRIBUTES <a name=\"ATTRIBUTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For an explanation of the terms used in this section, see <b>attributes<\/b>(7).<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"> <\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<\/table>\n<p align=\"center\"><img decoding=\"async\" src=\"grohtml-1610571.png\" alt=\"Image grohtml-1610571.png\"><\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>dl_iterate_phdr<\/b>() function is not specified in any standard. Various other systems provide a version of this function, although details of the returned <i>dl_phdr_info<\/i> structure differ. On the BSDs and Solaris, the structure includes the fields <i>dlpi_addr<\/i>, <i>dlpi_name<\/i>, <i>dlpi_phdr<\/i>, and <i>dlpi_phnum<\/i> in addition to other implementation-specific fields.<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Future versions of the C library may add further fields to the <i>dl_phdr_info<\/i> structure; in that event, the <i>size<\/i> argument provides a mechanism for the callback function to discover whether it is running on a system with added fields.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The first object visited by <i>callback<\/i> is the main program. For the main program, the <i>dlpi_name<\/i> field will be an empty string.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following program displays a list of pathnames of the 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.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ <b>.\/a.out<\/b> <br \/> Name: &#8220;&#8221; (9 segments) <br \/> 0: [ 0x400040; memsz: 1f8] flags: 0x5; PT_PHDR <br \/> 1: [ 0x400238; memsz: 1c] flags: 0x4; PT_INTERP <br \/> 2: [ 0x400000; memsz: ac4] flags: 0x5; PT_LOAD <br \/> 3: [ 0x600e10; memsz: 240] flags: 0x6; PT_LOAD <br \/> 4: [ 0x600e28; memsz: 1d0] flags: 0x6; PT_DYNAMIC <br \/> 5: [ 0x400254; memsz: 44] flags: 0x4; PT_NOTE <br \/> 6: [ 0x400970; memsz: 3c] flags: 0x4; PT_GNU_EH_FRAME <br \/> 7: [ (nil); memsz: 0] flags: 0x6; PT_GNU_STACK <br \/> 8: [ 0x600e10; memsz: 1f0] flags: 0x4; PT_GNU_RELRO <br \/> Name: &#8220;linux-vdso.so.1&#8221; (4 segments) <br \/> 0: [0x7ffc6edd1000; memsz: e89] flags: 0x5; PT_LOAD <br \/> 1: [0x7ffc6edd1360; memsz: 110] flags: 0x4; PT_DYNAMIC <br \/> 2: [0x7ffc6edd17b0; memsz: 3c] flags: 0x4; PT_NOTE <br \/> 3: [0x7ffc6edd17ec; memsz: 3c] flags: 0x4; PT_GNU_EH_FRAME <br \/> Name: &#8220;\/lib64\/libc.so.6&#8221; (10 segments) <br \/> 0: [0x7f55712ce040; memsz: 230] flags: 0x5; PT_PHDR <br \/> 1: [0x7f557145b980; memsz: 1c] flags: 0x4; PT_INTERP <br \/> 2: [0x7f55712ce000; memsz: 1b6a5c] flags: 0x5; PT_LOAD <br \/> 3: [0x7f55716857a0; memsz: 9240] flags: 0x6; PT_LOAD <br \/> 4: [0x7f5571688b80; memsz: 1f0] flags: 0x6; PT_DYNAMIC <br \/> 5: [0x7f55712ce270; memsz: 44] flags: 0x4; PT_NOTE <br \/> 6: [0x7f55716857a0; memsz: 78] flags: 0x4; PT_TLS <br \/> 7: [0x7f557145b99c; memsz: 544c] flags: 0x4; PT_GNU_EH_FRAME <br \/> 8: [0x7f55712ce000; memsz: 0] flags: 0x6; PT_GNU_STACK <br \/> 9: [0x7f55716857a0; memsz: 3860] flags: 0x4; PT_GNU_RELRO <br \/> Name: &#8220;\/lib64\/ld-linux-x86-64.so.2&#8221; (7 segments) <br \/> 0: [0x7f557168f000; memsz: 20828] flags: 0x5; PT_LOAD <br \/> 1: [0x7f55718afba0; memsz: 15a8] flags: 0x6; PT_LOAD <br \/> 2: [0x7f55718afe10; memsz: 190] flags: 0x6; PT_DYNAMIC <br \/> 3: [0x7f557168f1c8; memsz: 24] flags: 0x4; PT_NOTE <br \/> 4: [0x7f55716acec4; memsz: 604] flags: 0x4; PT_GNU_EH_FRAME <br \/> 5: [0x7f557168f000; memsz: 0] flags: 0x6; PT_GNU_STACK <br \/> 6: [0x7f55718afba0; memsz: 460] flags: 0x4; PT_GNU_RELRO<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Program source<\/b> <br \/> #define _GNU_SOURCE <br \/> #include <link.h> #include <stdlib.h> <br \/> #include <stdio.h> <br \/> #include <stdint.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">static int <br \/> callback(struct dl_phdr_info *info, size_t size, void *data) <br \/> { <br \/> char *type; <br \/> int p_type;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">printf(&#8220;Name: &#8220;%s&#8221; (%d segments)n&#8221;, info\u2212>dlpi_name, <br \/> info\u2212>dlpi_phnum);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">for (int j = 0; j < info\u2212>dlpi_phnum; j++) { <br \/> p_type = info\u2212>dlpi_phdr[j].p_type; <br \/> type = (p_type == PT_LOAD) ? &#8220;PT_LOAD&#8221; : <br \/> (p_type == PT_DYNAMIC) ? &#8220;PT_DYNAMIC&#8221; : <br \/> (p_type == PT_INTERP) ? &#8220;PT_INTERP&#8221; : <br \/> (p_type == PT_NOTE) ? &#8220;PT_NOTE&#8221; : <br \/> (p_type == PT_INTERP) ? &#8220;PT_INTERP&#8221; : <br \/> (p_type == PT_PHDR) ? &#8220;PT_PHDR&#8221; : <br \/> (p_type == PT_TLS) ? &#8220;PT_TLS&#8221; : <br \/> (p_type == PT_GNU_EH_FRAME) ? &#8220;PT_GNU_EH_FRAME&#8221; : <br \/> (p_type == PT_GNU_STACK) ? &#8220;PT_GNU_STACK&#8221; : <br \/> (p_type == PT_GNU_RELRO) ? &#8220;PT_GNU_RELRO&#8221; : NULL;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">printf(&#8221; %2d: [%14p; memsz:%7jx] flags: %#jx; &#8220;, j, <br \/> (void *) (info\u2212>dlpi_addr + info\u2212>dlpi_phdr[j].p_vaddr), <br \/> (uintmax_t) info\u2212>dlpi_phdr[j].p_memsz, <br \/> (uintmax_t) info\u2212>dlpi_phdr[j].p_flags); <br \/> if (type != NULL) <br \/> printf(&#8220;%sn&#8221;, type); <br \/> else <br \/> printf(&#8220;[other (%#x)]n&#8221;, p_type); <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">return 0; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <br \/> main(int argc, char *argv[]) <br \/> { <br \/> dl_iterate_phdr(callback, NULL);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">exit(EXIT_SUCCESS); <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>ldd<\/b>(1), <b>objdump<\/b>(1), <b>readelf<\/b>(1), <b>dladdr<\/b>(3), <b>dlopen<\/b>(3), <b>elf<\/b>(5), <b>ld.so<\/b>(8)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>Executable and Linking Format Specification<\/i>, available at various locations online.<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  dl_iterate_phdr \u2212 walk through list of shared objects <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3138,3007],"class_list":["post-6767","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-dl_iterate_phdr","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6767","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6767"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6767\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}