OSDN Git Service

Apply patch from Nick Burrett <nick.burrett@btinternet.com>
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 May 1999 10:02:49 +0000 (10:02 +0000)
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 May 1999 10:02:49 +0000 (10:02 +0000)
to implementn -mpoke-function-name

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26817 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/arm/aof.h
gcc/config/arm/aout.h
gcc/config/arm/arm.c
gcc/config/arm/arm.h
gcc/config/arm/elf.h

index 57cfb16..edc1e72 100644 (file)
@@ -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.
index ce41a70..d0bc692 100644 (file)
@@ -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))                    \
     {                                          \
index 692d54f..2e341b7 100644 (file)
@@ -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
index dc33088..03891cd 100644 (file)
@@ -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
index 52b4332..b15fe21 100644 (file)
@@ -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));
index c887ba2..e6d8eb7 100644 (file)
@@ -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)                      \