1 //===-- sanitizer_freebsd.h -------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of Sanitizer runtime. It contains FreeBSD-specific
12 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_FREEBSD_H
15 #define SANITIZER_FREEBSD_H
17 #include "sanitizer_internal_defs.h"
19 // x86-64 FreeBSD 9.2 and older define 'ucontext_t' incorrectly in
21 #if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
22 # include <osreldate.h>
23 # if __FreeBSD_version <= 902001 // v9.2
25 # include <sys/param.h>
26 # include <ucontext.h>
28 namespace __sanitizer {
30 typedef unsigned long long __xuint64_t;
32 typedef __int32_t __xregister_t;
34 typedef struct __xmcontext {
35 __xregister_t mc_onstack;
48 __xregister_t mc_trapno;
52 __xregister_t mc_eflags;
59 __xregister_t mc_flags;
61 int mc_fpstate[128] __aligned(16);
62 __xregister_t mc_fsbase;
63 __xregister_t mc_gsbase;
64 __xregister_t mc_xfpustate;
65 __xregister_t mc_xfpustate_len;
70 typedef struct __xucontext {
72 xmcontext_t uc_mcontext;
74 struct __ucontext *uc_link;
80 struct xkinfo_vmentry {
83 __xuint64_t kve_start;
85 __xuint64_t kve_offset;
86 __xuint64_t kve_vn_fileid;
87 __uint32_t kve_vn_fsid;
90 int kve_private_resident;
95 __xuint64_t kve_vn_size;
96 __uint32_t kve_vn_rdev;
97 __uint16_t kve_vn_mode;
98 __uint16_t kve_status;
100 char kve_path[PATH_MAX];
114 struct xdl_phdr_info {
116 const char *dlpi_name;
117 const XElf32_Phdr *dlpi_phdr;
119 unsigned long long int dlpi_adds;
120 unsigned long long int dlpi_subs;
121 size_t dlpi_tls_modid;
125 typedef int (*__xdl_iterate_hdr_callback)(struct xdl_phdr_info*, size_t, void*);
126 typedef int xdl_iterate_phdr_t(__xdl_iterate_hdr_callback, void*);
128 #define xdl_iterate_phdr(callback, param) \
129 (((xdl_iterate_phdr_t*) dl_iterate_phdr)((callback), (param)))
131 } // namespace __sanitizer
133 # endif // __FreeBSD_version <= 902001
134 #endif // SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
136 #endif // SANITIZER_FREEBSD_H