1 #ifndef _LINK_H 2 #define _LINK_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <elf.h> 9 #define __NEED_size_t 10 #define __NEED_uint32_t 11 #include <bits/alltypes.h> 12 13 #if UINTPTR_MAX > 0xffffffff 14 #define ElfW(type) Elf64_ ## type 15 #else 16 #define ElfW(type) Elf32_ ## type 17 #endif 18 19 #include <bits/link.h> 20 21 struct dl_phdr_info { 22 ElfW(Addr) dlpi_addr; 23 const char *dlpi_name; 24 const ElfW(Phdr) *dlpi_phdr; 25 ElfW(Half) dlpi_phnum; 26 unsigned long long int dlpi_adds; 27 unsigned long long int dlpi_subs; 28 size_t dlpi_tls_modid; 29 void *dlpi_tls_data; 30 }; 31 32 struct link_map { 33 ElfW(Addr) l_addr; 34 char *l_name; 35 ElfW(Dyn) *l_ld; 36 struct link_map *l_next, *l_prev; 37 }; 38 39 struct r_debug { 40 int r_version; 41 struct link_map *r_map; 42 ElfW(Addr) r_brk; 43 enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state; 44 ElfW(Addr) r_ldbase; 45 }; 46 47 int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *); 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 #endif 54