annotate libsanitizer/sanitizer_common/sanitizer_freebsd.h @ 158:494b0b89df80 default tip

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