diff options
| author | Rui Ueyama <ruiu@google.com> | 2013-11-15 20:23:25 +0000 | 
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2013-11-15 20:23:25 +0000 | 
| commit | 15ba1e20db232854a65f6b385a0368151596051f (patch) | |
| tree | c7047f4ed08a307fd82bade9f5f2d4ca5874bba8 /llvm/lib | |
| parent | fc0fea0251c1941fd6bd4d6b0c81efd6cc65da30 (diff) | |
| download | bcm5719-llvm-15ba1e20db232854a65f6b385a0368151596051f.tar.gz bcm5719-llvm-15ba1e20db232854a65f6b385a0368151596051f.zip  | |
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
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 11 | 
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index f33caee3349..42066c372b4 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -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));  }  | 

