From 8c6e3248e90605f0ff7249a9727fe46e79297b25 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 28 Jun 2013 14:25:52 +0000 Subject: [PATCH] llvm-symbolizer: skip leading underscore in Mach-O symbol table entries git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185151 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/DebugInfo/llvm-symbolizer.test | 6 +++--- tools/llvm-symbolizer/LLVMSymbolize.cpp | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/DebugInfo/llvm-symbolizer.test b/test/DebugInfo/llvm-symbolizer.test index efe09c15bfe..11ba6642837 100644 --- a/test/DebugInfo/llvm-symbolizer.test +++ b/test/DebugInfo/llvm-symbolizer.test @@ -32,9 +32,9 @@ CHECK-NEXT: dwarfdump-inl-test.cc: CHECK: _Z3do1v CHECK-NEXT: dwarfdump-test3-decl.h:7 -CHECK: _main -CHECK: __Z3inci -CHECK: __Z3inci +CHECK: main +CHECK: _Z3inci +CHECK: _Z3inci RUN: echo "unexisting-file 0x1234" > %t.input2 RUN: llvm-symbolizer < %t.input2 diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp index dfcbacfbe63..59564161b4e 100644 --- a/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -74,6 +74,9 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx) StringRef SymbolName; if (error(si->getName(SymbolName))) continue; + // Mach-O symbol table names have leading underscore, skip it. + if (Module->isMachO() && SymbolName.size() > 0 && SymbolName[0] == '_') + SymbolName = SymbolName.drop_front(); // FIXME: If a function has alias, there are two entries in symbol table // with same address size. Make sure we choose the correct one. SymbolMapTy &M = SymbolType == SymbolRef::ST_Function ? Functions : Objects;