diff options
| author | Sam Clegg <sbc@chromium.org> | 2019-01-31 22:38:22 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2019-01-31 22:38:22 +0000 |
| commit | c0affde863665ac198366956a56742321537f319 (patch) | |
| tree | 07e8dbf4e62a4807123472cdd02e84c3c4a90b28 /llvm/lib/MC | |
| parent | d16ca2fcbed759d39c724a1bf28b9c966dee6e03 (diff) | |
| download | bcm5719-llvm-c0affde863665ac198366956a56742321537f319.tar.gz bcm5719-llvm-c0affde863665ac198366956a56742321537f319.zip | |
[WebAssembly] MC: Fix for outputing wasm object to /dev/null
Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D57479
llvm-svn: 352806
Diffstat (limited to 'llvm/lib/MC')
| -rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index d0ffe7c4a40..83ac9a44dc4 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -398,7 +398,13 @@ void WasmObjectWriter::startCustomSection(SectionBookkeeping &Section, // Now that the section is complete and we know how big it is, patch up the // section size field at the start of the section. void WasmObjectWriter::endSection(SectionBookkeeping &Section) { - uint64_t Size = W.OS.tell() - Section.PayloadOffset; + uint64_t Size = W.OS.tell(); + // /dev/null doesn't support seek/tell and can report offset of 0. + // Simply skip this patching in that case. + if (!Size) + return; + + Size -= Section.PayloadOffset; if (uint32_t(Size) != Size) report_fatal_error("section size does not fit in a uint32_t"); |

