.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2015 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/>. |
---|
16 | 4 | */ |
---|
17 | 5 | |
---|
18 | 6 | #ifndef _ARCH_H |
---|
.. | .. |
---|
20 | 8 | |
---|
21 | 9 | #include <stdbool.h> |
---|
22 | 10 | #include <linux/list.h> |
---|
23 | | -#include "elf.h" |
---|
| 11 | +#include "objtool.h" |
---|
24 | 12 | #include "cfi.h" |
---|
25 | 13 | |
---|
26 | | -#define INSN_JUMP_CONDITIONAL 1 |
---|
27 | | -#define INSN_JUMP_UNCONDITIONAL 2 |
---|
28 | | -#define INSN_JUMP_DYNAMIC 3 |
---|
29 | | -#define INSN_CALL 4 |
---|
30 | | -#define INSN_CALL_DYNAMIC 5 |
---|
31 | | -#define INSN_RETURN 6 |
---|
32 | | -#define INSN_CONTEXT_SWITCH 7 |
---|
33 | | -#define INSN_STACK 8 |
---|
34 | | -#define INSN_BUG 9 |
---|
35 | | -#define INSN_NOP 10 |
---|
36 | | -#define INSN_OTHER 11 |
---|
37 | | -#define INSN_LAST INSN_OTHER |
---|
| 14 | +enum insn_type { |
---|
| 15 | + INSN_JUMP_CONDITIONAL, |
---|
| 16 | + INSN_JUMP_UNCONDITIONAL, |
---|
| 17 | + INSN_JUMP_DYNAMIC, |
---|
| 18 | + INSN_JUMP_DYNAMIC_CONDITIONAL, |
---|
| 19 | + INSN_CALL, |
---|
| 20 | + INSN_CALL_DYNAMIC, |
---|
| 21 | + INSN_RETURN, |
---|
| 22 | + INSN_CONTEXT_SWITCH, |
---|
| 23 | + INSN_BUG, |
---|
| 24 | + INSN_NOP, |
---|
| 25 | + INSN_STAC, |
---|
| 26 | + INSN_CLAC, |
---|
| 27 | + INSN_STD, |
---|
| 28 | + INSN_CLD, |
---|
| 29 | + INSN_TRAP, |
---|
| 30 | + INSN_OTHER, |
---|
| 31 | +}; |
---|
38 | 32 | |
---|
39 | 33 | enum op_dest_type { |
---|
40 | 34 | OP_DEST_REG, |
---|
41 | 35 | OP_DEST_REG_INDIRECT, |
---|
42 | 36 | OP_DEST_MEM, |
---|
43 | 37 | OP_DEST_PUSH, |
---|
| 38 | + OP_DEST_PUSHF, |
---|
44 | 39 | OP_DEST_LEAVE, |
---|
45 | 40 | }; |
---|
46 | 41 | |
---|
.. | .. |
---|
55 | 50 | OP_SRC_REG_INDIRECT, |
---|
56 | 51 | OP_SRC_CONST, |
---|
57 | 52 | OP_SRC_POP, |
---|
| 53 | + OP_SRC_POPF, |
---|
58 | 54 | OP_SRC_ADD, |
---|
59 | 55 | OP_SRC_AND, |
---|
60 | 56 | }; |
---|
.. | .. |
---|
68 | 64 | struct stack_op { |
---|
69 | 65 | struct op_dest dest; |
---|
70 | 66 | struct op_src src; |
---|
| 67 | + struct list_head list; |
---|
71 | 68 | }; |
---|
72 | 69 | |
---|
73 | | -void arch_initial_func_cfi_state(struct cfi_state *state); |
---|
| 70 | +struct instruction; |
---|
74 | 71 | |
---|
75 | | -int arch_decode_instruction(struct elf *elf, struct section *sec, |
---|
| 72 | +void arch_initial_func_cfi_state(struct cfi_init_state *state); |
---|
| 73 | + |
---|
| 74 | +int arch_decode_instruction(const struct elf *elf, const struct section *sec, |
---|
76 | 75 | unsigned long offset, unsigned int maxlen, |
---|
77 | | - unsigned int *len, unsigned char *type, |
---|
78 | | - unsigned long *immediate, struct stack_op *op); |
---|
| 76 | + unsigned int *len, enum insn_type *type, |
---|
| 77 | + unsigned long *immediate, |
---|
| 78 | + struct list_head *ops_list); |
---|
79 | 79 | |
---|
80 | 80 | bool arch_callee_saved_reg(unsigned char reg); |
---|
81 | 81 | |
---|
| 82 | +unsigned long arch_jump_destination(struct instruction *insn); |
---|
| 83 | + |
---|
| 84 | +unsigned long arch_dest_reloc_offset(int addend); |
---|
| 85 | + |
---|
| 86 | +const char *arch_nop_insn(int len); |
---|
| 87 | +const char *arch_ret_insn(int len); |
---|
| 88 | + |
---|
| 89 | +int arch_decode_hint_reg(u8 sp_reg, int *base); |
---|
| 90 | + |
---|
| 91 | +bool arch_is_retpoline(struct symbol *sym); |
---|
| 92 | +bool arch_is_rethunk(struct symbol *sym); |
---|
| 93 | +bool arch_is_embedded_insn(struct symbol *sym); |
---|
| 94 | + |
---|
| 95 | +int arch_rewrite_retpolines(struct objtool_file *file); |
---|
| 96 | + |
---|
82 | 97 | #endif /* _ARCH_H */ |
---|