Index: symtab.c =================================================================== --- symtab.c (revision 94) +++ symtab.c (revision 97) @@ -577,8 +577,27 @@ symbol_set_names (struct general_symbol_ (*slot)[lookup_len + 1] = '\0'; } + /* Set the name and demangled_name. + + For Ada symbols, the demangled_name does not apply and should + be NULL (see how symbol_find_demangled_name always return NULL + for Ada symbols). + + Unfortunately, there is a case that we have to watch out for: + During the symbol table processing, when creating the minimal + symbols, we don't know the language associated to each entry. + As a result, symbol_find_demangled_name tries various non-Ada + demanglers, and sometimes, a demangler accepts the symbol and + returns an unexpected demangled form of our symbol name. This + has consequences during the debugging info processing: This time, + we do know the language, but since we have already found an entry + in the demangled_name_hash using the linkage name, we use the + demangled name stored in the hash instead of trying to recompute it. + + To guard against this case, we add an explicit check against + Ada symbols before setting the symbol demangled_name. */ gsymbol->name = *slot + lookup_len - len; - if ((*slot)[lookup_len + 1] != '\0') + if (gsymbol->language != language_ada && (*slot)[lookup_len + 1] != '\0') gsymbol->language_specific.cplus_specific.demangled_name = &(*slot)[lookup_len + 1]; else