arch.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
  4. */
  5. #ifndef _ARCH_H
  6. #define _ARCH_H
  7. #include <stdbool.h>
  8. #include <linux/list.h>
  9. #include "objtool.h"
  10. #include "cfi.h"
  11. #ifdef INSN_USE_ORC
  12. #include <asm/orc_types.h>
  13. #endif
  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_OTHER,
  30. };
  31. enum op_dest_type {
  32. OP_DEST_REG,
  33. OP_DEST_REG_INDIRECT,
  34. OP_DEST_MEM,
  35. OP_DEST_PUSH,
  36. OP_DEST_PUSHF,
  37. OP_DEST_LEAVE,
  38. };
  39. struct op_dest {
  40. enum op_dest_type type;
  41. unsigned char reg;
  42. int offset;
  43. };
  44. enum op_src_type {
  45. OP_SRC_REG,
  46. OP_SRC_REG_INDIRECT,
  47. OP_SRC_CONST,
  48. OP_SRC_POP,
  49. OP_SRC_POPF,
  50. OP_SRC_ADD,
  51. OP_SRC_AND,
  52. };
  53. struct op_src {
  54. enum op_src_type type;
  55. unsigned char reg;
  56. int offset;
  57. };
  58. struct stack_op {
  59. struct op_dest dest;
  60. struct op_src src;
  61. struct list_head list;
  62. };
  63. struct instruction;
  64. void arch_initial_func_cfi_state(struct cfi_init_state *state);
  65. int arch_decode_instruction(const struct elf *elf, const struct section *sec,
  66. unsigned long offset, unsigned int maxlen,
  67. unsigned int *len, enum insn_type *type,
  68. unsigned long *immediate,
  69. struct list_head *ops_list);
  70. bool arch_callee_saved_reg(unsigned char reg);
  71. unsigned long arch_jump_destination(struct instruction *insn);
  72. unsigned long arch_dest_reloc_offset(int addend);
  73. const char *arch_nop_insn(int len);
  74. int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg);
  75. #endif /* _ARCH_H */