Adam Barth | 57eacf5 | 2020-11-04 00:38:09 +0000 | [diff] [blame^] | 1 | #ifndef SYSROOT_LINK_H_ |
| 2 | #define SYSROOT_LINK_H_ |
Doug Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "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 */ |
| 16 | typedef uint32_t Elf_Symndx; |
| 17 | |
| 18 | struct dl_phdr_info { |
Adam Barth | 57eacf5 | 2020-11-04 00:38:09 +0000 | [diff] [blame^] | 19 | 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 Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | struct link_map { |
Adam Barth | 57eacf5 | 2020-11-04 00:38:09 +0000 | [diff] [blame^] | 30 | ElfW(Addr) l_addr; |
| 31 | char* l_name; |
| 32 | ElfW(Dyn) * l_ld; |
| 33 | struct link_map *l_next, *l_prev; |
Doug Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | struct r_debug { |
Adam Barth | 57eacf5 | 2020-11-04 00:38:09 +0000 | [diff] [blame^] | 37 | 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 Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*); |
| 56 | |
| 57 | #ifdef __cplusplus |
| 58 | } |
| 59 | #endif |
Adam Barth | 57eacf5 | 2020-11-04 00:38:09 +0000 | [diff] [blame^] | 60 | |
| 61 | #endif // SYSROOT_LINK_H_ |