hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/tools/objtool/check.h
....@@ -1,70 +1,91 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * as published by the Free Software Foundation; either version 2
7
- * of the License, or (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
164 */
175
186 #ifndef _CHECK_H
197 #define _CHECK_H
208
219 #include <stdbool.h>
22
-#include "elf.h"
2310 #include "cfi.h"
2411 #include "arch.h"
25
-#include "orc.h"
26
-#include <linux/hashtable.h>
2712
2813 struct insn_state {
29
- struct cfi_reg cfa;
30
- struct cfi_reg regs[CFI_NUM_REGS];
31
- int stack_size;
32
- unsigned char type;
33
- bool bp_scratch;
34
- bool drap, end;
35
- int drap_reg, drap_offset;
36
- struct cfi_reg vals[CFI_NUM_REGS];
14
+ struct cfi_state cfi;
15
+ unsigned int uaccess_stack;
16
+ bool uaccess;
17
+ bool df;
18
+ bool noinstr;
19
+ s8 instr;
20
+};
21
+
22
+struct alt_group {
23
+ /*
24
+ * Pointer from a replacement group to the original group. NULL if it
25
+ * *is* the original group.
26
+ */
27
+ struct alt_group *orig_group;
28
+
29
+ /* First and last instructions in the group */
30
+ struct instruction *first_insn, *last_insn;
31
+
32
+ /*
33
+ * Byte-offset-addressed len-sized array of pointers to CFI structs.
34
+ * This is shared with the other alt_groups in the same alternative.
35
+ */
36
+ struct cfi_state **cfi;
3737 };
3838
3939 struct instruction {
4040 struct list_head list;
4141 struct hlist_node hash;
42
+ struct list_head mcount_loc_node;
43
+ struct list_head call_node;
4244 struct section *sec;
4345 unsigned long offset;
4446 unsigned int len;
45
- unsigned char type;
47
+ enum insn_type type;
4648 unsigned long immediate;
47
- bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts;
49
+ bool dead_end, ignore, ignore_alts;
50
+ bool hint;
51
+ bool save, restore;
4852 bool retpoline_safe;
53
+ bool entry;
54
+ s8 instr;
55
+ u8 visited;
56
+ struct alt_group *alt_group;
4957 struct symbol *call_dest;
5058 struct instruction *jump_dest;
5159 struct instruction *first_jump_src;
60
+ struct reloc *jump_table;
61
+ struct reloc *reloc;
5262 struct list_head alts;
5363 struct symbol *func;
54
- struct stack_op stack_op;
55
- struct insn_state state;
56
- struct orc_entry orc;
64
+ struct list_head stack_ops;
65
+ struct cfi_state *cfi;
5766 };
5867
59
-struct objtool_file {
60
- struct elf *elf;
61
- struct list_head insn_list;
62
- DECLARE_HASHTABLE(insn_hash, 16);
63
- struct section *whitelist;
64
- bool ignore_unreachables, c_file, hints, rodata;
65
-};
68
+#define VISITED_BRANCH 0x01
69
+#define VISITED_BRANCH_UACCESS 0x02
70
+#define VISITED_BRANCH_MASK 0x03
71
+#define VISITED_ENTRY 0x04
6672
67
-int check(const char *objname, bool orc);
73
+static inline bool is_static_jump(struct instruction *insn)
74
+{
75
+ return insn->type == INSN_JUMP_CONDITIONAL ||
76
+ insn->type == INSN_JUMP_UNCONDITIONAL;
77
+}
78
+
79
+static inline bool is_dynamic_jump(struct instruction *insn)
80
+{
81
+ return insn->type == INSN_JUMP_DYNAMIC ||
82
+ insn->type == INSN_JUMP_DYNAMIC_CONDITIONAL;
83
+}
84
+
85
+static inline bool is_jump(struct instruction *insn)
86
+{
87
+ return is_static_jump(insn) || is_dynamic_jump(insn);
88
+}
6889
6990 struct instruction *find_insn(struct objtool_file *file,
7091 struct section *sec, unsigned long offset);
....@@ -77,6 +98,5 @@
7798 insn && &insn->list != &file->insn_list && \
7899 insn->sec == sec; \
79100 insn = list_next_entry(insn, list))
80
-
81101
82102 #endif /* _CHECK_H */