objtool: Fix seg fault on bad switch table entry
[linux-block.git] / tools / objtool / arch.h
CommitLineData
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>
442f04c3 11#include "elf.h"
baa41469 12#include "cfi.h"
442f04c3 13
baa41469
JP
14#define INSN_JUMP_CONDITIONAL 1
15#define INSN_JUMP_UNCONDITIONAL 2
16#define INSN_JUMP_DYNAMIC 3
17#define INSN_CALL 4
18#define INSN_CALL_DYNAMIC 5
19#define INSN_RETURN 6
20#define INSN_CONTEXT_SWITCH 7
21#define INSN_STACK 8
649ea4d5
JP
22#define INSN_BUG 9
23#define INSN_NOP 10
ea24213d
PZ
24#define INSN_STAC 11
25#define INSN_CLAC 12
2f0f9e9a
PZ
26#define INSN_STD 13
27#define INSN_CLD 14
28#define INSN_OTHER 15
442f04c3
JP
29#define INSN_LAST INSN_OTHER
30
baa41469
JP
31enum op_dest_type {
32 OP_DEST_REG,
33 OP_DEST_REG_INDIRECT,
34 OP_DEST_MEM,
35 OP_DEST_PUSH,
ea24213d 36 OP_DEST_PUSHF,
baa41469
JP
37 OP_DEST_LEAVE,
38};
39
40struct op_dest {
41 enum op_dest_type type;
42 unsigned char reg;
43 int offset;
44};
45
46enum op_src_type {
47 OP_SRC_REG,
48 OP_SRC_REG_INDIRECT,
49 OP_SRC_CONST,
50 OP_SRC_POP,
ea24213d 51 OP_SRC_POPF,
baa41469
JP
52 OP_SRC_ADD,
53 OP_SRC_AND,
54};
55
56struct op_src {
57 enum op_src_type type;
58 unsigned char reg;
59 int offset;
60};
61
62struct stack_op {
63 struct op_dest dest;
64 struct op_src src;
65};
66
67void arch_initial_func_cfi_state(struct cfi_state *state);
68
442f04c3
JP
69int arch_decode_instruction(struct elf *elf, struct section *sec,
70 unsigned long offset, unsigned int maxlen,
71 unsigned int *len, unsigned char *type,
baa41469
JP
72 unsigned long *immediate, struct stack_op *op);
73
74bool arch_callee_saved_reg(unsigned char reg);
442f04c3
JP
75
76#endif /* _ARCH_H */