mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
CheckObjectStep: parse and dump target_features
When an object file or binary contains the target_features section we can now parse and then dump its contents in string format so we can use them in our linker tests to verify the features section.
This commit is contained in:
parent
777bcbf968
commit
b14f605dd7
@ -649,6 +649,8 @@ const WasmDumper = struct {
|
||||
try parseDumpNames(reader, writer, data);
|
||||
} else if (mem.eql(u8, name, "producers")) {
|
||||
try parseDumpProducers(reader, writer, data);
|
||||
} else if (mem.eql(u8, name, "target_features")) {
|
||||
try parseDumpFeatures(reader, writer, data);
|
||||
}
|
||||
// TODO: Implement parsing and dumping other custom sections (such as relocations)
|
||||
},
|
||||
@ -902,4 +904,19 @@ const WasmDumper = struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parseDumpFeatures(reader: anytype, writer: anytype, data: []const u8) !void {
|
||||
const feature_count = try std.leb.readULEB128(u32, reader);
|
||||
try writer.print("features {d}\n", .{feature_count});
|
||||
|
||||
var index: u32 = 0;
|
||||
while (index < feature_count) : (index += 1) {
|
||||
const prefix_byte = try std.leb.readULEB128(u8, reader);
|
||||
const name_length = try std.leb.readULEB128(u32, reader);
|
||||
const feature_name = data[reader.context.pos..][0..name_length];
|
||||
reader.context.pos += name_length;
|
||||
|
||||
try writer.print("{c} {s}\n", .{ prefix_byte, feature_name });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user