Fix bug where WinCOFFObjectWriter would assume starting from an empty output.

Starting on an input stream that is not at offset 0 would trigger the
assert in WinCOFFObjectWriter.cpp:1065:

  assert(getStream().tell() <= (*i)->Header.PointerToRawData &&
               "Section::PointerToRawData is insane!");

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253464 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Manuel Klimek 2015-11-18 15:24:17 +00:00
parent c68dcdb413
commit fc0981ecbc
3 changed files with 8 additions and 1 deletions

View File

@ -49,6 +49,10 @@ protected: // Can only create subclasses.
MCObjectWriter(raw_pwrite_stream &OS, bool IsLittleEndian)
: OS(&OS), IsLittleEndian(IsLittleEndian) {}
unsigned getInitialOffset() {
return OS->tell();
}
public:
virtual ~MCObjectWriter();

View File

@ -962,7 +962,7 @@ void WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
// Assign file offsets to COFF object file structures.
unsigned offset = 0;
unsigned offset = getInitialOffset();
if (UseBigObj)
offset += COFF::Header32Size;

3
test/MC/COFF/stdin.s Normal file
View File

@ -0,0 +1,3 @@
// REQUIRES: shell
// RUN: ( echo "test"; llvm-mc -filetype=obj -triple i686-pc-win32 %s ) > %t