gcc-4.5 build fixes
[binutils-gdb.git] / gas / ecoff.c
index 8f884bb0042b017710a01927f16fcb840ef2d885..1c01911f55cb3e3d866fb77fce640267c737acb8 100644 (file)
@@ -1,5 +1,5 @@
 /* ECOFF debugging support.
-   Copyright (C) 1993-2020 Free Software Foundation, Inc.
+   Copyright (C) 1993-2023 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    This file was put together by Ian Lance Taylor <ian@cygnus.com>.  A
    good deal of it comes directly from mips-tfile.c, by Michael
@@ -1578,7 +1578,8 @@ add_string (varray_t *vp,                 /* string obstack */
 
       strcpy (hash_ptr->string, str);
 
-      str_hash_insert (hash_tbl, str, (char *) hash_ptr);
+      if (str_hash_insert (hash_tbl, str, hash_ptr, 0) != NULL)
+       as_fatal (_("duplicate %s"), str);
     }
 
   if (ret_hash != (shash_t **) NULL)
@@ -1849,7 +1850,6 @@ add_aux_sym_tir (type_info_t *t,  /* current type information */
 {
   varray_t *vp;
   aux_t *aux_ptr;
-  static AUXU init_aux;
   symint_t ret;
   int i;
   AUXU aux;
@@ -1859,7 +1859,7 @@ add_aux_sym_tir (type_info_t *t,  /* current type information */
 
   vp = &cur_file_ptr->aux_syms;
 
-  aux = init_aux;
+  memset (&aux, 0, sizeof (aux));
   aux.ti.bt = (int) t->basic_type;
   aux.ti.continued = 0;
   aux.ti.fBitfield = t->bitfield;
@@ -2030,7 +2030,7 @@ get_tag (const char *tag, /* tag name */
 
       perm = xstrdup (tag);
       hash_ptr = allocate_shash ();
-      str_hash_insert (tag_hash, perm, (char *) hash_ptr);
+      str_hash_insert (tag_hash, perm, hash_ptr, 0);
       hash_ptr->string = perm;
     }
 
@@ -2311,7 +2311,7 @@ add_file (const char *file_name, int indx ATTRIBUTE_UNUSED, int fake)
    compiler output, only in hand coded assembler.  */
 
 void
-ecoff_new_file (const char *name, int appfile ATTRIBUTE_UNUSED)
+ecoff_new_file (const char *name)
 {
   if (cur_file_ptr != NULL && filename_cmp (cur_file_ptr->name, name) == 0)
     return;
@@ -3550,6 +3550,13 @@ ecoff_stab (segT sec ATTRIBUTE_UNUSED,
   cur_file_ptr = save_file_ptr;
 }
 \f
+static asection ecoff_scom_section;
+static const asymbol ecoff_scom_symbol =
+  GLOBAL_SYM_INIT (SCOMMON, &ecoff_scom_section);
+static asection ecoff_scom_section =
+  BFD_FAKE_SECTION (ecoff_scom_section, &ecoff_scom_symbol,
+                   SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
+
 /* Frob an ECOFF symbol.  Small common symbols go into a special
    .scommon section rather than bfd_com_section.  */
 
@@ -3560,23 +3567,7 @@ ecoff_frob_symbol (symbolS *sym)
       && S_GET_VALUE (sym) > 0
       && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
     {
-      static asection scom_section;
-      static asymbol scom_symbol;
-
-      /* We must construct a fake section similar to bfd_com_section
-         but with the name .scommon.  */
-      if (scom_section.name == NULL)
-       {
-         scom_section = *bfd_com_section_ptr;
-         scom_section.name = ".scommon";
-         scom_section.output_section = &scom_section;
-         scom_section.symbol = &scom_symbol;
-         scom_section.symbol_ptr_ptr = &scom_section.symbol;
-         scom_symbol = *bfd_com_section_ptr->symbol;
-         scom_symbol.name = ".scommon";
-         scom_symbol.section = &scom_section;
-       }
-      S_SET_SEGMENT (sym, &scom_section);
+      S_SET_SEGMENT (sym, &ecoff_scom_section);
     }
 
   /* Double check weak symbols.  */
@@ -4816,7 +4807,6 @@ static scope_t *
 allocate_scope (void)
 {
   scope_t *ptr;
-  static scope_t initial_scope;
 
 #ifndef MALLOC_CHECK
 
@@ -4846,7 +4836,7 @@ allocate_scope (void)
 #endif
 
   alloc_counts[(int) alloc_type_scope].total_alloc++;
-  *ptr = initial_scope;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }
 
@@ -4871,7 +4861,6 @@ static vlinks_t *
 allocate_vlinks (void)
 {
   vlinks_t *ptr;
-  static vlinks_t initial_vlinks;
 
 #ifndef MALLOC_CHECK
 
@@ -4895,7 +4884,7 @@ allocate_vlinks (void)
 #endif
 
   alloc_counts[(int) alloc_type_vlinks].total_alloc++;
-  *ptr = initial_vlinks;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }
 \f
@@ -4905,7 +4894,6 @@ static shash_t *
 allocate_shash (void)
 {
   shash_t *ptr;
-  static shash_t initial_shash;
 
 #ifndef MALLOC_CHECK
 
@@ -4929,7 +4917,7 @@ allocate_shash (void)
 #endif
 
   alloc_counts[(int) alloc_type_shash].total_alloc++;
-  *ptr = initial_shash;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }
 \f
@@ -4939,7 +4927,6 @@ static thash_t *
 allocate_thash (void)
 {
   thash_t *ptr;
-  static thash_t initial_thash;
 
 #ifndef MALLOC_CHECK
 
@@ -4963,7 +4950,7 @@ allocate_thash (void)
 #endif
 
   alloc_counts[(int) alloc_type_thash].total_alloc++;
-  *ptr = initial_thash;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }
 \f
@@ -4973,7 +4960,6 @@ static tag_t *
 allocate_tag (void)
 {
   tag_t *ptr;
-  static tag_t initial_tag;
 
 #ifndef MALLOC_CHECK
 
@@ -5003,7 +4989,7 @@ allocate_tag (void)
 #endif
 
   alloc_counts[(int) alloc_type_tag].total_alloc++;
-  *ptr = initial_tag;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }
 
@@ -5028,7 +5014,6 @@ static forward_t *
 allocate_forward (void)
 {
   forward_t *ptr;
-  static forward_t initial_forward;
 
 #ifndef MALLOC_CHECK
 
@@ -5052,7 +5037,7 @@ allocate_forward (void)
 #endif
 
   alloc_counts[(int) alloc_type_forward].total_alloc++;
-  *ptr = initial_forward;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }
 \f
@@ -5062,7 +5047,6 @@ static thead_t *
 allocate_thead (void)
 {
   thead_t *ptr;
-  static thead_t initial_thead;
 
 #ifndef MALLOC_CHECK
 
@@ -5092,7 +5076,7 @@ allocate_thead (void)
 #endif
 
   alloc_counts[(int) alloc_type_thead].total_alloc++;
-  *ptr = initial_thead;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }
 
@@ -5115,7 +5099,6 @@ static lineno_list_t *
 allocate_lineno_list (void)
 {
   lineno_list_t *ptr;
-  static lineno_list_t initial_lineno_list;
 
 #ifndef MALLOC_CHECK
 
@@ -5139,7 +5122,7 @@ allocate_lineno_list (void)
 #endif
 
   alloc_counts[(int) alloc_type_lineno].total_alloc++;
-  *ptr = initial_lineno_list;
+  memset (ptr, 0, sizeof (*ptr));
   return ptr;
 }