From bf1a23ad0e77b4f41c65b17731d443dc553f5911 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Sat, 7 Sep 2019 19:45:27 +0000 Subject: [PATCH] [llvm-nm] - Fix a bug and unbreak ASan BB. BB: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/13820/steps/check-llvm%20asan/logs/stdio rL371074 revealed a bug in llvm-nm. This patch fixes it. llvm-svn: 371318 --- llvm/tools/llvm-nm/llvm-nm.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index 6f9b38d..ee55722 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -1082,7 +1082,7 @@ static StringRef getNMTypeName(SymbolicFile &Obj, basic_symbol_iterator I) { static char getNMSectionTagAndName(SymbolicFile &Obj, basic_symbol_iterator I, StringRef &SecName) { uint32_t Symflags = I->getFlags(); - if (isa(&Obj)) { + if (ELFObjectFileBase *ELFObj = dyn_cast(&Obj)) { if (Symflags & object::SymbolRef::SF_Absolute) SecName = "*ABS*"; else if (Symflags & object::SymbolRef::SF_Common) @@ -1097,6 +1097,9 @@ static char getNMSectionTagAndName(SymbolicFile &Obj, basic_symbol_iterator I, return '?'; } + if (*SecIOrErr == ELFObj->section_end()) + return '?'; + Expected NameOrErr = (*SecIOrErr)->getName(); if (!NameOrErr) { consumeError(NameOrErr.takeError()); -- 2.7.4