[PATCH] D25590: Add initial support for WebAssembly binary format
Michael Spencer via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 29 20:24:33 PDT 2016
Bigcheese requested changes to this revision.
Bigcheese added a comment.
This revision now requires changes to proceed.
This patch is a bit too big. I'd prefer if you picked one of the tools and did that first. llvm-objdump is a good place to start.
================
Comment at: lib/Object/WasmObjectFile.cpp:37-44
+uint32_t readUint32(const uint8_t *&Ptr) {
+ uint32_t Result = 0;
+ memcpy(&Result, Ptr, sizeof(Result));
+ if (!sys::IsLittleEndianHost)
+ sys::swapByteOrder(Result);
+ Ptr += sizeof(Result);
+ return Result;
----------------
We already have these in Support/Endian.h
================
Comment at: tools/llvm-readobj/MachODumper.cpp:1
-//===-- MachODump.cpp - Object file dumping utility for llvm --------------===//
+//===-- MachODumper.cpp - Object file dumping utility for llvm ------------===//
//
----------------
This is an unrelated change.
================
Comment at: tools/obj2yaml/coff2yaml.cpp:1
-//===------ utils/obj2yaml.cpp - obj2yaml conversion tool -------*- C++ -*-===//
+//===------ utils/coff2yaml.cpp - obj2yaml conversion tool ------*- C++ -*-===//
//
----------------
Unrelated change.
================
Comment at: tools/obj2yaml/wasm2yaml.cpp:40
+ case wasm::WASM_SEC_TYPE: {
+ WasmYAML::TypeSection* TypeSec = new WasmYAML::TypeSection;
+ for (const auto &FunctionSig : Obj.types()) {
----------------
dschuff wrote:
> these `new foo` lines could be use `auto*`
This, and the others, would be better as:
```
auto TypeSec = std::make_unique<WasmYAML::TypeSection>();
// Fill them up
S = std::move(TypeSec);
```
================
Comment at: tools/yaml2obj/yaml2wasm.cpp:43
+
+static int writeUint64(raw_ostream &OS, uint64_t Value) {
+ char Data[sizeof(Value)];
----------------
dschuff wrote:
> could writeUint{32,64} be a template?
Support/Endian.h has write64le.
https://reviews.llvm.org/D25590
More information about the llvm-commits
mailing list