aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/CheckObject.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-12-13 11:41:51 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-12-13 11:41:51 +0100
commitc4519d6bbae661b2e569b9b86887020a3013414e (patch)
treeed4f4e8480992bee90361031a8d52c2017e78a41 /lib/std/Build/Step/CheckObject.zig
parent92cca7fbf155602584dee294d04ee0b33135a25e (diff)
downloadzig-c4519d6bbae661b2e569b9b86887020a3013414e.tar.gz
zig-c4519d6bbae661b2e569b9b86887020a3013414e.zip
lib/std/Build/CheckObject: implement for Wasm
Diffstat (limited to 'lib/std/Build/Step/CheckObject.zig')
-rw-r--r--lib/std/Build/Step/CheckObject.zig23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig
index f837f509dd..b8f7dee6cc 100644
--- a/lib/std/Build/Step/CheckObject.zig
+++ b/lib/std/Build/Step/CheckObject.zig
@@ -2221,7 +2221,6 @@ const WasmDumper = struct {
const symtab_label = "symbols";
fn parseAndDump(step: *Step, kind: Check.Kind, bytes: []const u8) ![]const u8 {
- _ = kind;
const gpa = step.owner.allocator;
var fbs = std.io.fixedBufferStream(bytes);
const reader = fbs.reader();
@@ -2238,15 +2237,21 @@ const WasmDumper = struct {
errdefer output.deinit();
const writer = output.writer();
- while (reader.readByte()) |current_byte| {
- const section = std.meta.intToEnum(std.wasm.Section, current_byte) catch {
- return step.fail("Found invalid section id '{d}'", .{current_byte});
- };
+ switch (kind) {
+ .headers => {
+ while (reader.readByte()) |current_byte| {
+ const section = std.meta.intToEnum(std.wasm.Section, current_byte) catch {
+ return step.fail("Found invalid section id '{d}'", .{current_byte});
+ };
- const section_length = try std.leb.readULEB128(u32, reader);
- try parseAndDumpSection(step, section, bytes[fbs.pos..][0..section_length], writer);
- fbs.pos += section_length;
- } else |_| {} // reached end of stream
+ const section_length = try std.leb.readULEB128(u32, reader);
+ try parseAndDumpSection(step, section, bytes[fbs.pos..][0..section_length], writer);
+ fbs.pos += section_length;
+ } else |_| {} // reached end of stream
+ },
+
+ else => return step.fail("invalid check kind for Wasm file format: {s}", .{@tagName(kind)}),
+ }
return output.toOwnedSlice();
}