From 7e369ff2e564495211e9cc3d6224057c804621fe Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 4 Feb 2014 23:53:15 +0000 Subject: [PATCH] Small fix for llvm-nm handling of weak symbols on ELF (print 'v'). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200808 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Object/Inputs/weak.elf-x86-64 | Bin 0 -> 896 bytes test/Object/nm-trivial-object.test | 6 ++++++ tools/llvm-nm/llvm-nm.cpp | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/Object/Inputs/weak.elf-x86-64 diff --git a/test/Object/Inputs/weak.elf-x86-64 b/test/Object/Inputs/weak.elf-x86-64 new file mode 100644 index 0000000000000000000000000000000000000000..e45f9880f9dbad4798cb6c9f694fbe405145c36c GIT binary patch literal 896 zcmbtSF>=B%5L^REfP^AlX3{_rDn^5OK*mi{QSb#bfk}}xScR#e=Tkg~M`R|^+9y!X zsuC5}?w;=UPS);a{@O|s_?6%p7v@!9e}TvAr%E!#_S5D|n8I%A{oSL@ z>LWLHRa%(0+~zRLqNsBI`5C%=_Is`BWWw*1u4j96@s2t}x@gzpRAQ{p+^+Bk*~g;G zaZ!Q!8T|&@f8xTd`PcmWNG=_{e@YT8?N8nc;vVirJc@ARcHWbozvndFJ5w?d2PDDL z{z0e#+tHUuznCNS=AWeBs8P9|WfZB;Ifs$+{YsB?U#2K$Sf^OenC3gXbvW$C-y5%$ JZ|Up1UO(ZHBsTy6 literal 0 HcmV?d00001 diff --git a/test/Object/nm-trivial-object.test b/test/Object/nm-trivial-object.test index d13d217d2f1..c2d2ebb14b5 100644 --- a/test/Object/nm-trivial-object.test +++ b/test/Object/nm-trivial-object.test @@ -6,6 +6,8 @@ RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \ RUN: | FileCheck %s -check-prefix ELF RUN: llvm-nm %p/Inputs/trivial-object-test.elf-x86-64 \ RUN: | FileCheck %s -check-prefix ELF +RUN: llvm-nm %p/Inputs/weak.elf-x86-64 \ +RUN: | FileCheck %s -check-prefix WEAK-ELF RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \ RUN: | FileCheck %s -check-prefix macho RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \ @@ -34,6 +36,10 @@ ELF: U SomeOtherFunction ELF: 00000000 T main ELF: U puts +WEAK-ELF: w f1 +WEAK-ELF: 00000000 W f2 +WEAK-ELF: v x1 +WEAK-ELF: 00000000 V x2 macho: 00000000 U _SomeOtherFunction macho: 00000000 T _main diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 5b8bafc8ab0..8d1fa729bd7 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -360,8 +360,12 @@ static char getSymbolNMTypeChar(ELFObjectFile &Obj, symbol_iterator I) { Ret = ::toupper(Ret); break; case ELF::STB_WEAK: - if (EF.getSymbolTableIndex(ESym) == ELF::SHN_UNDEF) - Ret = 'w'; + if (EF.getSymbolTableIndex(ESym) == ELF::SHN_UNDEF) { + if (ESym->getType() == ELF::STT_OBJECT) + Ret = 'v'; + else + Ret = 'w'; + } else if (ESym->getType() == ELF::STT_OBJECT) Ret = 'V'; else