wabt
wabt copied to clipboard
[Feature/Binary Request] List Exported functions only
I noticed that wasm-objdump can dump all functions and symbols but it does it weirdly it doesen't quite go functions (then their data) it seems to switch between all the diffrent data assocated whether being size, where it is pulled from etc
You can list the exports using wasm-objdump -j export.
We could add a flag to allow you to disassamble just exported functions but I'm not clear why that would be useful. Why would you only want to disassemble the exported functions?
Aside from that I'm not quite sure what you are asking for here. The data in wasm module is no generally associated with particular function. Any function can access any data. There may have been some link/assosiation in the source language but those links are not present in the binaryn.
In the case of a shared library and I forgot all the exported functions I included in it
Also I just tried wasm-objdump -j export and I had to add -x and then it told me "section not found: export" also checked the plural form
Also I just tried
wasm-objdump -j exportand I had to add -x and then it told me "section not found: export" also checked the plural form
What don't wasm-objdump -h tell you? Does the file really not have an export section?
all wasm-objdump -h tells me is
wasm-objdump: expected filename argument.
Try '--help' for more information.
if I try --help
usage: wasm-objdump [options] filename+
Print information about the contents of wasm binaries.
examples:
$ wasm-objdump test.wasm
options:
--help Print this help message
--version Print version information
-h, --headers Print headers
-j, --section=SECTION Select just one section
-s, --full-contents Print raw section contents
-d, --disassemble Disassemble function bodies
--debug Print extra debug information
-x, --details Show section details
-r, --reloc Show relocations inline with disassembly
--section-offsets Print section offsets instead of file offsets in code disassembly
and idk how to check for export section (all i know is that wasm2c produces valid C code)
The -h or --headers flag lists the headers of a wasm file. You need to also specify the wasm file on the command line along with the -h flag. Sorry I wasn't more clear about that.
so it appears the propper command is wasm-objdump -j Export -x but this includes the export of memory
and also fails to include the function types (inputs/outputs)
Right, -j Export lists all the exports, not just the functions. There is not flag for listing just part of the export section. Each section is listed in it's entirety, or not at all.
The signatures are in a different section so you would use a different -j flag to list those.
If you are looking for other ways to introspect a wasm module you might also want to take a look at wasm-dis from the binaryen project.
wasm-dis imo feels like a worse wasm2wat
(also totally not considering implementing my own WASM VM in lua since the only wasm2lua I can find is broken and apparently abandoned)
afterall for my specific binary I would only have to implement 101 diffrent opcodes (not including some other important stuff)