+
+/* Output debug information for a global DECL. Called from toplev.c
+ after compilation proper has finished. */
+
+static void
+sdbout_global_decl (tree decl)
+{
+ if (TREE_CODE (decl) == VAR_DECL
+ && !DECL_EXTERNAL (decl)
+ && DECL_RTL_SET_P (decl))
+ {
+ /* The COFF linker can move initialized global vars to the end.
+ And that can screw up the symbol ordering. Defer those for
+ sdbout_finish (). */
+ if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl))
+ sdbout_symbol (decl, 0);
+
+ /* Output COFF information for non-global file-scope initialized
+ variables. */
+ if (DECL_INITIAL (decl) && GET_CODE (DECL_RTL (decl)) == MEM)
+ sdbout_toplevel_data (decl);
+ }
+}
+
+/* Output initialized global vars at the end, in the order of
+ definition. See comment in sdbout_global_decl. */
+
+static void
+sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED)
+{
+ tree decl = (*lang_hooks.decls.getdecls) ();
+ unsigned int len = list_length (decl);
+ tree *vec = (tree *) xmalloc (sizeof (tree) * len);
+ unsigned int i;
+
+ /* Process the decls in reverse order--earliest first. Put them
+ into VEC from back to front, then take out from front. */
+
+ for (i = 0; i < len; i++, decl = TREE_CHAIN (decl))
+ vec[len - i - 1] = decl;
+
+ for (i = 0; i < len; i++)
+ {
+ decl = vec[i];
+ if (TREE_CODE (decl) == VAR_DECL
+ && ! DECL_EXTERNAL (decl)
+ && DECL_INITIAL (decl)
+ && TREE_PUBLIC (decl)
+ && DECL_RTL_SET_P (decl))
+ sdbout_symbol (decl, 0);
+ }
+
+ free (vec);
+}
+