summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-nm/llvm-nm.cpp
diff options
context:
space:
mode:
authorHemant Kulkarni <khemant@codeaurora.org>2016-02-10 17:51:39 +0000
committerHemant Kulkarni <khemant@codeaurora.org>2016-02-10 17:51:39 +0000
commit5e005a110862db0ad974862593d6e9541ce8cf8e (patch)
tree24e08e0d5a6d201f0cfb34f4feb728c524d4e970 /llvm/tools/llvm-nm/llvm-nm.cpp
parent4f2ca0d268a10b477f3b0dcb7438b1a204266f50 (diff)
downloadbcm5719-llvm-5e005a110862db0ad974862593d6e9541ce8cf8e.tar.gz
bcm5719-llvm-5e005a110862db0ad974862593d6e9541ce8cf8e.zip
[llvm-nm] Add -radix option
Differential Revision: http://reviews.llvm.org/D16822 llvm-svn: 260392
Diffstat (limited to 'llvm/tools/llvm-nm/llvm-nm.cpp')
-rw-r--r--llvm/tools/llvm-nm/llvm-nm.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 6d30e65e90e..5de4020d39e 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -138,6 +138,15 @@ cl::opt<bool> ArchiveMap("print-armap", cl::desc("Print the archive map"));
cl::alias ArchiveMaps("M", cl::desc("Alias for --print-armap"),
cl::aliasopt(ArchiveMap), cl::Grouping);
+enum Radix { d, o, x };
+cl::opt<Radix>
+ AddressRadix("radix", cl::desc("Radix (o/d/x) for printing symbol Values"),
+ cl::values(clEnumVal(d, "decimal"), clEnumVal(o, "octal"),
+ clEnumVal(x, "hexadecimal"), clEnumValEnd),
+ cl::init(x));
+cl::alias RadixAlias("t", cl::desc("Alias for --radix"),
+ cl::aliasopt(AddressRadix));
+
cl::opt<bool> JustSymbolName("just-symbol-name",
cl::desc("Print just the symbol's name"));
cl::alias JustSymbolNames("j", cl::desc("Alias for --just-symbol-name"),
@@ -572,11 +581,29 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
if (isSymbolList64Bit(Obj)) {
printBlanks = " ";
printDashes = "----------------";
- printFormat = "%016" PRIx64;
+ switch (AddressRadix) {
+ case Radix::o:
+ printFormat = "%016" PRIo64;
+ break;
+ case Radix::x:
+ printFormat = "%016" PRIx64;
+ break;
+ default:
+ printFormat = "%016" PRId64;
+ }
} else {
printBlanks = " ";
printDashes = "--------";
- printFormat = "%08" PRIx64;
+ switch (AddressRadix) {
+ case Radix::o:
+ printFormat = "%08" PRIo64;
+ break;
+ case Radix::x:
+ printFormat = "%08" PRIx64;
+ break;
+ default:
+ printFormat = "%08" PRId64;
+ }
}
for (SymbolListT::iterator I = SymbolList.begin(), E = SymbolList.end();
@@ -943,7 +970,7 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
std::error_code EC = Sym.printName(OS);
if (EC && MachO)
OS << "bad string index";
- else
+ else
error(EC);
OS << '\0';
S.Sym = Sym;
OpenPOWER on IntegriCloud