* config/stormy16/stormy16.c (stormy16_asm_out_destructor): New
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Aug 2001 15:44:20 +0000 (15:44 +0000)
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Aug 2001 15:44:20 +0000 (15:44 +0000)
function.
(stormy16_asm_out_constructor): New function.
(TARGET_ASM_CONSTRUCTOR): Define.
(TARGET_ASM_DESTRUCTOR): Define.

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

gcc/ChangeLog
gcc/config/stormy16/stormy16.c

index 6993ca6..a7ff025 100644 (file)
@@ -1,3 +1,11 @@
+2001-08-31  Geoffrey Keating  <geoffk@redhat.com>
+
+       * config/stormy16/stormy16.c (stormy16_asm_out_destructor): New
+       function.
+       (stormy16_asm_out_constructor): New function.
+       (TARGET_ASM_CONSTRUCTOR): Define.
+       (TARGET_ASM_DESTRUCTOR): Define.
+
 2001-08-31  Andreas Jaeger  <aj@suse.de>
 
        * gcse.c (add_label_notes): REG_LABEL is an INSN_LIST.
index 758b977..ebb9be7 100644 (file)
@@ -45,6 +45,8 @@ Boston, MA 02111-1307, USA.  */
 #include "tm_p.h"
 
 static rtx emit_addhi3_postreload PARAMS ((rtx, rtx, rtx));
+static void stormy16_asm_out_constructor PARAMS ((rtx, int));
+static void stormy16_asm_out_destructor PARAMS ((rtx, int));
 
 /* Define the information needed to generate branch and scc insns.  This is
    stored from the compare operation.  */
@@ -1324,6 +1326,61 @@ stormy16_encode_section_info (decl)
   if (TREE_CODE (decl) == FUNCTION_DECL)
     SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
 }
+
+/* Output constructors and destructors.  Just like 
+   default_named_section_asm_out_* but don't set the sections writable.  */
+#undef TARGET_ASM_CONSTRUCTOR
+#define TARGET_ASM_CONSTRUCTOR stormy16_asm_out_constructor
+#undef TARGET_ASM_DESTRUCTOR
+#define TARGET_ASM_DESTRUCTOR stormy16_asm_out_destructor
+
+static void
+stormy16_asm_out_destructor (symbol, priority)
+     rtx symbol;
+     int priority;
+{
+  const char *section = ".dtors";
+  char buf[16];
+
+  /* ??? This only works reliably with the GNU linker.   */
+  if (priority != DEFAULT_INIT_PRIORITY)
+    {
+      sprintf (buf, ".dtors.%.5u",
+              /* Invert the numbering so the linker puts us in the proper
+                 order; constructors are run from right to left, and the
+                 linker sorts in increasing order.  */
+              MAX_INIT_PRIORITY - priority);
+      section = buf;
+    }
+
+  named_section_flags (section, 0);
+  assemble_align (POINTER_SIZE);
+  assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
+}
+
+static void
+stormy16_asm_out_constructor (symbol, priority)
+     rtx symbol;
+     int priority;
+{
+  const char *section = ".ctors";
+  char buf[16];
+
+  /* ??? This only works reliably with the GNU linker.   */
+  if (priority != DEFAULT_INIT_PRIORITY)
+    {
+      sprintf (buf, ".ctors.%.5u",
+              /* Invert the numbering so the linker puts us in the proper
+                 order; constructors are run from right to left, and the
+                 linker sorts in increasing order.  */
+              MAX_INIT_PRIORITY - priority);
+      section = buf;
+    }
+
+  named_section_flags (section, 0);
+  assemble_align (POINTER_SIZE);
+  assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
+}
 \f
 /* Print a memory address as an operand to reference that memory location.  */
 void