This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix ARM EABI profiling

The -pg option (gprof profiling) is broken on ARM EABI targets.  The _mcount 
implementation we inherited from legacy targets assumes FP(r11) points to an 
old 4-word APCS frame layout. Recent gcc changes mean that the stack layout 
is no longer predictable, even when a frame pointer is used. This has always 
been true (and -pg broken) for Thumb-2 code.

The patch below changes EABI based targets to use a new function profiler 
entry point, using a different ABI that should work in all circumstances.

The corresponding glibc support has been available for some time:

We current assume that the mcount implementation does not need to be passed a 
a counter variable. This is true of at least the Linux implementation. 
There's some discussion of other potential requirements here:
I'm deferring support for more needy mcount implementations until someone 
demonstrates actual need.

While Thumb profiling has been busted pretty much forever, ARM profiling has 
regressed from mostly working to not working at all. I believe this is ample 
qualification for making this change during stage 3.

Tested on arm-linux-gnueabi.
Applied to svn trunk


2008-10-08  Paul Brook  <>

	* config/arm/bpabi.h (ARM_FUNCTION_PROFILER): Define new EABI
	compatible profiler (__gnu_mcount_nc).

Index: gcc/config/arm/bpabi.h
--- gcc/config/arm/bpabi.h	(revision 140937)
+++ gcc/config/arm/bpabi.h	(working copy)
@@ -147,3 +147,20 @@
+/* The legacy _mcount implementation assumes r11 points to a
+    4-word APCS frame.  This is generally not true for EABI targets,
+    particularly not in Thumb mode.  We assume the mcount
+    implementation does not require a counter variable (No Counter).
+    Note that __gnu_mcount_nc will be entered with a misaligned stack.
+    This is OK because it uses a special calling convention anyway.  */
+{									\
+  fprintf (STREAM, "\tpush\t{lr}\n");					\
+  fprintf (STREAM, "\tbl\t__gnu_mcount_nc\n");				\

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]