summaryrefslogtreecommitdiff
path: root/test/binary/code-metadata-section.txt
diff options
context:
space:
mode:
authorYuri Iozzelli <y.iozzelli@gmail.com>2022-02-25 16:36:35 +0100
committerGitHub <noreply@github.com>2022-02-25 15:36:35 +0000
commit1f59b65d8befc8512ff9045bb371ea5ec379a78c (patch)
tree349621c048c7716a746d3361c8ec6219d32f0250 /test/binary/code-metadata-section.txt
parent08cf71aa180674432750a02581f1e214c310042d (diff)
downloadwabt-1f59b65d8befc8512ff9045bb371ea5ec379a78c.tar.gz
wabt-1f59b65d8befc8512ff9045bb371ea5ec379a78c.tar.bz2
wabt-1f59b65d8befc8512ff9045bb371ea5ec379a78c.zip
Add initial support for code metadata (#1840)
See https://github.com/WebAssembly/tool-conventions/blob/main/CodeMetadata.md for the specification. In particular this pr implements the following: - Parsing code metadata sections in BinaryReader, providing appropriate callbacks that a BinaryReaderDelegate can implement: - BinaryReaderObjdump: show the sections in a human-readable form - BinaryReaderIr: add code metadata in the IR as expressions - Parsing code metadata annotations in text format, adding them in the IR like the BinaryReaderIR does - Writing the code metadata present in the IR in the proper sections when converting IR to binary - Support in wasm-decompiler for showing code metadata as comments in the pseudo-code All the features have corresponding tests. Support for code metadata is gated through the --enable-code-metadata feature. For reading/writing in the text format, --enable-annotations is also required. Missing features: Support for function-level code metadata (offset 0) Extensive validation in validator.cc (like making sure that all metadata instances are at the same code offset of an instruction)
Diffstat (limited to 'test/binary/code-metadata-section.txt')
-rw-r--r--test/binary/code-metadata-section.txt61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/binary/code-metadata-section.txt b/test/binary/code-metadata-section.txt
new file mode 100644
index 00000000..9625f602
--- /dev/null
+++ b/test/binary/code-metadata-section.txt
@@ -0,0 +1,61 @@
+;;; TOOL: run-objdump-gen-wasm
+;;; ARGS: -x
+magic
+version
+section(TYPE) {
+ count[1]
+ function params[0] results[1] i32
+}
+section(FUNCTION) {
+ count[1]
+ type[0]
+}
+section(MEMORY) {
+ count[1]
+ has_max[0]
+ initial[0]
+}
+section("metadata.code.test") {
+ function_count[1]
+ function_index[0]
+ ann_count[1]
+ ann_offset[1]
+ ann_data_size[1]
+ ann_data[1]
+}
+
+section(CODE) {
+ count[1]
+ func {
+ local_decls[0]
+ i32.const 1
+ return
+ }
+}
+(;; STDOUT ;;;
+
+code-metadata-section.wasm: file format wasm 0x1
+
+Section Details:
+
+Type[1]:
+ - type[0] () -> i32
+Function[1]:
+ - func[0] sig=0
+Memory[1]:
+ - memory[0] pages: initial=0
+Custom:
+ - name: "metadata.code.test"
+ - func[0]:
+ - meta[1]:
+ - 0000000: 01 .
+Code[1]:
+ - func[0] size=5
+
+Code Disassembly:
+
+000037 func[0]:
+ 000038: 41 01 | i32.const 1
+ 00003a: 0f | return
+ 00003b: 0b | end
+;;; STDOUT ;;)