[llvm] r364559 - [llvm-nm] Fix for BZ41711 - Class character for a symbol with undefined
Chris Jackson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 09:27:53 PDT 2019
Author: chrisj
Date: Thu Jun 27 09:27:53 2019
New Revision: 364559
URL: http://llvm.org/viewvc/llvm-project?rev=364559&view=rev
Log:
[llvm-nm] Fix for BZ41711 - Class character for a symbol with undefined
binding does not match class assigned by GNU nm
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=41711
Differential Revision: https://reviews.llvm.org/D63340
Modified:
llvm/trunk/test/tools/llvm-nm/format-sysv-binding.test
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/test/tools/llvm-nm/format-sysv-binding.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/format-sysv-binding.test?rev=364559&r1=364558&r2=364559&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/format-sysv-binding.test (original)
+++ llvm/trunk/test/tools/llvm-nm/format-sysv-binding.test Thu Jun 27 09:27:53 2019
@@ -1,9 +1,4 @@
-# XFAIL: *
-# For a symbol in a text section the class character for an unrecognised binding
-# value is '?' in gnu-nm but llvm-nm prints 'T'. Filed as:
-# https://bugs.llvm.org/show_bug.cgi?id=41711
-
-# RUN: yaml2obj %s > %t.o
+# RUN: yaml2obj %s -o %t.o
# RUN: llvm-nm %t.o --format=sysv | FileCheck %s
!ELF
@@ -17,28 +12,33 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Symbols:
- - Name: symbol_local
+ - Name: local_binding
Binding: STB_LOCAL
Section: .text
- Value: 0x101
- Size: 8
- - Name: symbol_weak
+ Value: 0xbeef
+ - Name: global_binding
+ Binding: STB_GLOBAL
+ Section: .text
+ - Name: weak_binding
Binding: STB_WEAK
Section: .text
- Value: 0x102
- Size: 4
- - Name: symbol_undefined_binding
+ - Name: unrecognised_binding
Binding: 5
Section: .text
- Value: 0x1004
- Size: 32
- - Name: symbol_global
- Binding: STB_GLOBAL
+ - Name: gnu_unique_binding
+ Binding: 10
+ Section: .text
+ - Name: os_binding
+ Binding: 11
+ Section: .text
+ - Name: proc_binding
+ Binding: 14
Section: .text
- Value: 0x103
- Size: 16
-# CHECK: symbol_global {{.*}}| T |
-# CHECK-NEXT: symbol_local {{.*}}| t |
-# CHECK-NEXT: symbol_unrecognised_binding {{.*}}| ? |
-# CHECK-NEXT: symbol_weak {{.*}}| W |
+# CHECK: global_binding {{.*}}| T |
+# CHECK-NEXT: gnu_unique_binding {{.*}}| u |
+# CHECK-NEXT: local_binding {{.*}}| t |
+# CHECK-NEXT: os_binding {{.*}}| ? |
+# CHECK-NEXT: proc_binding {{.*}}| ? |
+# CHECK-NEXT: unrecognised_binding{{.*}}| ? |
+# CHECK-NEXT: weak_binding {{.*}}| W |
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=364559&r1=364558&r2=364559&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Jun 27 09:27:53 2019
@@ -894,9 +894,14 @@ static char getSymbolNMTypeChar(ELFObjec
return '?';
}
- if (SymI->getBinding() == ELF::STB_GNU_UNIQUE)
+ uint8_t Binding = SymI->getBinding();
+ if (Binding == ELF::STB_GNU_UNIQUE)
return 'u';
+ assert(Binding != ELF::STB_WEAK && "STB_WEAK not tested in calling function");
+ if (Binding != ELF::STB_GLOBAL && Binding != ELF::STB_LOCAL)
+ return '?';
+
elf_section_iterator SecI = *SecIOrErr;
if (SecI != Obj.section_end()) {
uint32_t Type = SecI->getType();
More information about the llvm-commits
mailing list