sanitizer_freebsd.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //===-- sanitizer_freebsd.h -------------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file is a part of Sanitizer runtime. It contains FreeBSD-specific
  10. // definitions.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef SANITIZER_FREEBSD_H
  14. #define SANITIZER_FREEBSD_H
  15. #include "sanitizer_internal_defs.h"
  16. // x86-64 FreeBSD 9.2 and older define 'ucontext_t' incorrectly in
  17. // 32-bit mode.
  18. #if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
  19. #include <osreldate.h>
  20. #if __FreeBSD_version <= 902001 // v9.2
  21. #include <link.h>
  22. #include <sys/param.h>
  23. #include <ucontext.h>
  24. namespace __sanitizer {
  25. typedef unsigned long long __xuint64_t;
  26. typedef __int32_t __xregister_t;
  27. typedef struct __xmcontext {
  28. __xregister_t mc_onstack;
  29. __xregister_t mc_gs;
  30. __xregister_t mc_fs;
  31. __xregister_t mc_es;
  32. __xregister_t mc_ds;
  33. __xregister_t mc_edi;
  34. __xregister_t mc_esi;
  35. __xregister_t mc_ebp;
  36. __xregister_t mc_isp;
  37. __xregister_t mc_ebx;
  38. __xregister_t mc_edx;
  39. __xregister_t mc_ecx;
  40. __xregister_t mc_eax;
  41. __xregister_t mc_trapno;
  42. __xregister_t mc_err;
  43. __xregister_t mc_eip;
  44. __xregister_t mc_cs;
  45. __xregister_t mc_eflags;
  46. __xregister_t mc_esp;
  47. __xregister_t mc_ss;
  48. int mc_len;
  49. int mc_fpformat;
  50. int mc_ownedfp;
  51. __xregister_t mc_flags;
  52. int mc_fpstate[128] __aligned(16);
  53. __xregister_t mc_fsbase;
  54. __xregister_t mc_gsbase;
  55. __xregister_t mc_xfpustate;
  56. __xregister_t mc_xfpustate_len;
  57. int mc_spare2[4];
  58. } xmcontext_t;
  59. typedef struct __xucontext {
  60. sigset_t uc_sigmask;
  61. xmcontext_t uc_mcontext;
  62. struct __ucontext *uc_link;
  63. stack_t uc_stack;
  64. int uc_flags;
  65. int __spare__[4];
  66. } xucontext_t;
  67. struct xkinfo_vmentry {
  68. int kve_structsize;
  69. int kve_type;
  70. __xuint64_t kve_start;
  71. __xuint64_t kve_end;
  72. __xuint64_t kve_offset;
  73. __xuint64_t kve_vn_fileid;
  74. __uint32_t kve_vn_fsid;
  75. int kve_flags;
  76. int kve_resident;
  77. int kve_private_resident;
  78. int kve_protection;
  79. int kve_ref_count;
  80. int kve_shadow_count;
  81. int kve_vn_type;
  82. __xuint64_t kve_vn_size;
  83. __uint32_t kve_vn_rdev;
  84. __uint16_t kve_vn_mode;
  85. __uint16_t kve_status;
  86. int _kve_ispare[12];
  87. char kve_path[PATH_MAX];
  88. };
  89. typedef struct {
  90. __uint32_t p_type;
  91. __uint32_t p_offset;
  92. __uint32_t p_vaddr;
  93. __uint32_t p_paddr;
  94. __uint32_t p_filesz;
  95. __uint32_t p_memsz;
  96. __uint32_t p_flags;
  97. __uint32_t p_align;
  98. } XElf32_Phdr;
  99. struct xdl_phdr_info {
  100. Elf_Addr dlpi_addr;
  101. const char *dlpi_name;
  102. const XElf32_Phdr *dlpi_phdr;
  103. Elf_Half dlpi_phnum;
  104. unsigned long long int dlpi_adds;
  105. unsigned long long int dlpi_subs;
  106. size_t dlpi_tls_modid;
  107. void *dlpi_tls_data;
  108. };
  109. typedef int (*__xdl_iterate_hdr_callback)(struct xdl_phdr_info *, size_t,
  110. void *);
  111. typedef int xdl_iterate_phdr_t(__xdl_iterate_hdr_callback, void *);
  112. #define xdl_iterate_phdr(callback, param) \
  113. (((xdl_iterate_phdr_t *)dl_iterate_phdr)((callback), (param)))
  114. } // namespace __sanitizer
  115. #endif // __FreeBSD_version <= 902001
  116. #endif // SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
  117. #endif // SANITIZER_FREEBSD_H