Index: llvm/tools/llvm-nm/llvm-nm.cpp =================================================================== --- llvm/tools/llvm-nm/llvm-nm.cpp +++ llvm/tools/llvm-nm/llvm-nm.cpp @@ -1698,8 +1698,7 @@ } Symbols = E->getDynamicSymbolIterators(); } - std::string NameBuffer; - raw_string_ostream OS(NameBuffer); + // If a "-s segname sectname" option was specified and this is a Mach-O // file get the section number for that section in this object file. unsigned int Nsect = 0; @@ -1742,6 +1741,8 @@ } S.TypeName = getNMTypeName(Obj, Sym); S.TypeChar = getNMSectionTagAndName(Obj, Sym, S.SectionName); + + raw_string_ostream OS(S.Name); if (Error E = Sym.printName(OS)) { if (MachO) { OS << "bad string index"; @@ -1749,20 +1750,11 @@ } else error(std::move(E), Obj.getFileName()); } - OS << '\0'; S.Sym = Sym; SymbolList.push_back(S); } } - OS.flush(); - const char *P = NameBuffer.c_str(); - unsigned I; - for (I = 0; I < SymbolList.size(); ++I) { - SymbolList[I].Name = P; - P += strlen(P) + 1; - } - // If this is a Mach-O file where the nlist symbol table is out of sync // with the dyld export trie then look through exports and fake up symbols // for the ones that are missing (also done with the -add-dyldinfo flag).