| ... | @@ -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 | }; |
| 1582 | | 1587 | |
| 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 | }, |
| 1668 | | 1673 | |
| | 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 | } |
| 1671 | | 1687 | |