From 1f9e6bbfafca34d938a5ecccfd3d2fe7bc0fdc09 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 5 Sep 2018 18:01:04 +0000 Subject: [PATCH] Handle zero-length debug directory entries. Part of https://reviews.llvm.org/D51652 (tests will be in the lld repo) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341485 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Object/COFFObjectFile.cpp | 10 ++++++---- tools/llvm-readobj/COFFDumper.cpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp index dfb95edce92..f09401307b4 100644 --- a/lib/Object/COFFObjectFile.cpp +++ b/lib/Object/COFFObjectFile.cpp @@ -616,6 +616,8 @@ std::error_code COFFObjectFile::initBaseRelocPtr() { IntPtr); BaseRelocEnd = reinterpret_cast( IntPtr + DataEntry->Size); + // FIXME: Verify the section containing BaseRelocHeader has at least + // DataEntry->Size bytes after DataEntry->RelativeVirtualAddress. return std::error_code(); } @@ -637,10 +639,10 @@ std::error_code COFFObjectFile::initDebugDirectoryPtr() { if (std::error_code EC = getRvaPtr(DataEntry->RelativeVirtualAddress, IntPtr)) return EC; DebugDirectoryBegin = reinterpret_cast(IntPtr); - if (std::error_code EC = getRvaPtr( - DataEntry->RelativeVirtualAddress + DataEntry->Size, IntPtr)) - return EC; - DebugDirectoryEnd = reinterpret_cast(IntPtr); + DebugDirectoryEnd = reinterpret_cast( + IntPtr + DataEntry->Size); + // FIXME: Verify the section containing DebugDirectoryBegin has at least + // DataEntry->Size bytes after DataEntry->RelativeVirtualAddress. return std::error_code(); } diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index c0579d63dff..4b6125e1a00 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -751,7 +751,7 @@ void COFFDumper::printCOFFDebugDirectory() { W.printNumber("PDBAge", DebugInfo->PDB70.Age); W.printString("PDBFileName", PDBFileName); } - } else { + } else if (D.SizeOfData != 0) { // FIXME: Type values of 12 and 13 are commonly observed but are not in // the documented type enum. Figure out what they mean. ArrayRef RawData; -- 2.11.0