All Projects → akupila → Go Wasm

akupila / Go Wasm

Licence: mit
WebAssembly binary file parser written in go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Wasm

Deta parser
快速中文分词分析word segmentation
Stars: ✭ 476 (+293.39%)
Mutual labels:  parser, binary
Raw Wasm
Raw WebAssembly demos
Stars: ✭ 183 (+51.24%)
Mutual labels:  binary, wasm
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+367.77%)
Mutual labels:  parser, wasm
Gumnut
JS parser in Web Assembly / C
Stars: ✭ 140 (+15.7%)
Mutual labels:  parser, wasm
Markdown Wasm
Markdown parser and HTML generator implemented in WebAssembly, based on md4c
Stars: ✭ 833 (+588.43%)
Mutual labels:  parser, wasm
Ltgt
Lightweight HTML processor
Stars: ✭ 117 (-3.31%)
Mutual labels:  parser
Blurhash Rust Wasm
A Rust and WASM implementation of the blurhash algorithm
Stars: ✭ 119 (-1.65%)
Mutual labels:  wasm
Lua Gumbo
Moved to https://gitlab.com/craigbarnes/lua-gumbo
Stars: ✭ 116 (-4.13%)
Mutual labels:  parser
Chirp
A modern low-level programming language
Stars: ✭ 116 (-4.13%)
Mutual labels:  parser
Commonmark Java
Java library for parsing and rendering CommonMark (Markdown)
Stars: ✭ 1,675 (+1284.3%)
Mutual labels:  parser
Rust hdl
Stars: ✭ 120 (-0.83%)
Mutual labels:  parser
Crass
A Ruby CSS parser that's fully compliant with the CSS Syntax Level 3 specification.
Stars: ✭ 118 (-2.48%)
Mutual labels:  parser
Vte
Parser for virtual terminal emulators
Stars: ✭ 117 (-3.31%)
Mutual labels:  parser
Aries Framework Go
Hyperledger Aries Framework Go provides packages for building Agent / DIDComm services.
Stars: ✭ 118 (-2.48%)
Mutual labels:  wasm
Bssom.net
A small, high performance, powerful serializer using bssom binary protocol
Stars: ✭ 117 (-3.31%)
Mutual labels:  binary
Pq
a command-line Protobuf parser with Kafka support and JSON output
Stars: ✭ 120 (-0.83%)
Mutual labels:  parser
Corrode
A batteries-included library for reading binary data.
Stars: ✭ 116 (-4.13%)
Mutual labels:  binary
Luqum
A lucene query parser generating ElasticSearch queries and more !
Stars: ✭ 118 (-2.48%)
Mutual labels:  parser
Html2pug
Converts HTML to Pug 🐶
Stars: ✭ 118 (-2.48%)
Mutual labels:  parser
Instagram Parser
Парсер аккаунтов подписчиков и подписок в Instagram
Stars: ✭ 118 (-2.48%)
Mutual labels:  parser

CircleCI godoc

go-wasm

A WebAssembly binary file parser in go.

The parser takes an io.Reader and parses a WebAssembly module from it, which allows the user to see into the binary file. All data is read, future version may allow to write it out too, which would allow modifying the binary.

For example:

package main

import (
	"flag"
	"fmt"
	"os"
	"text/tabwriter"

	wasm "github.com/akupila/go-wasm"
)

func main() {
	file := flag.String("file", "", "file to parse (.wasm)")
	flag.Parse()

	if *file == "" {
		flag.Usage()
		os.Exit(2)
	}

	f, err := os.Open(*file)
	if err != nil {
		fmt.Fprintf(os.Stderr, "open file: %v", err)
		os.Exit(1)
	}
	defer f.Close()

	mod, err := wasm.Parse(f)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	w := tabwriter.NewWriter(os.Stdout, 0, 0, 4, ' ', 0)
	fmt.Fprintf(w, "Index\tName\tSize (bytes)\n")
	for i, s := range mod.Sections {
		fmt.Fprintf(w, "%d\t%s\t%d\n", i, s.Name(), s.Size())
	}
	w.Flush()
}

when passed in a .wasm file compiled with go1.11:

Index    Name        Size (bytes)
0        Custom      103
1        Type        58
2        Import      363
3        Function    1588
4        Table       5
5        Memory      5
6        Global      51
7        Export      14
8        Element     3066
9        Code        1174891
10       Data        1169054
11       Custom      45428

Much more information is available by type asserting on the items in .Sections, for example:

for i, s := range mod.Sections {
    switch section := s.(type) {
        case *wasm.SectionCode:
            // can now read function bytecode from section.
    }
}

Installation

go get github.com/akupila/go-wasm/...

Notes

This is a experimental, early and definitely not properly tested. There are probably bugs. If you find one, please open an issue!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].