# HG changeset patch # User jld # Date 1394998751 0 # Node ID 8b3440f8b6b64742cef9934870fdf78b403c2e4a # Parent 4839eca9f0c79a33e06830a188b485dce963e4f0 * src/mcount.S: Add mcount functions for call-graph profiling. * cdl/hal_arm.cdl: Add option to build mcount functions. [ Bugzilla 1001959 ] diff --git a/packages/hal/arm/arch/current/ChangeLog b/packages/hal/arm/arch/current/ChangeLog --- a/packages/hal/arm/arch/current/ChangeLog +++ b/packages/hal/arm/arch/current/ChangeLog @@ -1,3 +1,9 @@ +2014-03-14 John Dallaway + + * src/mcount.S: Add mcount functions for call-graph profiling. + * cdl/hal_arm.cdl: Add option to build mcount functions. + [ Bugzilla 1001959 ] + 2011-11-23 Nick Garnett * cdl/hal_arm.cdl: Add CDL to control whether both IRQs and FIQs @@ -1823,7 +1829,7 @@ 1998-10-16 Bart Veer +// +// For GCC version 4.4 and later targeting ARM, the following code is +// inserted: +// +// push { lr } +// bl __gnu_mcount_nc +// +// We provide implementations of both mcount() and __gnu_mcount_nc() to +// call the eCos __profile_mcount() function. +*/ + + .syntax unified + .arm + .globl mcount + .section .text.mcount + .type mcount, %function +mcount: + // resume execution beyond the data pointer on return to caller + add lr, lr, #4 + + // caller assumes r0-r3 will be preserved (non-AAPCS), we use + // r6 and must preserve lr across our __profile_mcount() call + push { r0, r1, r2, r3, r6, lr } + + // set up parameters for __profile_mcount() + sub r0, r12, #2 + bic r0, r0, #1 + bic r1, lr, #1 + + // disable interrupts + mrs r6, cpsr + orr r2, r6, #CPSR_INTR_MASK + msr cpsr, r2 + + // call eCos __profile_mcount() + // r6 is preserved across the call per AAPCS + bl __profile_mcount + + // restore interrupts + msr cpsr, r6 + + // restore registers and return + pop { r0, r1, r2, r3, r6, r12 } + bx r12 + + + .globl __gnu_mcount_nc + .section .text.__gnu_mcount_nc + .type __gnu_mcount_nc, %function +__gnu_mcount_nc: + // caller assumes r0-r3 will be preserved (non-AAPCS), we use + // r6 and must preserve lr across our __profile_mcount() call + push { r0, r1, r2, r3, r6, lr } + + // set up parameters for __profile_mcount() + ldr r0, [ sp, #24 ] + sub r0, r0, #2 + bic r0, r0, #1 + bic r1, lr, #1 + + // disable interrupts + mrs r6, cpsr + orr r2, r6, #CPSR_INTR_MASK + msr cpsr, r2 + + // call eCos __profile_mcount() + // r6 is preserved across the call per AAPCS + bl __profile_mcount + + // restore interrupts + msr cpsr, r6 + + // restore registers and return + pop { r0, r1, r2, r3, r6, r12, lr } + bx r12 + +//========================================================================== +// end of mcount.S