Commit | Line | Data |
---|---|---|
1ccea77e | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
dcc914f4 JP |
2 | /* |
3 | * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com> | |
dcc914f4 JP |
4 | */ |
5 | ||
6 | #ifndef _CHECK_H | |
7 | #define _CHECK_H | |
8 | ||
9 | #include <stdbool.h> | |
10 | #include "elf.h" | |
baa41469 | 11 | #include "cfi.h" |
dcc914f4 | 12 | #include "arch.h" |
627fce14 | 13 | #include "orc.h" |
dcc914f4 JP |
14 | #include <linux/hashtable.h> |
15 | ||
baa41469 JP |
16 | struct insn_state { |
17 | struct cfi_reg cfa; | |
18 | struct cfi_reg regs[CFI_NUM_REGS]; | |
19 | int stack_size; | |
627fce14 | 20 | unsigned char type; |
baa41469 | 21 | bool bp_scratch; |
2f0f9e9a | 22 | bool drap, end, uaccess, df; |
ea24213d | 23 | unsigned int uaccess_stack; |
bf4d1a83 | 24 | int drap_reg, drap_offset; |
dd88a0a0 | 25 | struct cfi_reg vals[CFI_NUM_REGS]; |
baa41469 JP |
26 | }; |
27 | ||
dcc914f4 JP |
28 | struct instruction { |
29 | struct list_head list; | |
30 | struct hlist_node hash; | |
31 | struct section *sec; | |
32 | unsigned long offset; | |
baa41469 | 33 | unsigned int len; |
9fe7b764 | 34 | enum insn_type type; |
dcc914f4 | 35 | unsigned long immediate; |
882a0db9 | 36 | bool alt_group, dead_end, ignore, hint, save, restore, ignore_alts; |
b5bc2231 | 37 | bool retpoline_safe; |
882a0db9 | 38 | u8 visited; |
dcc914f4 JP |
39 | struct symbol *call_dest; |
40 | struct instruction *jump_dest; | |
99ce7962 | 41 | struct instruction *first_jump_src; |
bd98c813 | 42 | struct rela *jump_table; |
dcc914f4 JP |
43 | struct list_head alts; |
44 | struct symbol *func; | |
baa41469 JP |
45 | struct stack_op stack_op; |
46 | struct insn_state state; | |
627fce14 | 47 | struct orc_entry orc; |
dcc914f4 JP |
48 | }; |
49 | ||
50 | struct objtool_file { | |
51 | struct elf *elf; | |
52 | struct list_head insn_list; | |
513b5ca6 | 53 | DECLARE_HASHTABLE(insn_hash, 20); |
4a60aa05 | 54 | bool ignore_unreachables, c_file, hints, rodata; |
dcc914f4 JP |
55 | }; |
56 | ||
43a4525f | 57 | int check(const char *objname, bool orc); |
627fce14 JP |
58 | |
59 | struct instruction *find_insn(struct objtool_file *file, | |
60 | struct section *sec, unsigned long offset); | |
dcc914f4 | 61 | |
baa41469 JP |
62 | #define for_each_insn(file, insn) \ |
63 | list_for_each_entry(insn, &file->insn_list, list) | |
64 | ||
627fce14 JP |
65 | #define sec_for_each_insn(file, sec, insn) \ |
66 | for (insn = find_insn(file, sec, 0); \ | |
67 | insn && &insn->list != &file->insn_list && \ | |
68 | insn->sec == sec; \ | |
69 | insn = list_next_entry(insn, list)) | |
70 | ||
71 | ||
dcc914f4 | 72 | #endif /* _CHECK_H */ |