check.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2017 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. #ifndef _CHECK_H
  18. #define _CHECK_H
  19. #include <stdbool.h>
  20. #include "elf.h"
  21. #include "cfi.h"
  22. #include "arch.h"
  23. #include <linux/hashtable.h>
  24. struct insn_state {
  25. struct cfi_reg cfa;
  26. struct cfi_reg regs[CFI_NUM_REGS];
  27. int stack_size;
  28. bool bp_scratch;
  29. bool drap;
  30. int drap_reg;
  31. };
  32. struct instruction {
  33. struct list_head list;
  34. struct hlist_node hash;
  35. struct section *sec;
  36. unsigned long offset;
  37. unsigned int len;
  38. unsigned char type;
  39. unsigned long immediate;
  40. bool alt_group, visited, dead_end, ignore;
  41. struct symbol *call_dest;
  42. struct instruction *jump_dest;
  43. struct list_head alts;
  44. struct symbol *func;
  45. struct stack_op stack_op;
  46. struct insn_state state;
  47. };
  48. struct objtool_file {
  49. struct elf *elf;
  50. struct list_head insn_list;
  51. DECLARE_HASHTABLE(insn_hash, 16);
  52. struct section *rodata, *whitelist;
  53. bool ignore_unreachables, c_file;
  54. };
  55. int check(const char *objname, bool nofp);
  56. #define for_each_insn(file, insn) \
  57. list_for_each_entry(insn, &file->insn_list, list)
  58. #endif /* _CHECK_H */