x86等效于WebAssembly指令

问题描述 投票:0回答:1

我一直在玩WebAssembly程序。我想获得与WebAssembly程序等效的x86。通过谷歌搜索,我发现objdump可用于使用命令

的任何对象文件
objdump -M intel <file_name>

但是明显的原因,wasm文件wasm-objdump的反汇编程序没有标志m,用于以x86格式反汇编代码。

是否有一种(简便的方法)将WebAssembly中给定的指令映射到等效的x86指令而不显式匹配每个指令?

webassembly objdump
1个回答
0
投票

在线WasmExplorer使用SpiderMonkey编译器将C代码编译为WebAssembly和FireFox x86。给出以下简单功能:

int testFunction(int* input, int length) {
  int sum = 0;
  for (int i = 0; i < length; ++i) {
    sum += input[i];
  }
  return sum;
}

这里是x86输出:

wasm-function[0]:
  sub rsp, 8                            ; 0x000000 48 83 ec 08
  cmp esi, 1                            ; 0x000004 83 fe 01
  jge 0x14                              ; 0x000007 0f 8d 07 00 00 00
 0x00000d:                              
  xor eax, eax                          ; 0x00000d 33 c0
  jmp 0x26                              ; 0x00000f e9 12 00 00 00
 0x000014:                              
  xor eax, eax                          ; 0x000014 33 c0
 0x000016:                              ; 0x000016 from: [0x000024]
  mov ecx, dword ptr [r15 + rdi]        ; 0x000016 41 8b 0c 3f
  add eax, ecx                          ; 0x00001a 03 c1
  add edi, 4                            ; 0x00001c 83 c7 04
  add esi, -1                           ; 0x00001f 83 c6 ff
  test esi, esi                         ; 0x000022 85 f6
  jne 0x16                              ; 0x000024 75 f0
 0x000026:                              
  nop                                   ; 0x000026 66 90
  add rsp, 8                            ; 0x000028 48 83 c4 08
  ret 

您可以view this example online

WasmExplorer通过服务将代码编译为wasm / x86-您可以看到scripts that are run on Github-您应该可以使用它们自己构建命令行工具。

© www.soinside.com 2019 - 2024. All rights reserved.