authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-13 09:14:35+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-13 09:14:35+02:00
log2d537da6bd0faead48d7b230e694ccdb76560e4e
tree060218ed65608f94c9d94d8c68c53e4bd901dbab
parent5d619da2de1e6f906082640b75322553f8fef7c0

Step.CheckObject: support dumping raw section contents for MachO


1 files changed, 16 insertions(+), 0 deletions(-)

lib/std/Build/Step/CheckObject.zig+16
...@@ -1578,6 +1578,11 @@ const MachODumper = struct {...@@ -1578,6 +1578,11 @@ const MachODumper = struct {
1578 it.pos = curr;1578 it.pos = curr;
1579 }1579 }
1580 }1580 }
1581
1582 fn dumpSection(ctx: ObjectContext, sect: macho.section_64, writer: anytype) !void {
1583 const data = ctx.data[sect.offset..][0..sect.size];
1584 try writer.print("{s}", .{data});
1585 }
1581 };1586 };
15821587
1583 fn parseAndDumpObject(step: *Step, check: Check, bytes: []const u8) ![]const u8 {1588 fn parseAndDumpObject(step: *Step, check: Check, bytes: []const u8) ![]const u8 {
...@@ -1666,6 +1671,17 @@ const MachODumper = struct {...@@ -1666,6 +1671,17 @@ const MachODumper = struct {
1666 return step.fail("no exports data found", .{});1671 return step.fail("no exports data found", .{});
1667 },1672 },
16681673
1674 .dump_section => {
1675 const name = mem.sliceTo(@as([*:0]const u8, @ptrCast(check.data.items.ptr + check.payload.dump_section)), 0);
1676 const sep_index = mem.indexOfScalar(u8, name, ',') orelse
1677 return step.fail("invalid section name: {s}", .{name});
1678 const segname = name[0..sep_index];
1679 const sectname = name[sep_index + 1 ..];
1680 const sect = ctx.getSectionByName(segname, sectname) orelse
1681 return step.fail("section '{s}' not found", .{name});
1682 try ctx.dumpSection(sect, writer);
1683 },
1684
1669 else => return step.fail("invalid check kind for MachO file format: {s}", .{@tagName(check.kind)}),1685 else => return step.fail("invalid check kind for MachO file format: {s}", .{@tagName(check.kind)}),
1670 }1686 }
16711687