Index: test/tools/llvm-nm/debug-syms.test =================================================================== --- /dev/null +++ test/tools/llvm-nm/debug-syms.test @@ -0,0 +1,32 @@ +# RUN: yaml2obj %s > %t.o +# RUN: llvm-nm --debug-syms %t.o | FileCheck %s --implicit-check-not U +# RUN: llvm-nm -a %t.o | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_ARM +Sections: + - Name: section + Type: SHT_PROGBITS +Symbols: + - Name: "" + Type: STT_SECTION + Section: section + - Name: file_sym + Type: STT_FILE + Index: SHN_ABS + - Name: $d + Section: section + - Name: $t + Section: section + - Name: $a + Section: section + +# CHECK: $a +# CHECK-NEXT: $d +# CHECK-NEXT: $t +# CHECK-NEXT: file_sym +# CHECK-NEXT: section Index: tools/llvm-nm/llvm-nm.cpp =================================================================== --- tools/llvm-nm/llvm-nm.cpp +++ tools/llvm-nm/llvm-nm.cpp @@ -1193,6 +1193,9 @@ continue; if (WithoutAliases && (SymFlags & SymbolRef::SF_Indirect)) continue; + // Skip the undefined symbol at index 0. + if (Sym == *Obj.symbols().begin() && Obj.isELF()) + continue; // If a "-s segname sectname" option was specified and this is a Mach-O // file and this section appears in this file, Nsect will be non-zero then // see if this symbol is a symbol from that section and if not skip it.