[llvm-nm] Generalize symbol types 'N', 'n' and '?'

llvm-svn: 359312
This commit is contained in:
Fangrui Song 2019-04-26 16:03:31 +00:00
parent 0bf06a8f59
commit 5f184f1780
1 changed files with 5 additions and 9 deletions

View File

@ -944,22 +944,18 @@ static char getSymbolNMTypeChar(ELFObjectFileBase &Obj,
return 't'; return 't';
if (Flags & ELF::SHF_ALLOC) if (Flags & ELF::SHF_ALLOC)
return Flags & ELF::SHF_WRITE ? 'd' : 'r'; return Flags & ELF::SHF_WRITE ? 'd' : 'r';
}
if (SymI->getELFType() == ELF::STT_SECTION) {
Expected<StringRef> Name = SymI->getName(); Expected<StringRef> Name = SymI->getName();
if (!Name) { if (!Name) {
consumeError(Name.takeError()); consumeError(Name.takeError());
return '?'; return '?';
} }
return StringSwitch<char>(*Name) if (Name->startswith(".debug"))
.StartsWith(".debug", 'N') return 'N';
.StartsWith(".note", 'n') if (!(Flags & ELF::SHF_WRITE))
.StartsWith(".comment", 'n') return 'n';
.Default('?');
} }
return 'n'; return '?';
} }
static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) { static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {