Index: include/llvm/MC/MCObjectWriter.h =================================================================== --- include/llvm/MC/MCObjectWriter.h +++ include/llvm/MC/MCObjectWriter.h @@ -49,6 +49,10 @@ MCObjectWriter(raw_pwrite_stream &OS, bool IsLittleEndian) : OS(&OS), IsLittleEndian(IsLittleEndian) {} + unsigned getInitialOffset() { + return OS->tell(); + } + public: virtual ~MCObjectWriter(); Index: lib/MC/WinCOFFObjectWriter.cpp =================================================================== --- lib/MC/WinCOFFObjectWriter.cpp +++ lib/MC/WinCOFFObjectWriter.cpp @@ -962,7 +962,7 @@ // Assign file offsets to COFF object file structures. - unsigned offset = 0; + unsigned offset = getInitialOffset(); if (UseBigObj) offset += COFF::Header32Size; Index: test/MC/COFF/stdin.s =================================================================== --- /dev/null +++ test/MC/COFF/stdin.s @@ -0,0 +1,3 @@ +// REQUIRES: shell +// RUN: ( echo "test"; llvm-mc -filetype=obj -triple i686-pc-win32 %s ) > %t +