+ m_objfile->per_bfd->minimal_symbol_count = mcount;
+ m_objfile->per_bfd->msymbols = std::move (msym_holder);
+
+#if CXX_STD_THREAD
+ /* Mutex that is used when modifying or accessing the demangled
+ hash table. */
+ std::mutex demangled_mutex;
+#endif
+
+ std::vector<computed_hash_values> hash_values (mcount);
+
+ msymbols = m_objfile->per_bfd->msymbols.get ();
+ gdb::parallel_for_each
+ (&msymbols[0], &msymbols[mcount],
+ [&] (minimal_symbol *start, minimal_symbol *end)
+ {
+ for (minimal_symbol *msym = start; msym < end; ++msym)
+ {
+ size_t idx = msym - msymbols;
+ hash_values[idx].name_length = strlen (msym->linkage_name ());
+ if (!msym->name_set)
+ {
+ /* This will be freed later, by compute_and_set_names. */
+ char *demangled_name
+ = symbol_find_demangled_name (msym, msym->linkage_name ());
+ symbol_set_demangled_name
+ (msym, demangled_name,
+ &m_objfile->per_bfd->storage_obstack);
+ msym->name_set = 1;
+ }
+ /* This mangled_name_hash computation has to be outside of
+ the name_set check, or compute_and_set_names below will
+ be called with an invalid hash value. */
+ hash_values[idx].mangled_name_hash
+ = fast_hash (msym->linkage_name (),
+ hash_values[idx].name_length);
+ hash_values[idx].minsym_hash
+ = msymbol_hash (msym->linkage_name ());
+ /* We only use this hash code if the search name differs
+ from the linkage name. See the code in
+ build_minimal_symbol_hash_tables. */
+ if (msym->search_name () != msym->linkage_name ())
+ hash_values[idx].minsym_demangled_hash
+ = search_name_hash (msym->language (), msym->search_name ());
+ }
+ {
+ /* To limit how long we hold the lock, we only acquire it here
+ and not while we demangle the names above. */
+#if CXX_STD_THREAD
+ std::lock_guard<std::mutex> guard (demangled_mutex);
+#endif
+ for (minimal_symbol *msym = start; msym < end; ++msym)
+ {
+ size_t idx = msym - msymbols;
+ msym->compute_and_set_names
+ (gdb::string_view (msym->linkage_name (),
+ hash_values[idx].name_length),
+ false,
+ m_objfile->per_bfd,
+ hash_values[idx].mangled_name_hash);
+ }
+ }
+ });
+
+ build_minimal_symbol_hash_tables (m_objfile, hash_values);