aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@cygnus.com>1999-05-07 10:02:49 +0000
committerNick Clifton <nickc@gcc.gnu.org>1999-05-07 10:02:49 +0000
commitef179a264402b2263909b8e09aabc57ed45a5f22 (patch)
treeb2df055698c7dd8c4527d0866b021b766ec877b7
parent6c9ef6d420830674a05693b1473e30f1292722bd (diff)
downloadgcc-ef179a264402b2263909b8e09aabc57ed45a5f22.zip
gcc-ef179a264402b2263909b8e09aabc57ed45a5f22.tar.gz
gcc-ef179a264402b2263909b8e09aabc57ed45a5f22.tar.bz2
Apply patch from Nick Burrett <nick.burrett@btinternet.com>
to implementn -mpoke-function-name From-SVN: r26817
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/config/arm/aof.h2
-rw-r--r--gcc/config/arm/aout.h7
-rw-r--r--gcc/config/arm/arm.c45
-rw-r--r--gcc/config/arm/arm.h2
-rw-r--r--gcc/config/arm/elf.h24
6 files changed, 81 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 57cfb16..edc1e72 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+Fri May 7 09:54:11 1999 Nick Clifton <nickc@cygnus.com>
+
+ Patch from: Nick Burrett <nick.burrett@btinternet.com>
+
+ * arm.c (arm_poke_function_name): New function to implement
+ -mpoke-function-name.
+ * aof.h (ASM_DECLARE_FUNCTION_NAME): Call it.
+ * aout.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
+ * elf.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
+ * arm.h: Prototype it.
+ (TARGET_SWITCHES): Add `no-poke-function-name'.
+
Fri May 7 14:19:31 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* fixinc/server.c (read_pipe_timeout): Declare volatile, modified
in signal handler.
diff --git a/gcc/config/arm/aof.h b/gcc/config/arm/aof.h
index ce41a70..d0bc692 100644
--- a/gcc/config/arm/aof.h
+++ b/gcc/config/arm/aof.h
@@ -324,6 +324,8 @@ do { \
#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
{ \
+ if (TARGET_POKE_FUNCTION_NAME) \
+ arm_poke_function_name ((STREAM), (NAME)); \
ASM_OUTPUT_LABEL (STREAM, NAME); \
if (! TREE_PUBLIC (DECL)) \
{ \
diff --git a/gcc/config/arm/aout.h b/gcc/config/arm/aout.h
index 692d54f..2e341b7 100644
--- a/gcc/config/arm/aout.h
+++ b/gcc/config/arm/aout.h
@@ -129,7 +129,12 @@ do { \
/* Output a function label definition. */
#ifndef ASM_DECLARE_FUNCTION_NAME
-#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) ASM_OUTPUT_LABEL (STREAM, NAME)
+#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
+{ \
+ if (TARGET_POKE_FUNCTION_NAME) \
+ arm_poke_function_name ((STREAM), (NAME)); \
+ ASM_OUTPUT_LABEL (STREAM, NAME); \
+}
#endif
#ifndef ASM_OUTPUT_LABEL
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index dc33088..03891cd 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -5398,6 +5398,51 @@ arm_volatile_func ()
return (optimize > 0 && TREE_THIS_VOLATILE (current_function_decl));
}
+/* Write the function name into the code section, directly preceding
+ the function prologue.
+
+ Code will be output similar to this:
+ t0
+ .ascii "arm_poke_function_name", 0
+ .align
+ t1
+ .word 0xff000000 + (t1 - t0)
+ arm_poke_function_name
+ mov ip, sp
+ stmfd sp!, {fp, ip, lr, pc}
+ sub fp, ip, #4
+
+ When performing a stack backtrace, code can inspect the value
+ of 'pc' stored at 'fp' + 0. If the trace function then looks
+ at location pc - 12 and the top 8 bits are set, then we know
+ that there is a function name embedded immediately preceding this
+ location and has length ((pc[-3]) & 0xff000000).
+
+ We assume that pc is declared as a pointer to an unsigned long.
+
+ It is of no benefit to output the function name if we are assembling
+ a leaf function. These function types will not contain a stack
+ backtrace structure, therefore it is not possible to determine the
+ function name. */
+
+void
+arm_poke_function_name (stream, name)
+ FILE * stream;
+ char * name;
+{
+ unsigned long alignlength;
+ unsigned long length;
+ rtx x;
+
+ length = strlen (name);
+ alignlength = (length + 1) + 3 & ~3;
+
+ ASM_OUTPUT_ASCII (stream, name, length + 1);
+ ASM_OUTPUT_ALIGN (stream, 2);
+ x = GEN_INT (0xff000000UL + alignlength);
+ ASM_OUTPUT_INT (stream, x);
+}
+
/* The amount of stack adjustment that happens here, in output_return and in
output_epilogue must be exactly the same as was calculated during reload,
or things will point to the wrong place. The only time we can safely
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index 52b4332..b15fe21 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -346,6 +346,7 @@ function tries to return. */
{"no-apcs-frame", -ARM_FLAG_APCS_FRAME, "" }, \
{"poke-function-name", ARM_FLAG_POKE, \
"Store function names in object code" }, \
+ {"no-poke-function-name", -ARM_FLAG_POKE, "" }, \
{"fpe", ARM_FLAG_FPE, "" }, \
{"apcs-32", ARM_FLAG_APCS_32, \
"Use the 32bit version of the APCS" }, \
@@ -2190,6 +2191,7 @@ char * arithmetic_instr PROTO ((Rtx, int));
void output_ascii_pseudo_op STDIO_PROTO ((FILE *, unsigned char *, int));
char * output_return_instruction PROTO ((Rtx, int, int));
int arm_volatile_func PROTO ((void));
+void arm_poke_function_name STDIO_PROTO ((FILE *, char *));
void output_func_prologue STDIO_PROTO ((FILE *, int));
void output_func_epilogue STDIO_PROTO ((FILE *, int));
void arm_expand_prologue PROTO ((void));
diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h
index c887ba2..e6d8eb7 100644
--- a/gcc/config/arm/elf.h
+++ b/gcc/config/arm/elf.h
@@ -60,16 +60,20 @@ Boston, MA 02111-1307, USA. */
/* Write the extra assembler code needed to declare a function properly.
Some svr4 assemblers need to also have something extra said about the
function's return value. We allow for that here. */
-#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
- do { \
- fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
- assemble_name (FILE, NAME); \
- putc (',', FILE); \
- fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
- putc ('\n', FILE); \
- ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
- ASM_OUTPUT_LABEL(FILE, NAME); \
- } while (0)
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
+ do \
+ { \
+ if (TARGET_POKE_FUNCTION_NAME) \
+ arm_poke_function_name (FILE, NAME); \
+ fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ putc (',', FILE); \
+ fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
+ putc ('\n', FILE); \
+ ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
+ ASM_OUTPUT_LABEL(FILE, NAME); \
+ } \
+ while (0)
/* Write the extra assembler code needed to declare an object properly. */
#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \