aboutsummaryrefslogtreecommitdiff
path: root/ta
diff options
context:
space:
mode:
authorJerome Forissier <jerome.forissier@linaro.org>2016-10-13 15:21:53 +0200
committerJerome Forissier <jerome.forissier@linaro.org>2017-01-24 18:33:32 +0100
commit883c4be3d11cacf49665f51d1d6af4c02a0a0afd (patch)
tree05e131182cd9c1223c0be98e58d3632cf65d4f5a /ta
parentf3bb2312f41f85790c77e749f096f10be36e9506 (diff)
Add support for user TA profiling with gprof (-pg)
Adds the infrastructure to collect profiling information from Trusted Applications running in user mode and instrumented with -pg. Enable with: CFG_TA_GPROF_SUPPORT=y. Profiling support in itself adds no significant performance overhead. Instrumented applications however may run 1.3x - 2x slower, and have a larger .bss section (+1.36 times .text size for 32-bit TAs, +1.77 times .text size for 64-bit ones). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (D02 64-bit) Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (QEMU 32-bit) Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'ta')
-rw-r--r--ta/arch/arm/ta.ld.S30
1 files changed, 29 insertions, 1 deletions
diff --git a/ta/arch/arm/ta.ld.S b/ta/arch/arm/ta.ld.S
index 8a318401..b80abc34 100644
--- a/ta/arch/arm/ta.ld.S
+++ b/ta/arch/arm/ta.ld.S
@@ -1,10 +1,18 @@
#ifdef ARM32
OUTPUT_FORMAT("elf32-littlearm")
OUTPUT_ARCH(arm)
+#define MCOUNT_SYM __gnu_mcount_nc
+/*
+ * This magic value corresponds to the size requested by
+ * libutee/arch/arm/gprof/gprof.c
+ */
+#define GPROF_BUF_MULT(x) ((x) * 136) / 100
#endif
#ifdef ARM64
OUTPUT_FORMAT("elf64-littleaarch64")
OUTPUT_ARCH(aarch64)
+#define MCOUNT_SYM _mcount
+#define GPROF_BUF_MULT(x) ((x) * 177) / 100
#endif
PHDRS {
@@ -24,6 +32,7 @@ SECTIONS {
.ta_head : {*(.ta_head)} :exec
.text : {
+ __text_start = .;
*(.text .text.*)
*(.stub)
*(.glue_7)
@@ -31,6 +40,8 @@ SECTIONS {
*(.gnu.linkonce.t.*)
/* Workaround for an erratum in ARM's VFP11 coprocessor */
*(.vfp11_veneer)
+ PROVIDE(MCOUNT_SYM = __utee_mcount);
+ __text_end = .;
}
.eh_frame : { *(.eh_frame) } :rodata
.rodata : {
@@ -77,7 +88,24 @@ SECTIONS {
.data : { *(.data .data.* .gnu.linkonce.d.*) } :rwdata
- .bss : { *(.bss .bss.* .gnu.linkonce.b.* COMMON) }
+ .bss : {
+ *(.bss .bss.* .gnu.linkonce.b.* COMMON)
+
+ /*
+ * TA profiling with gprof
+ * Reserve some space for the profiling buffer, only if the
+ * TA is instrumented (i.e., some files were built with -pg).
+ * Note that PROVIDE() above defines a symbol only if it is
+ * referenced in the object files.
+ * This also provides a way to detect at runtime if the TA is
+ * instrumented or not.
+ */
+ . = ALIGN(8);
+ __gprof_buf_start = .;
+ . += DEFINED(MCOUNT_SYM) ?
+ GPROF_BUF_MULT(__text_end - __text_start) : 0;
+ __gprof_buf_end = .;
+ }
/DISCARD/ : { *(.interp) }
}