blob: 78ebd483778bf00693ac7ed9f09fe93dd0166d43 [file] [log] [blame]
Adam Barth57eacf52020-11-04 00:38:09 +00001#ifndef SYSROOT_LINK_H_
2#define SYSROOT_LINK_H_
Doug Horn1427b6a2018-12-11 13:19:16 -08003
4#ifdef __cplusplus
5extern "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#define ElfW(type) Elf64_##type
14
15/* this is the same everywhere except alpha and s390 */
16typedef uint32_t Elf_Symndx;
17
18struct dl_phdr_info {
Adam Barth57eacf52020-11-04 00:38:09 +000019 ElfW(Addr) dlpi_addr;
20 const char* dlpi_name;
21 const ElfW(Phdr) * dlpi_phdr;
22 ElfW(Half) dlpi_phnum;
23 unsigned long long int dlpi_adds;
24 unsigned long long int dlpi_subs;
25 size_t dlpi_tls_modid;
26 void* dlpi_tls_data;
Doug Horn1427b6a2018-12-11 13:19:16 -080027};
28
29struct link_map {
Adam Barth57eacf52020-11-04 00:38:09 +000030 ElfW(Addr) l_addr;
31 char* l_name;
32 ElfW(Dyn) * l_ld;
33 struct link_map *l_next, *l_prev;
Doug Horn1427b6a2018-12-11 13:19:16 -080034};
35
36struct r_debug {
Adam Barth57eacf52020-11-04 00:38:09 +000037 int r_version;
38 struct link_map* r_map;
39 ElfW(Addr) r_brk;
40
41 /* This is the address of a function internal to the run-time linker
42 that triggers a debug trap. This function will always be called
43 when the linker begins to map in a library or unmap it, and again
44 when the mapping change is complete.
45
46 The debugger can compare the address of a sw exception to this value
47 to determine whether the debug trap was triggered by the run-time
48 linker. */
49 ElfW(Addr) r_brk_on_load;
50
51 enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
52 ElfW(Addr) r_ldbase;
Doug Horn1427b6a2018-12-11 13:19:16 -080053};
54
55int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*);
56
57#ifdef __cplusplus
58}
59#endif
Adam Barth57eacf52020-11-04 00:38:09 +000060
61#endif // SYSROOT_LINK_H_