Rizin
unix-like reverse engineering framework and cli tools
asm_wasm.c File Reference
#include <stdio.h>
#include <string.h>
#include <rz_types.h>
#include <rz_lib.h>
#include <rz_asm.h>
#include "../arch/wasm/wasm.h"

Go to the source code of this file.

Functions

static int disassemble (RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
 
static int assemble (RzAsm *a, RzAsmOp *op, const char *buf)
 

Variables

RzAsmPlugin rz_asm_plugin_wasm
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ assemble()

static int assemble ( RzAsm a,
RzAsmOp op,
const char *  buf 
)
static

Definition at line 24 of file asm_wasm.c.

24  {
25  ut8 *opbuf = (ut8 *)rz_strbuf_get(&op->buf);
26  op->size = wasm_asm(buf, opbuf, 32); // XXX hardcoded opsize
27  return op->size;
28 }
RZ_IPI int wasm_asm(const char *str, unsigned char *buf, int buf_len)
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
Definition: strbuf.c:321
Definition: dis.c:32

References rz_strbuf_get(), and wasm_asm().

◆ disassemble()

static int disassemble ( RzAsm a,
RzAsmOp op,
const ut8 buf,
int  len 
)
static

Definition at line 15 of file asm_wasm.c.

15  {
16  WasmOp wop = { { 0 } };
17  int ret = wasm_dis(&wop, buf, len);
18  rz_asm_op_set_asm(op, wop.txt);
19  free(wop.txt);
20  op->size = ret;
21  return op->size;
22 }
size_t len
Definition: 6502dis.c:15
RZ_API void rz_asm_op_set_asm(RzAsmOp *op, const char *str)
Definition: aop.c:53
RZ_IPI int wasm_dis(WasmOp *op, const unsigned char *buf, int buf_len)
Definition: wasm.c:479
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
Definition: wasm.h:486
char * txt
Definition: wasm.h:494

References free(), len, rz_asm_op_set_asm(), WasmOp::txt, and wasm_dis().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_wasm
Definition: asm_wasm.c:30
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_asm.h:133

Definition at line 44 of file asm_wasm.c.

◆ rz_asm_plugin_wasm

RzAsmPlugin rz_asm_plugin_wasm
Initial value:
= {
.name = "wasm",
.author = "cgvwzq",
.version = "0.1.0",
.arch = "wasm",
.license = "MIT",
.bits = 32,
.desc = "WebAssembly",
.disassemble = &disassemble,
.assemble = &assemble
}
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_wasm.c:15
static int assemble(RzAsm *a, RzAsmOp *op, const char *buf)
Definition: asm_wasm.c:24
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526

Definition at line 30 of file asm_wasm.c.