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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218549 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2014-09-26 22:32:16 +00:00
parent a51dbbd394
commit 01ea611601
6 changed files with 24 additions and 6 deletions

View File

@ -266,11 +266,16 @@ void MachODumper::printSections(const MachOObjectFile *Obj) {
}
if (opts::SectionData) {
StringRef Data;
if (error(Section.getContents(Data)))
bool IsBSS;
if (error(Section.isBSS(IsBSS)))
break;
if (!IsBSS) {
StringRef Data;
if (error(Section.getContents(Data)))
break;
W.printBinaryBlock("SectionData", Data);
W.printBinaryBlock("SectionData", Data);
}
}
}
}