2 * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com)
4 * This file implements mcount(), which is used to collect profiling data.
5 * This can also be tweaked for kernel stack overflow detection.
8 #include <linux/linkage.h>
11 * This is the main variant and is called by C code. GCC's -pg option
12 * automatically instruments every C function with a call to this.
18 .type _mcount,#function
20 .type mcount,#function
23 #ifdef CONFIG_FUNCTION_TRACER
24 #ifdef CONFIG_DYNAMIC_FTRACE
25 /* Do nothing, the retl/nop below is all we need. */
27 sethi %hi(function_trace_stop), %g1
28 lduw [%g1 + %lo(function_trace_stop)], %g2
30 sethi %hi(ftrace_trace_function), %g1
31 sethi %hi(ftrace_stub), %g2
32 ldx [%g1 + %lo(ftrace_trace_function)], %g1
33 or %g2, %lo(ftrace_stub), %g2
45 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
46 sethi %hi(ftrace_graph_return), %g1
47 ldx [%g1 + %lo(ftrace_graph_return)], %g3
50 sethi %hi(ftrace_graph_entry_stub), %g2
51 sethi %hi(ftrace_graph_entry), %g1
52 or %g2, %lo(ftrace_graph_entry_stub), %g2
53 ldx [%g1 + %lo(ftrace_graph_entry)], %g1
61 ba,pt %xcc, ftrace_graph_caller
69 .size _mcount,.-_mcount
72 #ifdef CONFIG_FUNCTION_TRACER
74 .type ftrace_stub,#function
78 .size ftrace_stub,.-ftrace_stub
79 #ifdef CONFIG_DYNAMIC_FTRACE
81 .type ftrace_caller,#function
83 sethi %hi(function_trace_stop), %g1
85 lduw [%g1 + %lo(function_trace_stop)], %g1
86 brnz,pn %g1, ftrace_stub
96 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
97 .globl ftrace_graph_call
104 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
105 .size ftrace_graph_call,.-ftrace_graph_call
107 .size ftrace_call,.-ftrace_call
108 .size ftrace_caller,.-ftrace_caller
112 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
113 ENTRY(ftrace_graph_caller)
116 call prepare_ftrace_return
120 END(ftrace_graph_caller)
122 ENTRY(return_to_handler)
124 call ftrace_return_to_handler
128 END(return_to_handler)