machine-gmon.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Machine-dependent definitions for profiling support. ARM version.
  2. Copyright (C) 1996, 1997, 1998 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. /* GCC for the ARM cannot compile __builtin_return_address(N) for N != 0,
  17. so we must use an assembly stub. */
  18. #include <sysdep.h>
  19. #ifndef NO_UNDERSCORES
  20. /* The asm symbols for C functions are `_function'.
  21. The canonical name for the counter function is `mcount', no _. */
  22. void _mcount (void) asm ("mcount");
  23. #else
  24. /* The canonical name for the function is `_mcount' in both C and asm,
  25. but some old asm code might assume it's `mcount'. */
  26. void _mcount (void);
  27. weak_alias (_mcount, mcount)
  28. #endif
  29. static void mcount_internal (u_long frompc, u_long selfpc);
  30. #define _MCOUNT_DECL(frompc, selfpc) \
  31. static void mcount_internal (u_long frompc, u_long selfpc)
  32. /* This macro/func MUST save r0, r1 because the compiler inserts
  33. blind calls to _mount(), ignoring the fact that _mcount may
  34. clobber registers; therefore, _mcount may NOT clobber registers */
  35. /* if (this_fp!=0) {
  36. r0 = this_fp
  37. r1 = this_lr
  38. r1 = [r1-4] which is caller's lr
  39. if (r1!=0)
  40. r1 = caller's lr
  41. call mcount_internal(this_lr, caller's_lr)
  42. }
  43. */
  44. #define MCOUNT \
  45. void _mcount (void) \
  46. { \
  47. __asm__("stmdb sp!, {r0, r1, r2, r3};" \
  48. "movs fp, fp;" \
  49. "moveq r1, #0;" \
  50. "ldrne r1, [fp, $-4];" \
  51. "ldrne r0, [fp, $-12];" \
  52. "movnes r0, r0;" \
  53. "ldrne r0, [r0, $-4];" \
  54. "movs r0, r0;" \
  55. "blne mcount_internal;" \
  56. "ldmia sp!, {r0, r1, r2, r3}"); \
  57. }