trap.s 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # 1 "trap.S"
  2. # 1 "<built-in>"
  3. # 1 "<command-line>"
  4. # 31 "<command-line>"
  5. # 1 "/usr/include/stdc-predef.h" 1 3 4
  6. # 32 "<command-line>" 2
  7. # 1 "trap.S"
  8. # 59 "trap.S"
  9. restore_all:
  10. popq %rax
  11. movq %rax, %ss
  12. popq %rax
  13. movq %rax, %gs
  14. popq %rax
  15. movq %rax, %fs
  16. popq %rax
  17. movq %rax, %es
  18. popq %rax
  19. movq %rax, %ds
  20. popq %r15
  21. popq %r14
  22. popq %r13
  23. popq %r12
  24. popq %r11
  25. popq %r10
  26. popq %r9
  27. popq %r8
  28. popq %rdi
  29. popq %rsi
  30. popq %rbp
  31. popq %rsp
  32. popq %rbx
  33. popq %rdx
  34. popq %rcx
  35. popq %rax
  36. addq $0x10, %rsp
  37. iretq
  38. .globl __stack_chk_fail
  39. __stack_chk_fail:
  40. movq schkfail_msg(%rip), %rdi
  41. scf_die:
  42. hlt
  43. jmp scf_die
  44. .globl divide_error
  45. divide_error:
  46. cli
  47. pushq $0
  48. pushq %rax
  49. pushq %rax; pushq %rcx; pushq %rdx; pushq %rbx; pushq %rsp; pushq %rbp; pushq %rsi; pushq %rdi; pushq %r8; pushq %r9; pushq %r10; pushq %r11; pushq %r12; pushq %r13; pushq %r14; pushq %r15; movq %ds, %rax; pushq %rax; movq %es, %rax; pushq %rax; movq %fs, %rax; pushq %rax; movq %gs, %rax; pushq %rax; movq %ss, %rax; pushq %rax;
  50. movq %rsp, %rdi
  51. leaq do_divide_error(%rip), %rcx
  52. callq *%rcx
  53. sti
  54. jmp restore_all
  55. .section .rodata
  56. schkfail_msg:
  57. .asciz "kernel panic: stack check fail. \n"