From 1f59b65d8befc8512ff9045bb371ea5ec379a78c Mon Sep 17 00:00:00 2001 From: Yuri Iozzelli Date: Fri, 25 Feb 2022 16:36:35 +0100 Subject: 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) --- src/binary.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/binary.h') diff --git a/src/binary.h b/src/binary.h index bd0a3de7..39e0f201 100644 --- a/src/binary.h +++ b/src/binary.h @@ -34,6 +34,7 @@ #define WABT_BINARY_SECTION_TARGET_FEATURES "target_features" #define WABT_BINARY_SECTION_DYLINK "dylink" #define WABT_BINARY_SECTION_DYLINK0 "dylink.0" +#define WABT_BINARY_SECTION_CODE_METADATA "metadata.code." #define WABT_FOREACH_BINARY_SECTION(V) \ V(Custom, custom, 0) \ -- cgit v1.2.3