[PATCH] D94669: [llvm-nm] - Simplify the code in dumpSymbolNamesFromObject. NFC.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 14 03:52:01 PST 2021
grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added a subscriber: rupprecht.
grimar requested review of this revision.
Herald added a project: LLVM.
It is possible to simplify the logic that extracts symbol names.
Depends on D94667 <https://reviews.llvm.org/D94667>.
It made the `NMSymbol::Name` to be `std::string`, what allowed this simplification.
https://reviews.llvm.org/D94669
Files:
llvm/tools/llvm-nm/llvm-nm.cpp
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).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94669.316613.patch
Type: text/x-patch
Size: 1374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210114/424098be/attachment.bin>
More information about the llvm-commits
mailing list