diff options
author | Kevin Enderby <enderby@apple.com> | 2017-09-13 21:01:49 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2017-09-13 21:01:49 +0000 |
commit | 44550600f295b4bd3486da95507d37c600d1539e (patch) | |
tree | 2c649210c629a54f358ae4492323ee056655cc8f /llvm/tools/llvm-nm/llvm-nm.cpp | |
parent | d91bf3998fb45f5a959b77d5d0e2d86c040b8bed (diff) | |
download | bcm5719-llvm-44550600f295b4bd3486da95507d37c600d1539e.tar.gz bcm5719-llvm-44550600f295b4bd3486da95507d37c600d1539e.zip |
Fix a crash in llvm-nm for a bad Mach-O file that has an N_SECT type symbol and a zero n_sect value.
The code in llvm-nm for Mach-O files to determine the section type for an
N_SECT type symbol it will call getSymbolSection() and check for the error,
but in the case the n_sect value is zero it will return section_end() (aka nullptr).
And the code was using that and crashing instead of just returning a āsā for a
section or printing (?,?) as it would if getSymbolSection() returned an error.
rdar://33136604
llvm-svn: 313193
Diffstat (limited to 'llvm/tools/llvm-nm/llvm-nm.cpp')
-rw-r--r-- | llvm/tools/llvm-nm/llvm-nm.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index 1934051c65d..4ad0d95d67f 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -486,6 +486,10 @@ static void darwinPrintSymbol(SymbolicFile &Obj, SymbolListT::iterator I, break; } Sec = *SecOrErr; + if (Sec == MachO->section_end()) { + outs() << "(?,?) "; + break; + } } else { Sec = I->Section; } @@ -997,6 +1001,8 @@ static char getSymbolNMTypeChar(MachOObjectFile &Obj, basic_symbol_iterator I) { return 's'; } section_iterator Sec = *SecOrErr; + if (Sec == Obj.section_end()) + return 's'; DataRefImpl Ref = Sec->getRawDataRefImpl(); StringRef SectionName; Obj.getSectionName(Ref, SectionName); |