[llvm-branch-commits] [llvm-branch] r360949 - Merging r352806:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 16 15:36:46 PDT 2019


Author: tstellar
Date: Thu May 16 15:36:46 2019
New Revision: 360949

URL: http://llvm.org/viewvc/llvm-project?rev=360949&view=rev
Log:
Merging r352806:

------------------------------------------------------------------------
r352806 | sbc | 2019-01-31 14:38:22 -0800 (Thu, 31 Jan 2019) | 5 lines

[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
------------------------------------------------------------------------

Added:
    llvm/branches/release_80/test/MC/WebAssembly/null-output.s
Modified:
    llvm/branches/release_80/lib/MC/WasmObjectWriter.cpp

Modified: llvm/branches/release_80/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/lib/MC/WasmObjectWriter.cpp?rev=360949&r1=360948&r2=360949&view=diff
==============================================================================
--- llvm/branches/release_80/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/branches/release_80/lib/MC/WasmObjectWriter.cpp Thu May 16 15:36:46 2019
@@ -368,7 +368,13 @@ void WasmObjectWriter::startCustomSectio
 // 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");
 

Added: llvm/branches/release_80/test/MC/WebAssembly/null-output.s
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/test/MC/WebAssembly/null-output.s?rev=360949&view=auto
==============================================================================
--- llvm/branches/release_80/test/MC/WebAssembly/null-output.s (added)
+++ llvm/branches/release_80/test/MC/WebAssembly/null-output.s Thu May 16 15:36:46 2019
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o /dev/null < %s
+
+    .text
+    .section .text.main,"",@
+    .type    main, at function
+main:
+    .functype   main (i32, i32) -> (i32)
+    end_function
+.Lfunc_end0:
+    .size main, .Lfunc_end0-main




More information about the llvm-branch-commits mailing list