Since gcc 4.4 the name and calling convention for function profiling on ARM changed. With this patch both types are supported. See http://sourceware.org/ml/libc-ports/2008-04/msg00009.html for some details. Lightly-Tested-by: Anand Gadiyar Tested-by: Kevin Hilman Signed-off-by: Uwe Kleine-König --- Hi, since the first submission I folded in the EXPORT_SYMBOL changes by Anand and removed the question mark after "gcc 4.4". (Using __gnu_mcount_nc was introduced in r140974[1] to gcc.) I'm still unsure if clobbering ip is OK, Russell, maybe you can comment? I think it's save, but as things like that are really nasty, I want to be 100% sure. Regarding my question "is there a way to find out which mcount function is used?", I wonder if we should provide both unconditionally to support using different compilers for kernel and modules? Best regards Uwe PS: I wonder if it's correct to declare mcount and __gnu_mcount_nc in ftrace.h. It's only needed for EXPORT_SYMBOL. So should the decarations go into arm/kernel/armksyms.c? [1] I intended to add a link to the websvn of gcc here, but it's currently broken. arch/arm/include/asm/ftrace.h | 1 + arch/arm/kernel/armksyms.c | 1 + arch/arm/kernel/entry-common.S | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) --- a/arch/arm/include/asm/ftrace.h +++ b/arch/arm/include/asm/ftrace.h @@ -7,6 +7,7 @@ #ifndef __ASSEMBLY__ extern void mcount(void); +extern void __gnu_mcount_nc(void); #endif #endif --- a/arch/arm/kernel/armksyms.c +++ b/arch/arm/kernel/armksyms.c @@ -186,4 +186,5 @@ EXPORT_SYMBOL(_find_next_bit_be); #ifdef CONFIG_FUNCTION_TRACER EXPORT_SYMBOL(mcount); +EXPORT_SYMBOL(__gnu_mcount_nc); #endif --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -133,6 +133,25 @@ ftrace_call: #else +ENTRY(__gnu_mcount_nc) + stmdb sp!, {r0-r3, lr} + ldr r0, =ftrace_trace_function + ldr r2, [r0] + adr r0, ftrace_stub + cmp r0, r2 + bne gnu_trace + ldmia sp!, {r0-r3, ip, lr} + bx ip + +gnu_trace: + ldr r1, [sp, #20] @ lr of instrumented routine + mov r0, lr + sub r0, r0, #MCOUNT_INSN_SIZE + mov lr, pc + mov pc, r2 + ldmia sp!, {r0-r3, ip, lr} + bx ip + ENTRY(mcount) stmdb sp!, {r0-r3, lr} ldr r0, =ftrace_trace_function