diff options
-rw-r--r-- | llvm/include/llvm/Support/Wasm.h | 2 | ||||
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 4 | ||||
-rw-r--r-- | llvm/test/MC/WebAssembly/file-headers.ll | 9 | ||||
-rw-r--r-- | llvm/test/MC/WebAssembly/lit.local.cfg | 2 |
4 files changed, 15 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/Wasm.h b/llvm/include/llvm/Support/Wasm.h index b45149577a0..4bb9b4b8eb0 100644 --- a/llvm/include/llvm/Support/Wasm.h +++ b/llvm/include/llvm/Support/Wasm.h @@ -23,7 +23,7 @@ namespace wasm { // Object file magic string. const char WasmMagic[] = {'\0', 'a', 's', 'm'}; // Wasm binary format version -const uint32_t WasmVersion = 0xd; +const uint32_t WasmVersion = 0x1; struct WasmObjectHeader { StringRef Magic; diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index cb11bab01eb..3a6114ad285 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -32,6 +32,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/StringSaver.h" +#include "llvm/Support/Wasm.h" #include <vector> using namespace llvm; @@ -90,7 +91,8 @@ WasmObjectWriter::~WasmObjectWriter() {} // Emit the Wasm header. void WasmObjectWriter::writeHeader(const MCAssembler &Asm) { - // TODO: write the magic cookie and the version. + writeBytes(StringRef(wasm::WasmMagic, sizeof(wasm::WasmMagic))); + writeLE32(wasm::WasmVersion); } void WasmObjectWriter::executePostLayoutBinding(MCAssembler &Asm, diff --git a/llvm/test/MC/WebAssembly/file-headers.ll b/llvm/test/MC/WebAssembly/file-headers.ll new file mode 100644 index 00000000000..1e5dd4b160a --- /dev/null +++ b/llvm/test/MC/WebAssembly/file-headers.ll @@ -0,0 +1,9 @@ +; RUN: llc -filetype=obj %s -o - | llvm-readobj -file-headers | FileCheck %s + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm32-unknown-unknown-wasm" + +; CHECK: Format: WASM{{$}} +; CHECK: Arch: wasm32{{$}} +; CHECK: AddressSize: 32bit{{$}} +; CHECK: Version: 0x1{{$}} diff --git a/llvm/test/MC/WebAssembly/lit.local.cfg b/llvm/test/MC/WebAssembly/lit.local.cfg new file mode 100644 index 00000000000..0dd8c920ff1 --- /dev/null +++ b/llvm/test/MC/WebAssembly/lit.local.cfg @@ -0,0 +1,2 @@ +if 'WebAssembly' not in config.root.targets: + config.unsupported = True |