diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-05-13 09:14:35 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-05-13 09:14:35 +0200 |
| commit | 2d537da6bd0faead48d7b230e694ccdb76560e4e (patch) | |
| tree | 060218ed65608f94c9d94d8c68c53e4bd901dbab /lib/std/Build | |
| parent | 5d619da2de1e6f906082640b75322553f8fef7c0 (diff) | |
| download | zig-2d537da6bd0faead48d7b230e694ccdb76560e4e.tar.gz zig-2d537da6bd0faead48d7b230e694ccdb76560e4e.zip | |
Step.CheckObject: support dumping raw section contents for MachO
Diffstat (limited to 'lib/std/Build')
| -rw-r--r-- | lib/std/Build/Step/CheckObject.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig index 6997216b41..08b3d4ae99 100644 --- a/lib/std/Build/Step/CheckObject.zig +++ b/lib/std/Build/Step/CheckObject.zig @@ -1578,6 +1578,11 @@ const MachODumper = struct { it.pos = curr; } } + + fn dumpSection(ctx: ObjectContext, sect: macho.section_64, writer: anytype) !void { + const data = ctx.data[sect.offset..][0..sect.size]; + try writer.print("{s}", .{data}); + } }; fn parseAndDumpObject(step: *Step, check: Check, bytes: []const u8) ![]const u8 { @@ -1666,6 +1671,17 @@ const MachODumper = struct { return step.fail("no exports data found", .{}); }, + .dump_section => { + const name = mem.sliceTo(@as([*:0]const u8, @ptrCast(check.data.items.ptr + check.payload.dump_section)), 0); + const sep_index = mem.indexOfScalar(u8, name, ',') orelse + return step.fail("invalid section name: {s}", .{name}); + const segname = name[0..sep_index]; + const sectname = name[sep_index + 1 ..]; + const sect = ctx.getSectionByName(segname, sectname) orelse + return step.fail("section '{s}' not found", .{name}); + try ctx.dumpSection(sect, writer); + }, + else => return step.fail("invalid check kind for MachO file format: {s}", .{@tagName(check.kind)}), } |
