1 1.13 kamil /* $NetBSD: link_elf.h,v 1.13 2020/09/22 01:52:16 kamil Exp $ */ 2 1.5 thorpej 3 1.5 thorpej #ifndef _LINK_ELF_H_ 4 1.5 thorpej #define _LINK_ELF_H_ 5 1.1 cgd 6 1.1 cgd #include <sys/types.h> 7 1.10 skrll #include <sys/exec_elf.h> 8 1.1 cgd 9 1.12 kamil #define R_DEBUG_VERSION 1 /* SVR4 Protocol version */ 10 1.12 kamil 11 1.8 pooka typedef struct link_map { 12 1.4 christos caddr_t l_addr; /* Base Address of library */ 13 1.2 mhitch #ifdef __mips__ 14 1.4 christos caddr_t l_offs; /* Load Offset of library */ 15 1.2 mhitch #endif 16 1.4 christos const char *l_name; /* Absolute Path to Library */ 17 1.4 christos void *l_ld; /* Pointer to .dynamic in memory */ 18 1.13 kamil struct link_map *l_next; /* linked list of mapped libs */ 19 1.4 christos struct link_map *l_prev; 20 1.8 pooka } Link_map; 21 1.1 cgd 22 1.9 skrll /* 23 1.11 kamil * Debug rendezvous struct. Pointer to this is set up in the 24 1.11 kamil * target code pointed by the DT_DEBUG tag. If it is 25 1.11 kamil * defined. 26 1.9 skrll */ 27 1.1 cgd struct r_debug { 28 1.11 kamil int r_version; /* protocol version */ 29 1.4 christos struct link_map *r_map; /* list of loaded images */ 30 1.11 kamil 31 1.11 kamil /* 32 1.11 kamil * This is the address of a function internal to the run-time linker, 33 1.11 kamil * that will always be called when the linker begins to map in a 34 1.11 kamil * library or unmap it, and again when the mapping change is complete. 35 1.11 kamil * The debugger can set a breakpoint at this address if it wants to 36 1.11 kamil * notice shared object mapping changes. 37 1.11 kamil */ 38 1.7 uwe void (*r_brk)(void); /* pointer to break point */ 39 1.1 cgd enum { 40 1.11 kamil /* 41 1.11 kamil * This state value describes the mapping change taking place 42 1.11 kamil * when the `r_brk' address is called. 43 1.11 kamil */ 44 1.4 christos RT_CONSISTENT, /* things are stable */ 45 1.4 christos RT_ADD, /* adding a shared library */ 46 1.4 christos RT_DELETE /* removing a shared library */ 47 1.4 christos } r_state; 48 1.12 kamil void *r_ldbase; /* base address of RTLD */ 49 1.1 cgd }; 50 1.4 christos 51 1.10 skrll struct dl_phdr_info 52 1.10 skrll { 53 1.10 skrll Elf_Addr dlpi_addr; /* module relocation base */ 54 1.10 skrll const char *dlpi_name; /* module name */ 55 1.10 skrll const Elf_Phdr *dlpi_phdr; /* pointer to module's phdr */ 56 1.10 skrll Elf_Half dlpi_phnum; /* number of entries in phdr */ 57 1.10 skrll unsigned long long int dlpi_adds; /* total # of loads */ 58 1.10 skrll unsigned long long int dlpi_subs; /* total # of unloads */ 59 1.10 skrll size_t dlpi_tls_modid; 60 1.10 skrll void *dlpi_tls_data; 61 1.10 skrll }; 62 1.10 skrll 63 1.10 skrll __BEGIN_DECLS 64 1.10 skrll 65 1.10 skrll int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), 66 1.10 skrll void *); 67 1.10 skrll 68 1.10 skrll __END_DECLS 69 1.10 skrll 70 1.5 thorpej #endif /* _LINK_ELF_H_ */ 71