blob: d8b8085e5dacb002f1db704ab4c20a359da7cc8a [file] [log] [blame]
Andrey Ryabininc6d30852016-01-20 15:00:55 -08001#ifndef _LIB_UBSAN_H
2#define _LIB_UBSAN_H
3
4enum {
5 type_kind_int = 0,
6 type_kind_float = 1,
7 type_unknown = 0xffff
8};
9
10struct type_descriptor {
11 u16 type_kind;
12 u16 type_info;
13 char type_name[1];
14};
15
16struct source_location {
17 const char *file_name;
18 union {
19 unsigned long reported;
20 struct {
21 u32 line;
22 u32 column;
23 };
24 };
25};
26
27struct overflow_data {
28 struct source_location location;
29 struct type_descriptor *type;
30};
31
32struct type_mismatch_data {
33 struct source_location location;
34 struct type_descriptor *type;
35 unsigned long alignment;
36 unsigned char type_check_kind;
37};
38
Andrey Ryabinin3c83fe52018-02-06 15:40:42 -080039struct type_mismatch_data_v1 {
40 struct source_location location;
41 struct type_descriptor *type;
42 unsigned char log_alignment;
43 unsigned char type_check_kind;
44};
45
46struct type_mismatch_data_common {
47 struct source_location *location;
48 struct type_descriptor *type;
49 unsigned long alignment;
50 unsigned char type_check_kind;
51};
52
Andrey Ryabininc6d30852016-01-20 15:00:55 -080053struct nonnull_arg_data {
54 struct source_location location;
55 struct source_location attr_location;
56 int arg_index;
57};
58
59struct nonnull_return_data {
60 struct source_location location;
61 struct source_location attr_location;
62};
63
64struct vla_bound_data {
65 struct source_location location;
66 struct type_descriptor *type;
67};
68
69struct out_of_bounds_data {
70 struct source_location location;
71 struct type_descriptor *array_type;
72 struct type_descriptor *index_type;
73};
74
75struct shift_out_of_bounds_data {
76 struct source_location location;
77 struct type_descriptor *lhs_type;
78 struct type_descriptor *rhs_type;
79};
80
81struct unreachable_data {
82 struct source_location location;
83};
84
85struct invalid_value_data {
86 struct source_location location;
87 struct type_descriptor *type;
88};
89
90#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
91typedef __int128 s_max;
92typedef unsigned __int128 u_max;
93#else
94typedef s64 s_max;
95typedef u64 u_max;
96#endif
97
98#endif