]>
Commit | Line | Data |
---|---|---|
1ccea77e | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
442f04c3 JP |
2 | /* |
3 | * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com> | |
442f04c3 JP |
4 | */ |
5 | ||
6 | #ifndef _ARCH_H | |
7 | #define _ARCH_H | |
8 | ||
9 | #include <stdbool.h> | |
baa41469 | 10 | #include <linux/list.h> |
7786032e VG |
11 | #include <objtool/objtool.h> |
12 | #include <objtool/cfi.h> | |
442f04c3 | 13 | |
9fe7b764 JP |
14 | enum insn_type { |
15 | INSN_JUMP_CONDITIONAL, | |
16 | INSN_JUMP_UNCONDITIONAL, | |
17 | INSN_JUMP_DYNAMIC, | |
b68b9907 | 18 | INSN_JUMP_DYNAMIC_CONDITIONAL, |
9fe7b764 JP |
19 | INSN_CALL, |
20 | INSN_CALL_DYNAMIC, | |
21 | INSN_RETURN, | |
22 | INSN_CONTEXT_SWITCH, | |
9fe7b764 JP |
23 | INSN_BUG, |
24 | INSN_NOP, | |
25 | INSN_STAC, | |
26 | INSN_CLAC, | |
27 | INSN_STD, | |
28 | INSN_CLD, | |
29 | INSN_OTHER, | |
30 | }; | |
442f04c3 | 31 | |
baa41469 JP |
32 | enum op_dest_type { |
33 | OP_DEST_REG, | |
34 | OP_DEST_REG_INDIRECT, | |
35 | OP_DEST_MEM, | |
36 | OP_DEST_PUSH, | |
ea24213d | 37 | OP_DEST_PUSHF, |
baa41469 JP |
38 | OP_DEST_LEAVE, |
39 | }; | |
40 | ||
41 | struct op_dest { | |
42 | enum op_dest_type type; | |
43 | unsigned char reg; | |
44 | int offset; | |
45 | }; | |
46 | ||
47 | enum op_src_type { | |
48 | OP_SRC_REG, | |
49 | OP_SRC_REG_INDIRECT, | |
50 | OP_SRC_CONST, | |
51 | OP_SRC_POP, | |
ea24213d | 52 | OP_SRC_POPF, |
baa41469 JP |
53 | OP_SRC_ADD, |
54 | OP_SRC_AND, | |
55 | }; | |
56 | ||
57 | struct op_src { | |
58 | enum op_src_type type; | |
59 | unsigned char reg; | |
60 | int offset; | |
61 | }; | |
62 | ||
63 | struct stack_op { | |
64 | struct op_dest dest; | |
65 | struct op_src src; | |
65ea47dc | 66 | struct list_head list; |
baa41469 JP |
67 | }; |
68 | ||
bfb08f22 RG |
69 | struct instruction; |
70 | ||
a3608f59 | 71 | void arch_initial_func_cfi_state(struct cfi_init_state *state); |
baa41469 | 72 | |
0c98be81 | 73 | int arch_decode_instruction(const struct elf *elf, const struct section *sec, |
442f04c3 | 74 | unsigned long offset, unsigned int maxlen, |
9fe7b764 | 75 | unsigned int *len, enum insn_type *type, |
65ea47dc JT |
76 | unsigned long *immediate, |
77 | struct list_head *ops_list); | |
baa41469 JP |
78 | |
79 | bool arch_callee_saved_reg(unsigned char reg); | |
442f04c3 | 80 | |
bfb08f22 RG |
81 | unsigned long arch_jump_destination(struct instruction *insn); |
82 | ||
f1974222 | 83 | unsigned long arch_dest_reloc_offset(int addend); |
bfb08f22 | 84 | |
0f1441b4 PZ |
85 | const char *arch_nop_insn(int len); |
86 | ||
edea9e6b JT |
87 | int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg); |
88 | ||
442f04c3 | 89 | #endif /* _ARCH_H */ |