Commit d3b9dc9d authored by Rabin Vincent's avatar Rabin Vincent

ARM: ftrace: use gas macros to avoid code duplication

Use assembler macros to avoid copy/pasting code between the
implementations of the two variants of the mcount call.
Signed-off-by: default avatarRabin Vincent <rabin@rab.in>
parent 61b5cb1c
...@@ -141,98 +141,112 @@ ENDPROC(ret_from_fork) ...@@ -141,98 +141,112 @@ ENDPROC(ret_from_fork)
#endif #endif
#endif #endif
#ifdef CONFIG_DYNAMIC_FTRACE .macro __mcount suffix
ENTRY(__gnu_mcount_nc) mcount_enter
mov ip, lr ldr r0, =ftrace_trace_function
ldmia sp!, {lr} ldr r2, [r0]
mov pc, ip adr r0, .Lftrace_stub
ENDPROC(__gnu_mcount_nc) cmp r0, r2
bne 1f
mcount_exit
ENTRY(ftrace_caller) 1: mcount_get_lr r1 @ lr of instrumented func
stmdb sp!, {r0-r3, lr} mov r0, lr @ instrumented function
mov r0, lr sub r0, r0, #MCOUNT_INSN_SIZE
adr lr, BSYM(2f)
mov pc, r2
2: mcount_exit
.endm
.macro __ftrace_caller suffix
mcount_enter
mcount_get_lr r1 @ lr of instrumented func
mov r0, lr @ instrumented function
sub r0, r0, #MCOUNT_INSN_SIZE sub r0, r0, #MCOUNT_INSN_SIZE
ldr r1, [sp, #20]
.global ftrace_call .globl ftrace_call\suffix
ftrace_call: ftrace_call\suffix:
bl ftrace_stub bl ftrace_stub
ldmia sp!, {r0-r3, ip, lr}
mov pc, ip mcount_exit
ENDPROC(ftrace_caller) .endm
#ifdef CONFIG_OLD_MCOUNT #ifdef CONFIG_OLD_MCOUNT
/*
* mcount
*/
.macro mcount_enter
stmdb sp!, {r0-r3, lr}
.endm
.macro mcount_get_lr reg
ldr \reg, [fp, #-4]
.endm
.macro mcount_exit
ldr lr, [fp, #-4]
ldmia sp!, {r0-r3, pc}
.endm
ENTRY(mcount) ENTRY(mcount)
#ifdef CONFIG_DYNAMIC_FTRACE
stmdb sp!, {lr} stmdb sp!, {lr}
ldr lr, [fp, #-4] ldr lr, [fp, #-4]
ldmia sp!, {pc} ldmia sp!, {pc}
#else
__mcount _old
#endif
ENDPROC(mcount) ENDPROC(mcount)
#ifdef CONFIG_DYNAMIC_FTRACE
ENTRY(ftrace_caller_old) ENTRY(ftrace_caller_old)
stmdb sp!, {r0-r3, lr} __ftrace_caller _old
ldr r1, [fp, #-4]
mov r0, lr
sub r0, r0, #MCOUNT_INSN_SIZE
.globl ftrace_call_old
ftrace_call_old:
bl ftrace_stub
ldr lr, [fp, #-4] @ restore lr
ldmia sp!, {r0-r3, pc}
ENDPROC(ftrace_caller_old) ENDPROC(ftrace_caller_old)
#endif #endif
#else .purgem mcount_enter
.purgem mcount_get_lr
.purgem mcount_exit
#endif
ENTRY(__gnu_mcount_nc) /*
* __gnu_mcount_nc
*/
.macro mcount_enter
stmdb sp!, {r0-r3, lr} stmdb sp!, {r0-r3, lr}
ldr r0, =ftrace_trace_function .endm
ldr r2, [r0]
adr r0, .Lftrace_stub .macro mcount_get_lr reg
cmp r0, r2 ldr \reg, [sp, #20]
bne gnu_trace .endm
.macro mcount_exit
ldmia sp!, {r0-r3, ip, lr} ldmia sp!, {r0-r3, ip, lr}
mov pc, ip mov pc, ip
.endm
gnu_trace: ENTRY(__gnu_mcount_nc)
ldr r1, [sp, #20] @ lr of instrumented routine #ifdef CONFIG_DYNAMIC_FTRACE
mov r0, lr mov ip, lr
sub r0, r0, #MCOUNT_INSN_SIZE ldmia sp!, {lr}
adr lr, BSYM(1f)
mov pc, r2
1:
ldmia sp!, {r0-r3, ip, lr}
mov pc, ip mov pc, ip
#else
__mcount
#endif
ENDPROC(__gnu_mcount_nc) ENDPROC(__gnu_mcount_nc)
#ifdef CONFIG_OLD_MCOUNT #ifdef CONFIG_DYNAMIC_FTRACE
/* ENTRY(ftrace_caller)
* This is under an ifdef in order to force link-time errors for people trying __ftrace_caller
* to build with !FRAME_POINTER with a GCC which doesn't use the new-style ENDPROC(ftrace_caller)
* mcount.
*/
ENTRY(mcount)
stmdb sp!, {r0-r3, lr}
ldr r0, =ftrace_trace_function
ldr r2, [r0]
adr r0, ftrace_stub
cmp r0, r2
bne trace
ldr lr, [fp, #-4] @ restore lr
ldmia sp!, {r0-r3, pc}
trace:
ldr r1, [fp, #-4] @ lr of instrumented routine
mov r0, lr
sub r0, r0, #MCOUNT_INSN_SIZE
mov lr, pc
mov pc, r2
ldr lr, [fp, #-4] @ restore lr
ldmia sp!, {r0-r3, pc}
ENDPROC(mcount)
#endif #endif
#endif /* CONFIG_DYNAMIC_FTRACE */ .purgem mcount_enter
.purgem mcount_get_lr
.purgem mcount_exit
ENTRY(ftrace_stub) ENTRY(ftrace_stub)
.Lftrace_stub: .Lftrace_stub:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment