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