aboutsummaryrefslogtreecommitdiff
path: root/libraries/libprof/profiler.S
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-05-04 15:23:10 -0400
committerPaul Selkirk <paul@psgd.org>2017-05-04 15:23:10 -0400
commit9cec66f9200cb573353928bd3292fb1f710e4b3c (patch)
treede778569d4e433dcd1e0d50bde8f05775555115d /libraries/libprof/profiler.S
parent1175ff63f2a8c4762692551403862f9f0789aef8 (diff)
Copy profiling code from MCUOnEclipse.
Diffstat (limited to 'libraries/libprof/profiler.S')
-rw-r--r--libraries/libprof/profiler.S28
1 files changed, 28 insertions, 0 deletions
diff --git a/libraries/libprof/profiler.S b/libraries/libprof/profiler.S
new file mode 100644
index 0000000..1aa5c97
--- /dev/null
+++ b/libraries/libprof/profiler.S
@@ -0,0 +1,28 @@
+/*
+ * profiler.S
+ * Implements the gprof profiler arc counting function.
+ * Created on: 06.08.2015
+ * Author: Erich Styger
+ */
+
+ .syntax unified
+ .arch armv7-m
+
+.globl __gnu_mcount_nc
+.type __gnu_mcount_nc, %function
+
+__gnu_mcount_nc:
+#if 0 /* dummy version, doing nothing */
+ mov ip, lr
+ pop { lr }
+ bx ip
+#else
+ push {r0, r1, r2, r3, lr} /* save registers */
+ bic r1, lr, #1 /* R1 contains callee address, with thumb bit cleared */
+ ldr r0, [sp, #20] /* R0 contains caller address */
+ bic r0, r0, #1 /* clear thumb bit */
+ bl _mcount_internal /* jump to internal _mcount() implementation */
+ pop {r0, r1, r2, r3, ip, lr} /* restore saved registers */
+ bx ip /* return to caller */
+#endif
+