mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-09 21:50:50 +00:00
[WebAssembly] Implement the wasm binary container header.
Also, update the version number to 0x1, which is what engines are now expecting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295860 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f55d742b2
commit
6d5b578789
@ -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;
|
||||
|
@ -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,
|
||||
|
9
test/MC/WebAssembly/file-headers.ll
Normal file
9
test/MC/WebAssembly/file-headers.ll
Normal 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{{$}}
|
2
test/MC/WebAssembly/lit.local.cfg
Normal file
2
test/MC/WebAssembly/lit.local.cfg
Normal file
@ -0,0 +1,2 @@
|
||||
if 'WebAssembly' not in config.root.targets:
|
||||
config.unsupported = True
|
Loading…
Reference in New Issue
Block a user