mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 17:56:53 +00:00
Readobj: If NumbersOfSections is 0xffff, it's an COFF import library.
0xffff does not mean that there are 65535 sections in a COFF file but indicates that it's a COFF import library. This patch fixes SEGV error when an import library file is passed to llvm-readobj. llvm-svn: 194844
This commit is contained in:
parent
1bbe61860d
commit
061635e520
@ -57,6 +57,8 @@ struct coff_file_header {
|
||||
support::ulittle32_t NumberOfSymbols;
|
||||
support::ulittle16_t SizeOfOptionalHeader;
|
||||
support::ulittle16_t Characteristics;
|
||||
|
||||
bool isImportLibrary() const { return NumberOfSections == 0xffff; }
|
||||
};
|
||||
|
||||
/// The 32-bit PE header that follows the COFF header.
|
||||
|
@ -507,9 +507,10 @@ COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &ec)
|
||||
CurPtr += COFFHeader->SizeOfOptionalHeader;
|
||||
}
|
||||
|
||||
if ((ec = getObject(SectionTable, Data, base() + CurPtr,
|
||||
COFFHeader->NumberOfSections * sizeof(coff_section))))
|
||||
return;
|
||||
if (!COFFHeader->isImportLibrary())
|
||||
if ((ec = getObject(SectionTable, Data, base() + CurPtr,
|
||||
COFFHeader->NumberOfSections * sizeof(coff_section))))
|
||||
return;
|
||||
|
||||
// Initialize the pointer to the symbol table.
|
||||
if (COFFHeader->PointerToSymbolTable != 0)
|
||||
@ -586,7 +587,9 @@ section_iterator COFFObjectFile::begin_sections() const {
|
||||
|
||||
section_iterator COFFObjectFile::end_sections() const {
|
||||
DataRefImpl ret;
|
||||
ret.p = reinterpret_cast<uintptr_t>(SectionTable + COFFHeader->NumberOfSections);
|
||||
int numSections = COFFHeader->isImportLibrary()
|
||||
? 0 : COFFHeader->NumberOfSections;
|
||||
ret.p = reinterpret_cast<uintptr_t>(SectionTable + numSections);
|
||||
return section_iterator(SectionRef(ret, this));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user