From 14ae43449c7038afa8dced4f5cb054b243b67d76 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 3 Apr 2014 00:19:35 +0000 Subject: Revert "Fix a nomenclature error in llvm-nm." This reverts commit r205479. It turns out that nm does use addresses, it is just that every reasonable relocatable ELF object has sections with address 0. I have no idea if those exist in reality, but it at least it shows that llvm-nm should use the name address. The added test was includes an unusual .o file with non 0 section addresses. I created it by hacking ELFObjectWriter.cpp. Really sorry for the churn. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205493 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-nm/llvm-nm.cpp | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'tools') diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index a4601b611d..22e019a8a5 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -95,7 +95,7 @@ cl::opt DebugSyms("debug-syms", cl::alias DebugSymsa("a", cl::desc("Alias for --debug-syms"), cl::aliasopt(DebugSyms)); -cl::opt NumericSort("numeric-sort", cl::desc("Sort symbols by value")); +cl::opt NumericSort("numeric-sort", cl::desc("Sort symbols by address")); cl::alias NumericSortn("n", cl::desc("Alias for --numeric-sort"), cl::aliasopt(NumericSort)); cl::alias NumericSortv("v", cl::desc("Alias for --numeric-sort"), @@ -105,7 +105,7 @@ cl::opt NoSort("no-sort", cl::desc("Show symbols in order encountered")); cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort)); cl::opt PrintSize("print-size", - cl::desc("Show symbol size instead of value")); + cl::desc("Show symbol size instead of address")); cl::alias PrintSizeS("S", cl::desc("Alias for --print-size"), cl::aliasopt(PrintSize)); @@ -117,7 +117,7 @@ cl::opt WithoutAliases("without-aliases", cl::Hidden, cl::opt ArchiveMap("print-armap", cl::desc("Print the archive map")); cl::alias ArchiveMaps("s", cl::desc("Alias for --print-armap"), cl::aliasopt(ArchiveMap)); -bool PrintValue = true; +bool PrintAddress = true; bool MultipleFiles = false; @@ -141,19 +141,19 @@ static bool error(error_code EC, Twine Path = Twine()) { namespace { struct NMSymbol { - uint64_t Value; + uint64_t Address; uint64_t Size; char TypeChar; StringRef Name; }; } -static bool compareSymbolValue(const NMSymbol &A, const NMSymbol &B) { - if (A.Value < B.Value) +static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) { + if (A.Address < B.Address) return true; - else if (A.Value == B.Value && A.Name < B.Name) + else if (A.Address == B.Address && A.Name < B.Name) return true; - else if (A.Value == B.Value && A.Name == B.Name && A.Size < B.Size) + else if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size) return true; else return false; @@ -164,7 +164,7 @@ static bool compareSymbolSize(const NMSymbol &A, const NMSymbol &B) { return true; else if (A.Size == B.Size && A.Name < B.Name) return true; - else if (A.Size == B.Size && A.Name == B.Name && A.Value < B.Value) + else if (A.Size == B.Size && A.Name == B.Name && A.Address < B.Address) return true; else return false; @@ -175,7 +175,7 @@ static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) { return true; else if (A.Name == B.Name && A.Size < B.Size) return true; - else if (A.Name == B.Name && A.Size == B.Size && A.Value < B.Value) + else if (A.Name == B.Name && A.Size == B.Size && A.Address < B.Address) return true; else return false; @@ -188,7 +188,7 @@ static SymbolListT SymbolList; static void sortAndPrintSymbolList() { if (!NoSort) { if (NumericSort) - std::sort(SymbolList.begin(), SymbolList.end(), compareSymbolValue); + std::sort(SymbolList.begin(), SymbolList.end(), compareSymbolAddress); else if (SizeSort) std::sort(SymbolList.begin(), SymbolList.end(), compareSymbolSize); else @@ -211,29 +211,29 @@ static void sortAndPrintSymbolList() { continue; if ((I->TypeChar == 'U') && DefinedOnly) continue; - if (SizeSort && !PrintValue && I->Size == UnknownAddressOrSize) + if (SizeSort && !PrintAddress && I->Size == UnknownAddressOrSize) continue; - char SymbolValueStr[10] = ""; + char SymbolAddrStr[10] = ""; char SymbolSizeStr[10] = ""; - if (OutputFormat == sysv || I->Value == UnknownAddressOrSize) - strcpy(SymbolValueStr, " "); + if (OutputFormat == sysv || I->Address == UnknownAddressOrSize) + strcpy(SymbolAddrStr, " "); if (OutputFormat == sysv) strcpy(SymbolSizeStr, " "); - if (I->Value != UnknownAddressOrSize) - format("%08" PRIx64, I->Value) - .print(SymbolValueStr, sizeof(SymbolValueStr)); + if (I->Address != UnknownAddressOrSize) + format("%08" PRIx64, I->Address) + .print(SymbolAddrStr, sizeof(SymbolAddrStr)); if (I->Size != UnknownAddressOrSize) format("%08" PRIx64, I->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr)); if (OutputFormat == posix) { - outs() << I->Name << " " << I->TypeChar << " " << SymbolValueStr + outs() << I->Name << " " << I->TypeChar << " " << SymbolAddrStr << SymbolSizeStr << "\n"; } else if (OutputFormat == bsd) { - if (PrintValue) - outs() << SymbolValueStr << ' '; + if (PrintAddress) + outs() << SymbolAddrStr << ' '; if (PrintSize) { outs() << SymbolSizeStr; if (I->Size != UnknownAddressOrSize) @@ -244,7 +244,7 @@ static void sortAndPrintSymbolList() { std::string PaddedName(I->Name); while (PaddedName.length() < 20) PaddedName += " "; - outs() << PaddedName << "|" << SymbolValueStr << "| " << I->TypeChar + outs() << PaddedName << "|" << SymbolAddrStr << "| " << I->TypeChar << " | |" << SymbolSizeStr << "| |\n"; } } @@ -490,14 +490,14 @@ static void dumpSymbolNamesFromObject(SymbolicFile *Obj) { } NMSymbol S; S.Size = UnknownAddressOrSize; - S.Value = UnknownAddressOrSize; + S.Address = UnknownAddressOrSize; if ((PrintSize || SizeSort) && isa(Obj)) { symbol_iterator SymI = I; if (error(SymI->getSize(S.Size))) break; } - if (PrintValue && isa(Obj)) - if (error(symbol_iterator(I)->getValue(S.Value))) + if (PrintAddress && isa(Obj)) + if (error(symbol_iterator(I)->getAddress(S.Address))) break; S.TypeChar = getNMTypeChar(Obj, I); if (error(I->printName(OS))) @@ -602,9 +602,9 @@ int main(int argc, char **argv) { // The relative order of these is important. If you pass --size-sort it should // only print out the size. However, if you pass -S --size-sort, it should - // print out both the size and values. + // print out both the size and address. if (SizeSort && !PrintSize) - PrintValue = false; + PrintAddress = false; if (OutputFormat == sysv || SizeSort) PrintSize = true; -- cgit v1.2.3