When sorting by address, undefined symbols go first.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 6 Jul 2015 19:21:04 +0000 (19:21 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 6 Jul 2015 19:21:04 +0000 (19:21 +0000)
This matches gnu nm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241488 91177308-0d34-0410-b5e6-96231b3b80d8

test/Object/coff-archive.test
tools/llvm-nm/llvm-nm.cpp

index 239a96b..5d0b844 100644 (file)
@@ -66,7 +66,24 @@ CHECKIDX: 00000000 N .debug$T
 CHECKIDX: 00000000 i .drectve
 CHECKIDX: 00000001 a @feat.00
 CHECKIDX: 00ab9d1b a @comp.id
+
 CHECKIDX: Debug\mymath.obj:
+CHECKIDX:          U ??2@YAPAXI@Z
+CHECKIDX:          U ??3@YAXPAX@Z
+CHECKIDX:          U ??_7type_info@@6B@
+CHECKIDX:          U ??_Ginvalid_argument@std@@UAEPAXI@Z
+CHECKIDX:          U ??_Glogic_error@std@@UAEPAXI@Z
+CHECKIDX:          U ?what@exception@std@@UBEPBDXZ
+CHECKIDX:          U @__security_check_cookie@4
+CHECKIDX:          U __CxxThrowException@8
+CHECKIDX:          U __RTC_CheckEsp
+CHECKIDX:          U __RTC_InitBase
+CHECKIDX:          U __RTC_Shutdown
+CHECKIDX:          U ___CxxFrameHandler3
+CHECKIDX:          U ___security_cookie
+CHECKIDX:          U __fltused
+CHECKIDX:          U __imp_??0exception@std@@QAE@ABQBD@Z
+CHECKIDX:          U __imp_??1exception@std@@UAE@XZ
 CHECKIDX: 00000000 d .data
 CHECKIDX: 00000000 d .data
 CHECKIDX: 00000000 d .data
@@ -205,21 +222,5 @@ CHECKIDX: 00000004 R ??_7logic_error@std@@6B@
 CHECKIDX: 00000008 r __ehfuncinfo$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
 CHECKIDX: 0000000e t __ehhandler$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
 CHECKIDX: 00ab9d1b a @comp.id
-CHECKIDX:          U ??2@YAPAXI@Z
-CHECKIDX:          U ??3@YAXPAX@Z
-CHECKIDX:          U ??_7type_info@@6B@
 CHECKIDX:          w ??_Einvalid_argument@std@@UAEPAXI@Z
 CHECKIDX:          w ??_Elogic_error@std@@UAEPAXI@Z
-CHECKIDX:          U ??_Ginvalid_argument@std@@UAEPAXI@Z
-CHECKIDX:          U ??_Glogic_error@std@@UAEPAXI@Z
-CHECKIDX:          U ?what@exception@std@@UBEPBDXZ
-CHECKIDX:          U @__security_check_cookie@4
-CHECKIDX:          U __CxxThrowException@8
-CHECKIDX:          U __RTC_CheckEsp
-CHECKIDX:          U __RTC_InitBase
-CHECKIDX:          U __RTC_Shutdown
-CHECKIDX:          U ___CxxFrameHandler3
-CHECKIDX:          U ___security_cookie
-CHECKIDX:          U __fltused
-CHECKIDX:          U __imp_??0exception@std@@QAE@ABQBD@Z
-CHECKIDX:          U __imp_??1exception@std@@UAE@XZ
index 961754c..c30d628 100644 (file)
@@ -185,6 +185,10 @@ struct NMSymbol {
 }
 
 static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) {
+  if (A.TypeChar == 'U' && B.TypeChar != 'U')
+    return true;
+  if (A.TypeChar != 'U' && B.TypeChar == 'U')
+    return false;
   if (A.Address < B.Address)
     return true;
   if (A.Address == B.Address && A.Name < B.Name)