syscallas.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright (C) 2014 OSCAR lab, Stony Brook University
  2. This file is part of Graphene Library OS.
  3. Graphene Library OS is free software: you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. Graphene Library OS is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. * syscallas.S
  15. *
  16. * This file contains the entry point of system call table in library OS.
  17. */
  18. #include <shim_tls.h>
  19. .text
  20. .globl syscalldb
  21. .type syscalldb, @function
  22. .extern shim_table
  23. syscalldb:
  24. .cfi_startproc
  25. # avoid red zone for previous rsp
  26. subq $128, %rsp
  27. .cfi_def_cfa_offset 136
  28. # DEP 7/9/12: Push a stack pointer so clone can find the return address
  29. pushq %rbp
  30. .cfi_def_cfa_offset 144
  31. movq %rsp, %rbp
  32. .cfi_offset 6,-144
  33. .cfi_def_cfa_register 6
  34. pushq %rbx
  35. pushq %r12
  36. movq %rax, %fs:(SHIM_TCB_OFFSET + 24)
  37. movq %rsp, %rbx
  38. addq $152, %rbx
  39. movq %rbx, %fs:(SHIM_TCB_OFFSET + 32)
  40. movq (%rbx), %rbx
  41. movq %rbx, %fs:(SHIM_TCB_OFFSET + 40)
  42. movq shim_table@GOTPCREL(%rip), %rbx
  43. movq (%rbx,%rax,8), %r12
  44. cmp $0, (%r12)
  45. je isundef
  46. isdef:
  47. pushq %rdi
  48. pushq %rsi
  49. pushq %rdx
  50. pushq %rcx
  51. pushq %r8
  52. pushq %r9
  53. pushq %r13
  54. pushq %r14
  55. pushq %r15
  56. movq %rsp, %fs:(SHIM_TCB_OFFSET + 48)
  57. call *(%rbx,%rax,8)
  58. popq %r15
  59. popq %r14
  60. popq %r13
  61. popq %r9
  62. popq %r8
  63. popq %rcx
  64. popq %rdx
  65. popq %rsi
  66. popq %rdi
  67. jmp ret
  68. isundef:
  69. movq $-38, %rax
  70. ret:
  71. popq %r12
  72. popq %rbx
  73. popq %rbp
  74. movq $0, %fs:(SHIM_TCB_OFFSET + 24)
  75. movq $0, %fs:(SHIM_TCB_OFFSET + 32)
  76. movq $0, %fs:(SHIM_TCB_OFFSET + 40)
  77. movq $0, %fs:(SHIM_TCB_OFFSET + 48)
  78. addq $128, %rsp
  79. retq
  80. .cfi_endproc
  81. .size syscalldb, .-syscalldb