diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog
index 94c257db7beee06a5135782d8b5ad3f6dc5cf097..847fd20e97bd3c8b313e32820cd014f8415cce54 100644
--- a/gcc/cobol/ChangeLog
+++ b/gcc/cobol/ChangeLog
@@ -70,7 +70,7 @@
 	* Use built_in version of malloc; required initialization 
     during lang_hook_init
 
-2024-12-26  Robert Dubner <rdubner@symas.com>
+2024-12-27  Robert Dubner <rdubner@symas.com>
 	* Use built_in version of realloc and free
 	* Use built_in version of strdup, memchr, and memset
 	* Use built_in version of abort
@@ -79,4 +79,7 @@
 	* Use built_in version of strcmp
 	* Use built_in version of strcpy
 
+2024-12-27  Robert Dubner <rdubner@symas.com>
+	* Put called_by_main_counter in static memory, not the stack!
+
 
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 51b8c305016537a66e2b2875a2579789f947f78d..d19fdb1b7a709163cbf353d9ca4aa4e11b6ef59c 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -3502,9 +3502,9 @@ enter_program_common(const char *funcname, const char *funcname_)
 
   current_function->first_time_through =
     gg_define_variable(INT,
-                                          "_first_time_through",
-                                          vs_static,
-                                          integer_one_node);
+                        "_first_time_through",
+                        vs_static,
+                        integer_one_node);
 
   gg_create_goto_pair(&current_function->skip_init_goto,
                       &current_function->skip_init_label);
@@ -3554,10 +3554,21 @@ enter_program_common(const char *funcname, const char *funcname_)
           "__gg__codeset_figurative_constants",
           NULL_TREE);
 
-  current_function->first_declarative_section
-                  = gg_define_char_star(null_pointer_node);
+  static int counter=1;
+  char ach[32];
 
-  current_function->called_by_main_counter = gg_define_int(0);
+  sprintf(ach, "_cf_fds_%d", counter);
+  current_function->first_declarative_section
+                  = gg_define_variable(CHAR_P,
+                                       ach,
+                                       vs_static,
+                                       null_pointer_node);
+  sprintf(ach, "_cf_cbmc_%d", counter);
+  current_function->called_by_main_counter = gg_define_variable(INT,
+                                                          ach,
+                                                          vs_static,
+                                                          integer_zero_node);
+  counter += 1;
 
   // Initialize the TRACE logic, which has to be done before the first TRACE1
   // invocation, but after there is a function to lay down GIMPLE code in.
@@ -6503,7 +6514,6 @@ parser_division(cbl_division_t division,
       ENDIF
 
     gg_append_statement(current_function->skip_init_label);
-
     // This is where we check to see if somebody tried to cancel us
     tree cancelled = gg_define_int();
     gg_assign(cancelled,
@@ -6885,8 +6895,6 @@ parser_division(cbl_division_t division,
         ENDIF
       }
       ENDIF
-
-
     }
   }
 
@@ -12378,6 +12386,7 @@ create_and_call(size_t narg,
     // passed expressions BY VALUE and BY CONTENT
     gg_assign(gg_array_value(var_decl_call_parameter_lengths, i),length);
     }
+
   // Let the called program know how many parameters we are passing
   gg_assign(var_decl_call_parameter_count,
             build_int_cst_type(INT, narg));
@@ -12396,7 +12405,6 @@ create_and_call(size_t narg,
 
     // We are expecting a return value of type CHAR_P, SSIZE_T, SIZE_T,
     // UINT128 or INT128
-
     push_program_state();
     gg_assign(returned_value, gg_cast(returned_value_type, call_expr));
     pop_program_state();
@@ -12638,7 +12646,6 @@ parser_call(   cbl_refer_t name,
 
   tree function_handle = function_handle_from_name( name,
                                                     returned_value_type);
-
   if(    (use_static_call() && is_literal(name.field))
       || (name.field && name.field->type == FldPointer) )
     {
diff --git a/gcc/cobol/gengen.h b/gcc/cobol/gengen.h
index bc10f7e39b82ecabee12db52fd9929efe9c954a5..9a19d237f2511001ea9cff184b26ee3a0f50273b 100644
--- a/gcc/cobol/gengen.h
+++ b/gcc/cobol/gengen.h
@@ -232,7 +232,6 @@ struct gg_function_t
     // decremented and a return is created.  When the counter is 1, the
     // EXIT program is treated as a CONTINUE.
     tree called_by_main_counter;
-
     };
 
 struct cbl_translation_unit_t