From 40b3496f9ae621250f90b1a107f3ad54b4e8e137 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 6 Jul 2015 19:21:04 +0000 Subject: [PATCH] When sorting by address, undefined symbols go first. 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 | 33 +++++++++++++++++---------------- tools/llvm-nm/llvm-nm.cpp | 4 ++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/test/Object/coff-archive.test b/test/Object/coff-archive.test index 239a96b4c35..5d0b844aa0d 100644 --- a/test/Object/coff-archive.test +++ b/test/Object/coff-archive.test @@ -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 diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 961754ccefa..c30d628d9a5 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -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)