From dac39857d6545e32f20f0735a04b934f36b6c1d9 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 26 Sep 2014 22:32:16 +0000 Subject: Object: BSS/virtual sections don't have contents Users of getSectionContents shouldn't try to pass in BSS or virtual sections. In all instances, this is a bug in the code calling this routine. N.B. Some COFF implementations (like CL) will mark their BSS sections as taking space on disk. This would confuse COFFObjectFile into thinking the section is larger than the file. llvm-svn: 218549 --- llvm/lib/Object/COFFObjectFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Object/COFFObjectFile.cpp') diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 7daef06..45de434 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -840,6 +840,10 @@ std::error_code COFFObjectFile::getSectionName(const coff_section *Sec, std::error_code COFFObjectFile::getSectionContents(const coff_section *Sec, ArrayRef &Res) const { + // PointerToRawData and SizeOfRawData won't make sense for BSS sections, don't + // do anything interesting for them. + assert((Sec->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) == 0 && + "BSS sections don't have contents!"); // The only thing that we need to verify is that the contents is contained // within the file bounds. We don't need to make sure it doesn't cover other // data, as there's nothing that says that is not allowed. -- cgit v1.1