mcount.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com)
  3. *
  4. * This file implements mcount(), which is used to collect profiling data.
  5. * This can also be tweaked for kernel stack overflow detection.
  6. */
  7. #include <linux/linkage.h>
  8. /*
  9. * This is the main variant and is called by C code. GCC's -pg option
  10. * automatically instruments every C function with a call to this.
  11. */
  12. .text
  13. .align 32
  14. .globl _mcount
  15. .type _mcount,#function
  16. .globl mcount
  17. .type mcount,#function
  18. _mcount:
  19. mcount:
  20. #ifdef CONFIG_FUNCTION_TRACER
  21. #ifdef CONFIG_DYNAMIC_FTRACE
  22. /* Do nothing, the retl/nop below is all we need. */
  23. #else
  24. sethi %hi(function_trace_stop), %g1
  25. lduw [%g1 + %lo(function_trace_stop)], %g2
  26. brnz,pn %g2, 1f
  27. sethi %hi(ftrace_trace_function), %g1
  28. sethi %hi(ftrace_stub), %g2
  29. ldx [%g1 + %lo(ftrace_trace_function)], %g1
  30. or %g2, %lo(ftrace_stub), %g2
  31. cmp %g1, %g2
  32. be,pn %icc, 1f
  33. mov %i7, %o1
  34. jmpl %g1, %g0
  35. mov %o7, %o0
  36. /* not reached */
  37. 1:
  38. #endif
  39. #endif
  40. retl
  41. nop
  42. .size _mcount,.-_mcount
  43. .size mcount,.-mcount
  44. #ifdef CONFIG_FUNCTION_TRACER
  45. .globl ftrace_stub
  46. .type ftrace_stub,#function
  47. ftrace_stub:
  48. retl
  49. nop
  50. .size ftrace_stub,.-ftrace_stub
  51. #ifdef CONFIG_DYNAMIC_FTRACE
  52. .globl ftrace_caller
  53. .type ftrace_caller,#function
  54. ftrace_caller:
  55. sethi %hi(function_trace_stop), %g1
  56. mov %i7, %o1
  57. lduw [%g1 + %lo(function_trace_stop)], %g2
  58. brnz,pn %g2, ftrace_stub
  59. mov %o7, %o0
  60. .globl ftrace_call
  61. ftrace_call:
  62. /* If the final kernel link ever turns on relaxation, we'll need
  63. * to do something about this tail call. Otherwise the linker
  64. * will rewrite the call into a branch and nop out the move
  65. * instruction.
  66. */
  67. call ftrace_stub
  68. mov %o0, %o7
  69. retl
  70. nop
  71. .size ftrace_call,.-ftrace_call
  72. .size ftrace_caller,.-ftrace_caller
  73. #endif
  74. #endif