1*2ec95d7aSkamil /* $NetBSD: link_elf.h,v 1.13 2020/09/22 01:52:16 kamil Exp $ */ 2e278587dSthorpej 3e278587dSthorpej #ifndef _LINK_ELF_H_ 4e278587dSthorpej #define _LINK_ELF_H_ 541fe218bScgd 641fe218bScgd #include <sys/types.h> 7e6cdac9cSskrll #include <sys/exec_elf.h> 8fd7cb419Sjonathan 9f3656ffaSkamil #define R_DEBUG_VERSION 1 /* SVR4 Protocol version */ 10f3656ffaSkamil 115f6806f4Spooka typedef struct link_map { 1241fe218bScgd caddr_t l_addr; /* Base Address of library */ 13082edeccSmhitch #ifdef __mips__ 14082edeccSmhitch caddr_t l_offs; /* Load Offset of library */ 15082edeccSmhitch #endif 1641fe218bScgd const char *l_name; /* Absolute Path to Library */ 1741fe218bScgd void *l_ld; /* Pointer to .dynamic in memory */ 18*2ec95d7aSkamil struct link_map *l_next; /* linked list of mapped libs */ 1926475619Schristos struct link_map *l_prev; 205f6806f4Spooka } Link_map; 2141fe218bScgd 229c4f0f80Sskrll /* 23acc2f1f4Skamil * Debug rendezvous struct. Pointer to this is set up in the 24acc2f1f4Skamil * target code pointed by the DT_DEBUG tag. If it is 25acc2f1f4Skamil * defined. 269c4f0f80Sskrll */ 2741fe218bScgd struct r_debug { 28acc2f1f4Skamil int r_version; /* protocol version */ 2941fe218bScgd struct link_map *r_map; /* list of loaded images */ 30acc2f1f4Skamil 31acc2f1f4Skamil /* 32acc2f1f4Skamil * This is the address of a function internal to the run-time linker, 33acc2f1f4Skamil * that will always be called when the linker begins to map in a 34acc2f1f4Skamil * library or unmap it, and again when the mapping change is complete. 35acc2f1f4Skamil * The debugger can set a breakpoint at this address if it wants to 36acc2f1f4Skamil * notice shared object mapping changes. 37acc2f1f4Skamil */ 3819b7469aSperry void (*r_brk)(void); /* pointer to break point */ 3941fe218bScgd enum { 40acc2f1f4Skamil /* 41acc2f1f4Skamil * This state value describes the mapping change taking place 42acc2f1f4Skamil * when the `r_brk' address is called. 43acc2f1f4Skamil */ 4441fe218bScgd RT_CONSISTENT, /* things are stable */ 4541fe218bScgd RT_ADD, /* adding a shared library */ 4641fe218bScgd RT_DELETE /* removing a shared library */ 4741fe218bScgd } r_state; 48f3656ffaSkamil void *r_ldbase; /* base address of RTLD */ 4941fe218bScgd }; 5026475619Schristos 51e6cdac9cSskrll struct dl_phdr_info 52e6cdac9cSskrll { 53e6cdac9cSskrll Elf_Addr dlpi_addr; /* module relocation base */ 54e6cdac9cSskrll const char *dlpi_name; /* module name */ 55e6cdac9cSskrll const Elf_Phdr *dlpi_phdr; /* pointer to module's phdr */ 56e6cdac9cSskrll Elf_Half dlpi_phnum; /* number of entries in phdr */ 57e6cdac9cSskrll unsigned long long int dlpi_adds; /* total # of loads */ 58e6cdac9cSskrll unsigned long long int dlpi_subs; /* total # of unloads */ 59e6cdac9cSskrll size_t dlpi_tls_modid; 60e6cdac9cSskrll void *dlpi_tls_data; 61e6cdac9cSskrll }; 62e6cdac9cSskrll 63e6cdac9cSskrll __BEGIN_DECLS 64e6cdac9cSskrll 65e6cdac9cSskrll int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), 66e6cdac9cSskrll void *); 67e6cdac9cSskrll 68e6cdac9cSskrll __END_DECLS 69e6cdac9cSskrll 70e278587dSthorpej #endif /* _LINK_ELF_H_ */ 71