Blame view

tools/objtool/check.h 1.55 KB
1ccea77e2   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
dcc914f44   Josh Poimboeuf   objtool: Move che...
2
3
  /*
   * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
dcc914f44   Josh Poimboeuf   objtool: Move che...
4
5
6
7
8
9
   */
  
  #ifndef _CHECK_H
  #define _CHECK_H
  
  #include <stdbool.h>
baa41469a   Josh Poimboeuf   objtool: Implemen...
10
  #include "cfi.h"
dcc914f44   Josh Poimboeuf   objtool: Move che...
11
  #include "arch.h"
dcc914f44   Josh Poimboeuf   objtool: Move che...
12

baa41469a   Josh Poimboeuf   objtool: Implemen...
13
  struct insn_state {
e7c0219b3   Peter Zijlstra   objtool: Fix !CFI...
14
  	struct cfi_state cfi;
ea24213d8   Peter Zijlstra   objtool: Add UACC...
15
  	unsigned int uaccess_stack;
e7c0219b3   Peter Zijlstra   objtool: Fix !CFI...
16
17
  	bool uaccess;
  	bool df;
c4a33939a   Peter Zijlstra   objtool: Implemen...
18
19
  	bool noinstr;
  	s8 instr;
baa41469a   Josh Poimboeuf   objtool: Implemen...
20
  };
dcc914f44   Josh Poimboeuf   objtool: Move che...
21
22
23
  struct instruction {
  	struct list_head list;
  	struct hlist_node hash;
1e7e47883   Josh Poimboeuf   x86/static_call: ...
24
  	struct list_head static_call_node;
7dcfcd46b   Peter Zijlstra   FROMLIST: objtool...
25
  	struct list_head mcount_loc_node;
dcc914f44   Josh Poimboeuf   objtool: Move che...
26
27
  	struct section *sec;
  	unsigned long offset;
baa41469a   Josh Poimboeuf   objtool: Implemen...
28
  	unsigned int len;
9fe7b7642   Josh Poimboeuf   objtool: Convert ...
29
  	enum insn_type type;
dcc914f44   Josh Poimboeuf   objtool: Move che...
30
  	unsigned long immediate;
13fab06d9   Alexandre Chartre   objtool: Uniquely...
31
  	bool dead_end, ignore, ignore_alts;
c536ed2ff   Peter Zijlstra   objtool: Remove S...
32
  	bool hint;
b5bc2231b   Peter Zijlstra   objtool: Add retp...
33
  	bool retpoline_safe;
c4a33939a   Peter Zijlstra   objtool: Implemen...
34
  	s8 instr;
882a0db9d   Peter Zijlstra   objtool: Improve ...
35
  	u8 visited;
e25eea89b   Peter Zijlstra   objtool: Introduc...
36
  	u8 ret_offset;
13fab06d9   Alexandre Chartre   objtool: Uniquely...
37
  	int alt_group;
dcc914f44   Josh Poimboeuf   objtool: Move che...
38
39
  	struct symbol *call_dest;
  	struct instruction *jump_dest;
99ce7962d   Peter Zijlstra   objtool: Fix swit...
40
  	struct instruction *first_jump_src;
f19742226   Matt Helsley   objtool: Rename r...
41
  	struct reloc *jump_table;
dcc914f44   Josh Poimboeuf   objtool: Move che...
42
43
  	struct list_head alts;
  	struct symbol *func;
65ea47dcf   Julien Thierry   objtool: Support ...
44
  	struct list_head stack_ops;
e7c0219b3   Peter Zijlstra   objtool: Fix !CFI...
45
  	struct cfi_state cfi;
66734e324   Julien Thierry   objtool: Define '...
46
  #ifdef INSN_USE_ORC
627fce148   Josh Poimboeuf   objtool: Add ORC ...
47
  	struct orc_entry orc;
66734e324   Julien Thierry   objtool: Define '...
48
  #endif
dcc914f44   Josh Poimboeuf   objtool: Move che...
49
  };
45245f51f   Julien Thierry   objtool: Make rel...
50
51
52
53
54
  static inline bool is_static_jump(struct instruction *insn)
  {
  	return insn->type == INSN_JUMP_CONDITIONAL ||
  	       insn->type == INSN_JUMP_UNCONDITIONAL;
  }
627fce148   Josh Poimboeuf   objtool: Add ORC ...
55
56
  struct instruction *find_insn(struct objtool_file *file,
  			      struct section *sec, unsigned long offset);
dcc914f44   Josh Poimboeuf   objtool: Move che...
57

baa41469a   Josh Poimboeuf   objtool: Implemen...
58
59
  #define for_each_insn(file, insn)					\
  	list_for_each_entry(insn, &file->insn_list, list)
627fce148   Josh Poimboeuf   objtool: Add ORC ...
60
61
62
63
64
  #define sec_for_each_insn(file, sec, insn)				\
  	for (insn = find_insn(file, sec, 0);				\
  	     insn && &insn->list != &file->insn_list &&			\
  			insn->sec == sec;				\
  	     insn = list_next_entry(insn, list))
dcc914f44   Josh Poimboeuf   objtool: Move che...
65
  #endif /* _CHECK_H */