mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-24 12:20:00 +00:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313193 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2029d1efeb
commit
0833191bf8
BIN
test/tools/llvm-nm/X86/Inputs/macho-bad-zero-nsect-for-N_SECT
Executable file
BIN
test/tools/llvm-nm/X86/Inputs/macho-bad-zero-nsect-for-N_SECT
Executable file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
RUN: llvm-nm %p/Inputs/macho-bad-zero-nsect-for-N_SECT | FileCheck -check-prefix DEFAULT %s
|
||||
DEFAULT: 0000000000000000 S dyld_stub_binder
|
||||
|
||||
RUN: llvm-nm -m %p/Inputs/macho-bad-zero-nsect-for-N_SECT | FileCheck -check-prefix MACHO %s
|
||||
MACHO: 0000000000000000 (?,?) private external dyld_stub_binder
|
||||
|
||||
RUN: llvm-nm -x %p/Inputs/macho-bad-zero-nsect-for-N_SECT | FileCheck -check-prefix HEX %s
|
||||
HEX: 0000000000000000 1f 00 0000 00000024 dyld_stub_binder
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user