arch.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "elf.h"
  10. #include "cfi.h"
  11. enum insn_type {
  12. INSN_JUMP_CONDITIONAL,
  13. INSN_JUMP_UNCONDITIONAL,
  14. INSN_JUMP_DYNAMIC,
  15. INSN_JUMP_DYNAMIC_CONDITIONAL,
  16. INSN_CALL,
  17. INSN_CALL_DYNAMIC,
  18. INSN_RETURN,
  19. INSN_CONTEXT_SWITCH,
  20. INSN_STACK,
  21. INSN_BUG,
  22. INSN_NOP,
  23. INSN_STAC,
  24. INSN_CLAC,
  25. INSN_STD,
  26. INSN_CLD,
  27. INSN_OTHER,
  28. };
  29. enum op_dest_type {
  30. OP_DEST_REG,
  31. OP_DEST_REG_INDIRECT,
  32. OP_DEST_MEM,
  33. OP_DEST_PUSH,
  34. OP_DEST_PUSHF,
  35. OP_DEST_LEAVE,
  36. };
  37. struct op_dest {
  38. enum op_dest_type type;
  39. unsigned char reg;
  40. int offset;
  41. };
  42. enum op_src_type {
  43. OP_SRC_REG,
  44. OP_SRC_REG_INDIRECT,
  45. OP_SRC_CONST,
  46. OP_SRC_POP,
  47. OP_SRC_POPF,
  48. OP_SRC_ADD,
  49. OP_SRC_AND,
  50. };
  51. struct op_src {
  52. enum op_src_type type;
  53. unsigned char reg;
  54. int offset;
  55. };
  56. struct stack_op {
  57. struct op_dest dest;
  58. struct op_src src;
  59. };
  60. void arch_initial_func_cfi_state(struct cfi_state *state);
  61. int arch_decode_instruction(struct elf *elf, struct section *sec,
  62. unsigned long offset, unsigned int maxlen,
  63. unsigned int *len, enum insn_type *type,
  64. unsigned long *immediate, struct stack_op *op);
  65. bool arch_callee_saved_reg(unsigned char reg);
  66. #endif /* _ARCH_H */