[go: up one dir, main page]

File: mcount.S

package info (click to toggle)
uftrace 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,356 kB
  • sloc: ansic: 49,770; python: 11,181; asm: 837; makefile: 769; sh: 637; cpp: 627; javascript: 191
file content (52 lines) | stat: -rw-r--r-- 962 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* in i386, generally used stack for argument passing. */
/* use register for return : %eax */
/* no need save registers */
/* stack frame (with -pg): parent addr = 4(%ebp) */
/* child addr = (%esp) */

#include "utils/asm.h"

GLOBAL(mcount)
	sub $32, %esp
	/* save registers */
	movl %edx, 28(%esp)
	movl %ecx, 24(%esp)
	movl %eax, 20(%esp)
	movl $0, 16(%esp)
	/* parent location */
	leal 4(%ebp), %eax
	movl %eax, 0(%esp)
	/* child addr */
	movl 32(%esp), %eax
	movl %eax, 4(%esp)
	/*  mcount_regs */
	leal 16(%esp), %eax
	movl %eax, 8(%esp)

	call mcount_entry

	/* restore registers */
	movl 20(%esp), %eax
	movl 24(%esp), %ecx
	movl 28(%esp), %edx
	add $32, %esp
	ret
END(mcount)


ENTRY(mcount_return)
	sub $16, %esp
	movl %edx, 8(%esp)
	movl %eax, 4(%esp)
	leal 4(%esp), %eax
	movl %eax, 0(%esp)

	/* returns original parent address */
	call mcount_exit
	movl %eax, 12(%esp)

	movl 4(%esp), %eax
	movl 8(%esp), %edx
	add $12, %esp
	ret
END(mcount_return)