Index: lib/Object/MachOObjectFile.cpp =================================================================== --- lib/Object/MachOObjectFile.cpp +++ lib/Object/MachOObjectFile.cpp @@ -1659,6 +1659,10 @@ Expected MachOObjectFile::getSymbolName(DataRefImpl Symb) const { StringRef StringTable = getStringTableData(); MachO::nlist_base Entry = getSymbolTableEntryBase(*this, Symb); + if (Entry.n_strx == 0) { + // contents of the StringTable at n_strx 0 are not defined + return StringRef(); + } const char *Start = &StringTable.data()[Entry.n_strx]; if (Start < getData().begin() || Start >= getData().end()) { return malformedError("bad string index: " + Twine(Entry.n_strx) + Index: test/tools/llvm-nm/X86/macho-dwarf.test =================================================================== --- /dev/null +++ test/tools/llvm-nm/X86/macho-dwarf.test @@ -0,0 +1,5 @@ +# RUN: llvm-nm -ap %p/Inputs/macho-dwarf-x86_64 | cat -e | FileCheck %s + +# CHECK-NOT: ENSYM $ +# CHECK: ENSYM $ +