Index: test/tools/llvm-nm/format-sysv-binding.test =================================================================== --- test/tools/llvm-nm/format-sysv-binding.test +++ test/tools/llvm-nm/format-sysv-binding.test @@ -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 @@ 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 | Index: tools/llvm-nm/llvm-nm.cpp =================================================================== --- tools/llvm-nm/llvm-nm.cpp +++ tools/llvm-nm/llvm-nm.cpp @@ -894,9 +894,14 @@ 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();