[llvm] r253464 - Fix bug where WinCOFFObjectWriter would assume starting from an empty output.
Manuel Klimek via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 18 07:24:18 PST 2015
Author: klimek
Date: Wed Nov 18 09:24:17 2015
New Revision: 253464
URL: http://llvm.org/viewvc/llvm-project?rev=253464&view=rev
Log:
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!");
Added:
llvm/trunk/test/MC/COFF/stdin.s
Modified:
llvm/trunk/include/llvm/MC/MCObjectWriter.h
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
Modified: llvm/trunk/include/llvm/MC/MCObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectWriter.h?rev=253464&r1=253463&r2=253464&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectWriter.h Wed Nov 18 09:24:17 2015
@@ -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();
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=253464&r1=253463&r2=253464&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Wed Nov 18 09:24:17 2015
@@ -962,7 +962,7 @@ void WinCOFFObjectWriter::writeObject(MC
// Assign file offsets to COFF object file structures.
- unsigned offset = 0;
+ unsigned offset = getInitialOffset();
if (UseBigObj)
offset += COFF::Header32Size;
Added: llvm/trunk/test/MC/COFF/stdin.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/stdin.s?rev=253464&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/stdin.s (added)
+++ llvm/trunk/test/MC/COFF/stdin.s Wed Nov 18 09:24:17 2015
@@ -0,0 +1,3 @@
+// REQUIRES: shell
+// RUN: ( echo "test"; llvm-mc -filetype=obj -triple i686-pc-win32 %s ) > %t
+
More information about the llvm-commits
mailing list