1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[WebAssembly] Implement the wasm binary container header.

Also, update the version number to 0x1, which is what engines are now
expecting.

llvm-svn: 295860
This commit is contained in:
Dan Gohman 2017-02-22 18:50:20 +00:00
parent 075724a5d9
commit a6d9264e17
4 changed files with 15 additions and 2 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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{{$}}

View File

@ -0,0 +1,2 @@
if 'WebAssembly' not in config.root.targets:
config.unsupported = True