File tree Expand file tree Collapse file tree 3 files changed +26
-18
lines changed Expand file tree Collapse file tree 3 files changed +26
-18
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ SRC += c1args.c
1212SRC += c1loadef.c
1313SRC += c1pglob.c
1414SRC += crt1.c
15- SRC += mcount.c
15+ SRC += mcount_i.c
16+ SRC += mcount.S
1617SRC += memhandl.c
1718SRC += rfinfo.c
1819SRC += dfinfo.c
@@ -40,5 +41,5 @@ $(LIB)/gcrt0.o : gcrt0.S crt0.S exit16.ah sbrk16.ah
4041 $(MISC ) rm gcrt0.o
4142 sed ' s@gcrt0.o@$(LIB)/gcrt0.o@' gcrt0.d > gcrt02.d
4243
43- mcount .o : mcount .c
44+ mcount_i .o : mcount_i .c
4445 $(XNOPGGCC ) -c $<
Original file line number Diff line number Diff line change 1+ .intel_syntax noprefix
2+ .text
3+ .globl _mcount
4+ _mcount:
5+ cmp esp , offset _etext
6+ jb Lstack_overflow
7+ push eax
8+ push ecx
9+ mov eax , [ esp + 8 ] # Our return address (callee)
10+ mov ecx , [ ebp + 4 ] # Callee's return address (caller)
11+ call ___mcount_internal
12+ pop ecx
13+ pop eax
14+ ret
15+ Lstack_overflow:
16+ ud2
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ typedef struct MTAB {
3838
3939static header h ;
4040static short * histogram ;
41- static int mcount_skip = 1 ;
41+ static volatile unsigned char mcount_skip = 1 ;
4242static int histlen ;
4343static MTAB * mtab = 0 ;
4444
@@ -48,35 +48,26 @@ extern int etext __asm__("etext");
4848
4949static int profiling_p ;
5050
51- /* called by functions . Use the pointer it provides to cache
51+ /* called by mcount . Use the pointer it provides to cache
5252** the last used MTABE, so that repeated calls to/from the same
5353** pair works quickly - no lookup.
5454*/
55- void mcount (int _to );
56- void mcount (int _to )
55+ __attribute__((regparm (3 ))) /* EAX, EDX, ECX */
56+ void __mcount_internal (unsigned long to , MTABE * * cache , unsigned long from );
57+ __attribute__((regparm (3 )))
58+ void __mcount_internal (unsigned long to , MTABE * * cache , unsigned long from )
5759{
5860 MTAB * m ;
5961 int i ;
60- unsigned int to ;
61- int ebp ;
62- unsigned int from ;
6362 int mtabi ;
64- MTABE * * cache ;
65-
66- /* obtain the cached pointer */
67- __asm__ __volatile__ ("movl %%edx,%0" : "=g" (cache ));
6863
6964 mcount_skip = 1 ;
7065 /* Do nothing if profiling is disabled. */
7166 if (!profiling_p )
7267 return ;
7368
74- if (& _to < & etext )
75- * (int * )(-1 ) = 0 ; /* fault! */
69+ to -= 12 ;
7670
77- to = * ((& _to )- 1 ) - 12 ;
78- ebp = * ((& _to )- 2 ); /* glean the caller's return address from the stack */
79- from = ((int * )ebp )[1 ];
8071 /* Do nothing if the FROM address is outside the sampling range. */
8172 if (from < h .low || from >= h .high )
8273 return ;
You can’t perform that action at this time.
0 commit comments