[PATCH] D155535: [WebAssembly][Objcopy] Write output section headers identically to inputs

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 21 00:38:05 PDT 2023


jhenderson added inline comments.


================
Comment at: llvm/lib/ObjectYAML/WasmEmitter.cpp:652
     // Write the section size followed by the content
-    encodeULEB128(OutString.size(), OS);
+    encodeULEB128(OutString.size(), OS, HeaderSecSizeEncodingLen);
     OS << OutString;
----------------
What happens if the encoding length is smaller than what is actually required to encode the size? I assume it either throws some kind of error somehow (no idea how), or silently writes size in full without truncation. If the latter, I think it might be worth reporting an error from yaml2obj, as otherwise the data won't reflect what was explicitly requested.


================
Comment at: llvm/test/ObjectYAML/wasm/section_header_size.yaml:72
+# CHECK-NEXT:         Body:            200020016A0B
\ No newline at end of file

----------------
Nit: new line at EOF.


================
Comment at: llvm/tools/obj2yaml/wasm2yaml.cpp:402-403
+    if (WasmSec.HeaderSecSizeEncodingLen &&
+        WasmSec.HeaderSecSizeEncodingLen !=
+            getULEB128Size(WasmSec.Content.size()) &&
+        WasmSec.HeaderSecSizeEncodingLen != 5)
----------------
Maybe I'm missing something, but doesn't this mean that there's ambiguity between whether a length of the LEB size or 5 is appropriate when the emitted YAML is converted back to an object?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155535/new/

https://reviews.llvm.org/D155535



More information about the llvm-commits mailing list