]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - tools/objtool/arch.h
UBUNTU: Ubuntu-4.13.0-43.48
[mirror_ubuntu-artful-kernel.git] / tools / objtool / arch.h
1 /*
2 * 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 */
17
18 #ifndef _ARCH_H
19 #define _ARCH_H
20
21 #include <stdbool.h>
22 #include <linux/list.h>
23 #include "elf.h"
24 #include "cfi.h"
25
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_NOP 9
35 #define INSN_OTHER 10
36 #define INSN_LAST INSN_OTHER
37
38 enum op_dest_type {
39 OP_DEST_REG,
40 OP_DEST_REG_INDIRECT,
41 OP_DEST_MEM,
42 OP_DEST_PUSH,
43 OP_DEST_LEAVE,
44 };
45
46 struct op_dest {
47 enum op_dest_type type;
48 unsigned char reg;
49 int offset;
50 };
51
52 enum op_src_type {
53 OP_SRC_REG,
54 OP_SRC_REG_INDIRECT,
55 OP_SRC_CONST,
56 OP_SRC_POP,
57 OP_SRC_ADD,
58 OP_SRC_AND,
59 };
60
61 struct op_src {
62 enum op_src_type type;
63 unsigned char reg;
64 int offset;
65 };
66
67 struct stack_op {
68 struct op_dest dest;
69 struct op_src src;
70 };
71
72 void arch_initial_func_cfi_state(struct cfi_state *state);
73
74 int arch_decode_instruction(struct elf *elf, struct section *sec,
75 unsigned long offset, unsigned int maxlen,
76 unsigned int *len, unsigned char *type,
77 unsigned long *immediate, struct stack_op *op);
78
79 bool arch_callee_saved_reg(unsigned char reg);
80
81 #endif /* _ARCH_H */