]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - tools/objtool/include/objtool/check.h
objtool: Refactor ORC section generation
[mirror_ubuntu-jammy-kernel.git] / tools / objtool / include / objtool / check.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
4 */
5
6 #ifndef _CHECK_H
7 #define _CHECK_H
8
9 #include <stdbool.h>
10 #include <objtool/cfi.h>
11 #include <objtool/arch.h>
12
13 struct insn_state {
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 instruction {
23 struct list_head list;
24 struct hlist_node hash;
25 struct list_head static_call_node;
26 struct section *sec;
27 unsigned long offset;
28 unsigned int len;
29 enum insn_type type;
30 unsigned long immediate;
31 bool dead_end, ignore, ignore_alts;
32 bool hint;
33 bool retpoline_safe;
34 s8 instr;
35 u8 visited;
36 u8 ret_offset;
37 int alt_group;
38 struct symbol *call_dest;
39 struct instruction *jump_dest;
40 struct instruction *first_jump_src;
41 struct reloc *jump_table;
42 struct list_head alts;
43 struct symbol *func;
44 struct list_head stack_ops;
45 struct cfi_state cfi;
46 };
47
48 static inline bool is_static_jump(struct instruction *insn)
49 {
50 return insn->type == INSN_JUMP_CONDITIONAL ||
51 insn->type == INSN_JUMP_UNCONDITIONAL;
52 }
53
54 struct instruction *find_insn(struct objtool_file *file,
55 struct section *sec, unsigned long offset);
56
57 #define for_each_insn(file, insn) \
58 list_for_each_entry(insn, &file->insn_list, list)
59
60 #define sec_for_each_insn(file, sec, insn) \
61 for (insn = find_insn(file, sec, 0); \
62 insn && &insn->list != &file->insn_list && \
63 insn->sec == sec; \
64 insn = list_next_entry(insn, list))
65
66 #endif /* _CHECK_H */