sysdep.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* Assembler macros for x86-64.
  2. Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifdef __ASSEMBLER__
  17. /* Syntactic details of assembler. */
  18. #ifdef HAVE_ELF
  19. /* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
  20. #define ALIGNARG(log2) 1<<log2
  21. /* For ELF we need the `.type' directive to make shared libs work right. */
  22. #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
  23. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
  24. /* In ELF C symbols are asm symbols. */
  25. #undef NO_UNDERSCORES
  26. #define NO_UNDERSCORES
  27. #else
  28. #define ALIGNARG(log2) log2
  29. #define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */
  30. #define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */
  31. #endif
  32. /* Define an entry point visible from C. */
  33. #define ENTRY(name) \
  34. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
  35. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
  36. .align ALIGNARG(4); \
  37. C_LABEL(name) \
  38. cfi_startproc; \
  39. CALL_MCOUNT
  40. #undef END
  41. #define END(name) \
  42. cfi_endproc; \
  43. ASM_SIZE_DIRECTIVE(name)
  44. /* If compiled for profiling, call `mcount' at the start of each function. */
  45. #ifdef PROF
  46. /* The mcount code relies on a normal frame pointer being on the stack
  47. to locate our caller, so push one just for its benefit. */
  48. #define CALL_MCOUNT \
  49. pushq %rbp; \
  50. cfi_adjust_cfa_offset(8); \
  51. movq %rsp, %rbp; \
  52. cfi_def_cfa_register(%rbp); \
  53. call JUMPTARGET(mcount); \
  54. popq %rbp; \
  55. cfi_def_cfa(rsp,8);
  56. #else
  57. #define CALL_MCOUNT /* Do nothing. */
  58. #endif
  59. #ifdef NO_UNDERSCORES
  60. /* Since C identifiers are not normally prefixed with an underscore
  61. on this system, the asm identifier `syscall_error' intrudes on the
  62. C name space. Make sure we use an innocuous name. */
  63. #define syscall_error __syscall_error
  64. #define mcount _mcount
  65. #endif
  66. // commented by GP
  67. #define PSEUDO(name, syscall_name, args) \
  68. lose: \
  69. jmp JUMPTARGET(syscall_error) \
  70. .globl syscall_error; \
  71. ENTRY (name) \
  72. DO_CALL (syscall_name, args); \
  73. jb lose
  74. #undef PSEUDO_END
  75. #define PSEUDO_END(name) \
  76. END (name)
  77. #undef JUMPTARGET
  78. #ifdef PIC
  79. #define JUMPTARGET(name) name##@PLT
  80. #else
  81. #define JUMPTARGET(name) name
  82. #endif
  83. /* Local label name for asm code. */
  84. #ifndef L
  85. # ifdef HAVE_ELF
  86. /* ELF-like local names start with `.L'. */
  87. # define L(name) .L##name
  88. # else
  89. # define L(name) name
  90. # endif
  91. #endif
  92. #endif /* __ASSEMBLER__ */