link.h 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef _LINK_H
  2. #define _LINK_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <elf.h>
  7. #define __NEED_size_t
  8. #define __NEED_uint32_t
  9. #include <bits/alltypes.h>
  10. #if UINTPTR_MAX > 0xffffffff
  11. #define ElfW(type) Elf64_ ## type
  12. #else
  13. #define ElfW(type) Elf32_ ## type
  14. #endif
  15. /* this is the same everywhere except alpha and s390 */
  16. typedef uint32_t Elf_Symndx;
  17. struct dl_phdr_info {
  18. ElfW(Addr) dlpi_addr;
  19. const char *dlpi_name;
  20. const ElfW(Phdr) *dlpi_phdr;
  21. ElfW(Half) dlpi_phnum;
  22. unsigned long long int dlpi_adds;
  23. unsigned long long int dlpi_subs;
  24. size_t dlpi_tls_modid;
  25. void *dlpi_tls_data;
  26. };
  27. struct link_map {
  28. ElfW(Addr) l_addr;
  29. char *l_name;
  30. ElfW(Dyn) *l_ld;
  31. struct link_map *l_next, *l_prev;
  32. };
  33. struct r_debug {
  34. int r_version;
  35. struct link_map *r_map;
  36. ElfW(Addr) r_brk;
  37. enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
  38. ElfW(Addr) r_ldbase;
  39. };
  40. int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif