| ... | ... | @@ -649,6 +649,8 @@ const WasmDumper = struct { |
| 649 | 649 | try parseDumpNames(reader, writer, data); |
| 650 | 650 | } else if (mem.eql(u8, name, "producers")) { |
| 651 | 651 | try parseDumpProducers(reader, writer, data); |
| 652 | } else if (mem.eql(u8, name, "target_features")) { |
| 653 | try parseDumpFeatures(reader, writer, data); |
| 652 | 654 | } |
| 653 | 655 | // TODO: Implement parsing and dumping other custom sections (such as relocations) |
| 654 | 656 | }, |
| ... | ... | @@ -902,4 +904,19 @@ const WasmDumper = struct { |
| 902 | 904 | } |
| 903 | 905 | } |
| 904 | 906 | } |
| 907 | |
| 908 | fn parseDumpFeatures(reader: anytype, writer: anytype, data: []const u8) !void { |
| 909 | const feature_count = try std.leb.readULEB128(u32, reader); |
| 910 | try writer.print("features {d}\n", .{feature_count}); |
| 911 | |
| 912 | var index: u32 = 0; |
| 913 | while (index < feature_count) : (index += 1) { |
| 914 | const prefix_byte = try std.leb.readULEB128(u8, reader); |
| 915 | const name_length = try std.leb.readULEB128(u32, reader); |
| 916 | const feature_name = data[reader.context.pos..][0..name_length]; |
| 917 | reader.context.pos += name_length; |
| 918 | |
| 919 | try writer.print("{c} {s}\n", .{ prefix_byte, feature_name }); |
| 920 | } |
| 921 | } |
| 905 | 922 | }; |