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