Fix an abort triggered when objcopy is used to set the "share" section flag on an...
[deliverable/binutils-gdb.git] / binutils / stabs.c
index 807ca1e3c4ab2d59fb65043ae6c4340c3180db50..7cd782d4db6199712fe03fea042b2524720b86b1 100644 (file)
@@ -1,5 +1,5 @@
 /* stabs.c -- Parse stabs debugging information
-   Copyright (C) 1995-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
    This file is part of GNU Binutils.
@@ -215,6 +215,8 @@ static debug_type stab_demangle_v3_arg
   (void *, struct stab_handle *, struct demangle_component *, debug_type,
    bfd_boolean *);
 
+static int demangle_flags = DMGL_ANSI;
+
 /* Save a string in memory.  */
 
 static char *
@@ -449,7 +451,6 @@ parse_stab (void *dhandle, void *handle, int type, int desc, bfd_vma value,
       info->file_types = ((struct stab_types **)
                          xmalloc (sizeof *info->file_types));
       info->file_types[0] = NULL;
-
       info->so_string = NULL;
 
       /* Now process whatever type we just got.  */
@@ -3036,27 +3037,15 @@ parse_stab_argtypes (void *dhandle, struct stab_handle *info,
          && fieldname[1] == 'p'
          && (fieldname[2] == '$' || fieldname[2] == '.'))
        {
-         const char *opname;
-
-         opname = cplus_mangle_opname (fieldname + 3, 0);
-         if (opname == NULL)
-           {
-             fprintf (stderr, _("No mangling for \"%s\"\n"), fieldname);
-             return DEBUG_TYPE_NULL;
-           }
-         mangled_name_len += strlen (opname);
-         physname = (char *) xmalloc (mangled_name_len);
-         strncpy (physname, fieldname, 3);
-         strcpy (physname + 3, opname);
+         /* Opname selection is no longer supported by libiberty's demangler.  */
+         return DEBUG_TYPE_NULL;
        }
+
+      physname = (char *) xmalloc (mangled_name_len);
+      if (is_constructor)
+       physname[0] = '\0';
       else
-       {
-         physname = (char *) xmalloc (mangled_name_len);
-         if (is_constructor)
-           physname[0] = '\0';
-         else
-           strcpy (physname, fieldname);
-       }
+       strcpy (physname, fieldname);
 
       physname_len = strlen (physname);
       strcat (physname, buf);
@@ -3326,6 +3315,9 @@ pop_bincl (struct stab_handle *info)
     return info->main_filename;
   info->bincl_stack = o->next_stack;
 
+  if (o->file >= info->files)
+    return info->main_filename;
+
   o->file_types = info->file_types[o->file];
 
   if (info->bincl_stack == NULL)
@@ -4515,7 +4507,7 @@ stab_demangle_template (struct stab_demangle_info *minfo, const char **pp,
 
       free (s1);
 
-      s3 = cplus_demangle (s2, DMGL_ANSI);
+      s3 = cplus_demangle (s2, demangle_flags);
 
       free (s2);
 
@@ -5241,7 +5233,7 @@ stab_demangle_v3_argtypes (void *dhandle, struct stab_handle *info,
   void *mem;
   debug_type *pargs;
 
-  dc = cplus_demangle_v3_components (physname, DMGL_PARAMS | DMGL_ANSI, &mem);
+  dc = cplus_demangle_v3_components (physname, DMGL_PARAMS | demangle_flags, &mem);
   if (dc == NULL)
     {
       stab_bad_demangle (physname);
@@ -5416,7 +5408,7 @@ stab_demangle_v3_arg (void *dhandle, struct stab_handle *info,
        /* We print this component to get a class name which we can
           use.  FIXME: This probably won't work if the template uses
           template parameters which refer to an outer template.  */
-       p = cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, dc, 20, &alc);
+       p = cplus_demangle_print (DMGL_PARAMS | demangle_flags, dc, 20, &alc);
        if (p == NULL)
          {
            fprintf (stderr, _("Failed to print demangled template\n"));
@@ -5496,7 +5488,7 @@ stab_demangle_v3_arg (void *dhandle, struct stab_handle *info,
        /* We print this component in order to find out the type name.
           FIXME: Should we instead expose the
           demangle_builtin_type_info structure?  */
-       p = cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, dc, 20, &alc);
+       p = cplus_demangle_print (DMGL_PARAMS | demangle_flags, dc, 20, &alc);
        if (p == NULL)
          {
            fprintf (stderr, _("Couldn't get demangled builtin type\n"));
This page took 0.031284 seconds and 4 git commands to generate.