mcount.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* i386-specific implemetation of profiling support.
  2. Copyright (C) 1997, 2002 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. /* We need a special version of the `mcount' function since for ix86 it
  18. must not clobber any register. This has several reasons:
  19. - there is a bug in gcc as of version 2.7.2.2 which prohibits the
  20. use of profiling together with nested functions
  21. - the ELF `fixup' function uses GCC's regparm feature
  22. - some (future) systems might want to pass parameters in registers. */
  23. .globl _mcount
  24. .type _mcount,@function;
  25. .align 1<<4
  26. _mcount:
  27. /* Save the caller-clobbered registers. */
  28. pushl %eax
  29. pushl %ecx
  30. pushl %edx
  31. movl 12(%esp), %edx
  32. movl 4(%ebp), %eax
  33. /* No need to access the PLT or GOT, __mcount_internal is an
  34. internal function and we can make a relative call. */
  35. call __mcount_internal
  36. /* Pop the saved registers. Please note that `mcount' has no
  37. return value. */
  38. popl %edx
  39. popl %ecx
  40. popl %eax
  41. ret
  42. .size _mcount,.-_mcount;
  43. #undef mcount
  44. .weak mcount ; mcount = _mcount