mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
Add the -reverse-sort flag (aka -r) to llvm-nm
which exists in other Unix nm(1)’s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212235 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
be453c5c3d
commit
1faddea960
@ -16,6 +16,8 @@ RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \
|
||||
RUN: | FileCheck %s -check-prefix macho64
|
||||
RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \
|
||||
RUN: | FileCheck %s -check-prefix macho-tdb
|
||||
RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \
|
||||
RUN: | FileCheck %s -check-prefix macho-r
|
||||
RUN: llvm-nm %p/Inputs/common.coff-i386 \
|
||||
RUN: | FileCheck %s -check-prefix COFF-COMMON
|
||||
RUN: llvm-nm %p/Inputs/relocatable-with-section-address.elf-x86-64 \
|
||||
@ -77,6 +79,12 @@ macho-tdb: 000000000000000c D _d
|
||||
macho-tdb: 0000000000000000 T _t
|
||||
macho-tdb: 0000000000000048 S _t.eh
|
||||
|
||||
macho-r: 0000000000000048 S _t.eh
|
||||
macho-r-NEXT: 0000000000000000 T _t
|
||||
macho-r-NEXT: 000000000000000c D _d
|
||||
macho-r-NEXT: 0000000000000070 b _b
|
||||
macho-r-NEXT: 0000000000000030 s EH_frame0
|
||||
|
||||
Test that nm uses addresses even with ELF .o files.
|
||||
ELF-SEC-ADDR64: 0000000000000058 D a
|
||||
ELF-SEC-ADDR64-NEXT: 000000000000005c D b
|
||||
|
@ -111,6 +111,10 @@ cl::alias NumericSortv("v", cl::desc("Alias for --numeric-sort"),
|
||||
cl::opt<bool> 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<bool> ReverseSort("reverse-sort", cl::desc("Sort in reverse order"));
|
||||
cl::alias ReverseSortr("r", cl::desc("Alias for --reverse-sort"),
|
||||
cl::aliasopt(ReverseSort));
|
||||
|
||||
cl::opt<bool> PrintSize("print-size",
|
||||
cl::desc("Show symbol size instead of address"));
|
||||
cl::alias PrintSizeS("S", cl::desc("Alias for --print-size"),
|
||||
@ -157,36 +161,69 @@ struct NMSymbol {
|
||||
}
|
||||
|
||||
static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) {
|
||||
if (A.Address < B.Address)
|
||||
return true;
|
||||
else if (A.Address == B.Address && A.Name < B.Name)
|
||||
return true;
|
||||
else if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
if (!ReverseSort) {
|
||||
if (A.Address < B.Address)
|
||||
return true;
|
||||
else if (A.Address == B.Address && A.Name < B.Name)
|
||||
return true;
|
||||
else if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else {
|
||||
if (A.Address > B.Address)
|
||||
return true;
|
||||
else if (A.Address == B.Address && A.Name > B.Name)
|
||||
return true;
|
||||
else if (A.Address == B.Address && A.Name == B.Name && A.Size > B.Size)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool compareSymbolSize(const NMSymbol &A, const NMSymbol &B) {
|
||||
if (A.Size < B.Size)
|
||||
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.Address < B.Address)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
if (!ReverseSort) {
|
||||
if (A.Size < B.Size)
|
||||
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.Address < B.Address)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else {
|
||||
if (A.Size > B.Size)
|
||||
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.Address > B.Address)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) {
|
||||
if (A.Name < B.Name)
|
||||
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.Address < B.Address)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
if (!ReverseSort) {
|
||||
if (A.Name < B.Name)
|
||||
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.Address < B.Address)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else {
|
||||
if (A.Name > B.Name)
|
||||
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.Address > B.Address)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static char isSymbolList64Bit(SymbolicFile *Obj) {
|
||||
|
Loading…
Reference in New Issue
Block a user