Fail of x86_64 AMX-COMPLEX insns (Intel disassembly)
[binutils-gdb.git] / gas / ecoff.c
index 608d72b7e0d496cc7504300e0a2f55d112df65de..1c01911f55cb3e3d866fb77fce640267c737acb8 100644 (file)
@@ -1,5 +1,5 @@
 /* ECOFF debugging support.
-   Copyright (C) 1993-2017 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
     #26             48  0x00000030  struct no name { ifd = -1, index = 1048575 }
 */
 \f
-/* Redefinition of of storage classes as an enumeration for better
+/* Redefinition of storage classes as an enumeration for better
    debugging.  */
 
 typedef enum sc {
@@ -946,7 +946,7 @@ typedef struct efdr {
   varray_t      aux_syms;      /* auxiliary symbols */
   struct efdr  *next_file;     /* next file descriptor */
                                /* string/type hash tables */
-  struct hash_control *str_hash;       /* string hash table */
+  htab_t       str_hash;       /* string hash table */
   thash_t      *thash_head[THASH_SIZE];
 } efdr_t;
 
@@ -994,7 +994,7 @@ static const efdr_t init_file = {
 
   (struct efdr *)0,    /* next_file:   next file structure */
 
-  (struct hash_control *)0,    /* str_hash:    string hash table */
+  (htab_t)0,           /* str_hash:    string hash table */
   { 0 },               /* thash_head:  type hash table */
 };
 
@@ -1111,7 +1111,7 @@ static const type_info_t type_info_init = {
 
 static varray_t file_desc = INIT_VARRAY (efdr_t);
 
-static struct hash_control *tag_hash;
+static htab_t tag_hash;
 
 /* Static types for int and void.  Also, remember the last function's
    type (which is set up when we encounter the declaration for the
@@ -1408,7 +1408,7 @@ static char stabs_symbol[] = STABS_SYMBOL;
 
 static void add_varray_page (varray_t *vp);
 static symint_t add_string (varray_t *vp,
-                           struct hash_control *hash_tbl,
+                           htab_t hash_tbl,
                            const char *str,
                            shash_t **ret_hash);
 static localsym_t *add_ecoff_symbol (const char *str, st_t type,
@@ -1475,7 +1475,7 @@ static lineno_list_t *allocate_lineno_list (void);
 void
 ecoff_read_begin_hook (void)
 {
-  tag_hash = hash_new ();
+  tag_hash = str_htab_create ();
   top_tag_head = allocate_thead ();
   top_tag_head->first_tag = (tag_t *) NULL;
   top_tag_head->free = (thead_t *) NULL;
@@ -1548,7 +1548,7 @@ add_varray_page (varray_t *vp /* varray to add page to */)
 
 static symint_t
 add_string (varray_t *vp,                      /* string obstack */
-           struct hash_control *hash_tbl,      /* ptr to hash table */
+           htab_t hash_tbl,                    /* ptr to hash table */
            const char *str,                    /* string */
            shash_t **ret_hash                  /* return hash pointer */)
 {
@@ -1558,11 +1558,9 @@ add_string (varray_t *vp,                        /* string obstack */
   if (len >= PAGE_USIZE)
     as_fatal (_("string too big (%lu bytes)"), len);
 
-  hash_ptr = (shash_t *) hash_find (hash_tbl, str);
+  hash_ptr = (shash_t *) str_hash_find (hash_tbl, str);
   if (hash_ptr == (shash_t *) NULL)
     {
-      const char *err;
-
       if (vp->objects_last_page + len >= PAGE_USIZE)
        {
          vp->num_allocated =
@@ -1580,10 +1578,8 @@ add_string (varray_t *vp,                        /* string obstack */
 
       strcpy (hash_ptr->string, str);
 
-      err = hash_insert (hash_tbl, str, (char *) hash_ptr);
-      if (err)
-       as_fatal (_("inserting \"%s\" into string hash table: %s"),
-                 str, err);
+      if (str_hash_insert (hash_tbl, str, hash_ptr, 0) != NULL)
+       as_fatal (_("duplicate %s"), str);
     }
 
   if (ret_hash != (shash_t **) NULL)
@@ -1854,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;
@@ -1864,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;
@@ -2009,13 +2004,12 @@ get_tag (const char *tag,       /* tag name */
         bt_t basic_type        /* bt_Struct, bt_Union, or bt_Enum */)
 {
   shash_t *hash_ptr;
-  const char *err;
   tag_t *tag_ptr;
 
   if (cur_file_ptr == (efdr_t *) NULL)
     as_fatal (_("no current file pointer"));
 
-  hash_ptr = (shash_t *) hash_find (tag_hash, tag);
+  hash_ptr = (shash_t *) str_hash_find (tag_hash, tag);
 
   if (hash_ptr != (shash_t *) NULL
       && hash_ptr->tag_ptr != (tag_t *) NULL)
@@ -2036,10 +2030,7 @@ get_tag (const char *tag,        /* tag name */
 
       perm = xstrdup (tag);
       hash_ptr = allocate_shash ();
-      err = hash_insert (tag_hash, perm, (char *) hash_ptr);
-      if (err)
-       as_fatal (_("inserting \"%s\" into tag hash table: %s"),
-                 tag, err);
+      str_hash_insert (tag_hash, perm, hash_ptr, 0);
       hash_ptr->string = perm;
     }
 
@@ -2227,9 +2218,8 @@ add_file (const char *file_name, int indx ATTRIBUTE_UNUSED, int fake)
   if (stabs_seen)
     {
       (void) add_ecoff_symbol (file_name, st_Nil, sc_Nil,
-                              symbol_new ("L0\001", now_seg,
-                                          (valueT) frag_now_fix (),
-                                          frag_now),
+                              symbol_new (FAKE_LABEL_NAME, now_seg,
+                                          frag_now, frag_now_fix ()),
                               (bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SOL));
       return;
     }
@@ -2281,7 +2271,7 @@ add_file (const char *file_name, int indx ATTRIBUTE_UNUSED, int fake)
       fil_ptr->fake = fake;
 
       /* Allocate the string hash table.  */
-      fil_ptr->str_hash = hash_new ();
+      fil_ptr->str_hash = str_htab_create ();
 
       /* Make sure 0 byte in string table is null  */
       add_string (&fil_ptr->strings,
@@ -2321,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;
@@ -2526,10 +2516,8 @@ ecoff_directive_def (int ignore ATTRIBUTE_UNUSED)
     as_warn (_("empty symbol name in .def; ignored"));
   else
     {
-      if (coff_sym_name != (char *) NULL)
-       free (coff_sym_name);
-      if (coff_tag != (char *) NULL)
-       free (coff_tag);
+      free (coff_sym_name);
+      free (coff_tag);
 
       coff_sym_name = xstrdup (name);
       coff_type = type_info_init;
@@ -3020,9 +3008,8 @@ ecoff_directive_end (int ignore ATTRIBUTE_UNUSED)
     as_warn (_(".end directive names unknown symbol"));
   else
     (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
-                            symbol_new ("L0\001", now_seg,
-                                        (valueT) frag_now_fix (),
-                                        frag_now),
+                            symbol_new (FAKE_LABEL_NAME, now_seg,
+                                        frag_now, frag_now_fix ()),
                             (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
 
 #ifdef md_flush_pending_output
@@ -3264,9 +3251,8 @@ ecoff_directive_loc (int ignore ATTRIBUTE_UNUSED)
   if (stabs_seen)
     {
       (void) add_ecoff_symbol ((char *) NULL, st_Label, sc_Text,
-                              symbol_new ("L0\001", now_seg,
-                                          (valueT) frag_now_fix (),
-                                          frag_now),
+                              symbol_new (FAKE_LABEL_NAME, now_seg,
+                                          frag_now, frag_now_fix ()),
                               (bfd_vma) 0, 0, lineno);
       return;
     }
@@ -3564,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.  */
 
@@ -3574,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.  */
@@ -3700,8 +3677,7 @@ ecoff_build_lineno (const struct ecoff_debug_swap *backend,
       && first_proc_ptr != (proc_t *) NULL
       && local_first_lineno != (lineno_list_t *) NULL
       && ((S_GET_VALUE (first_proc_ptr->sym->as_sym)
-          + bfd_get_section_vma (stdoutput,
-                                 S_GET_SEGMENT (first_proc_ptr->sym->as_sym)))
+          + bfd_section_vma (S_GET_SEGMENT (first_proc_ptr->sym->as_sym)))
          != 0))
     {
       first.file = local_first_lineno->file;
@@ -3981,8 +3957,7 @@ ecoff_build_symbols (const struct ecoff_debug_swap *backend,
                      else
                        sym_ptr->ecoff_sym.asym.value =
                          (S_GET_VALUE (as_sym)
-                          + bfd_get_section_vma (stdoutput,
-                                                 S_GET_SEGMENT (as_sym))
+                          + bfd_section_vma (S_GET_SEGMENT (as_sym))
                           + sym_ptr->addend);
 
                      sym_ptr->ecoff_sym.weakext = S_IS_WEAK (as_sym);
@@ -4104,10 +4079,10 @@ ecoff_build_symbols (const struct ecoff_debug_swap *backend,
                      /* If an st_end symbol has an associated gas
                         symbol, then it is a local label created for
                         a .bend or .end directive.  Stabs line
-                        numbers will have \001 in the names.  */
+                        numbers will have FAKE_LABEL_CHAR in the names.  */
                      if (local
                          && sym_ptr->ecoff_sym.asym.st != st_End
-                         && strchr (sym_ptr->name, '\001') == 0)
+                         && strchr (sym_ptr->name, FAKE_LABEL_CHAR) == 0)
                        sym_ptr->ecoff_sym.asym.iss =
                          add_string (&fil_ptr->strings,
                                      fil_ptr->str_hash,
@@ -4310,8 +4285,7 @@ ecoff_build_procs (const struct ecoff_debug_swap *backend,
 
                  adr_sym = proc_ptr->sym->as_sym;
                  adr = (S_GET_VALUE (adr_sym)
-                        + bfd_get_section_vma (stdoutput,
-                                               S_GET_SEGMENT (adr_sym)));
+                        + bfd_section_vma (S_GET_SEGMENT (adr_sym)));
                  if (first)
                    {
                      /* This code used to force the adr of the very
@@ -4833,7 +4807,6 @@ static scope_t *
 allocate_scope (void)
 {
   scope_t *ptr;
-  static scope_t initial_scope;
 
 #ifndef MALLOC_CHECK
 
@@ -4863,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;
 }
 
@@ -4888,7 +4861,6 @@ static vlinks_t *
 allocate_vlinks (void)
 {
   vlinks_t *ptr;
-  static vlinks_t initial_vlinks;
 
 #ifndef MALLOC_CHECK
 
@@ -4912,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
@@ -4922,7 +4894,6 @@ static shash_t *
 allocate_shash (void)
 {
   shash_t *ptr;
-  static shash_t initial_shash;
 
 #ifndef MALLOC_CHECK
 
@@ -4946,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
@@ -4956,7 +4927,6 @@ static thash_t *
 allocate_thash (void)
 {
   thash_t *ptr;
-  static thash_t initial_thash;
 
 #ifndef MALLOC_CHECK
 
@@ -4980,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
@@ -4990,7 +4960,6 @@ static tag_t *
 allocate_tag (void)
 {
   tag_t *ptr;
-  static tag_t initial_tag;
 
 #ifndef MALLOC_CHECK
 
@@ -5020,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;
 }
 
@@ -5045,7 +5014,6 @@ static forward_t *
 allocate_forward (void)
 {
   forward_t *ptr;
-  static forward_t initial_forward;
 
 #ifndef MALLOC_CHECK
 
@@ -5069,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
@@ -5079,7 +5047,6 @@ static thead_t *
 allocate_thead (void)
 {
   thead_t *ptr;
-  static thead_t initial_thead;
 
 #ifndef MALLOC_CHECK
 
@@ -5109,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;
 }
 
@@ -5132,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
 
@@ -5156,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;
 }