| ... | ... | @@ -3546,16 +3546,20 @@ fn objectSectionMapIndex( |
| 3546 | 3546 | try coff.symbols.ensureUnusedCapacity(gpa, 1); |
| 3547 | 3547 | const parent_ni = parent.node(coff); |
| 3548 | 3548 | var prev_oni: MappedFile.Node.Index.Optional = .none; |
| 3549 | | var next_it = parent_ni.children(&coff.mf); |
| 3550 | | while (next_it.next()) |next_ni| switch (std.mem.order( |
| 3551 | | u8, |
| 3552 | | name_slice, |
| 3553 | | coff.getNode(next_ni).object_section.name(coff).toSlice(coff), |
| 3554 | | )) { |
| 3555 | | .lt => break, |
| 3556 | | .eq => unreachable, |
| 3557 | | .gt => prev_oni = .wrap(next_ni), |
| 3558 | | }; |
| 3549 | { |
| 3550 | var child_oni = parent_ni.first(&coff.mf); |
| 3551 | while (child_oni.unwrap()) |child_ni| : (child_oni = child_ni.next(&coff.mf)) { |
| 3552 | switch (std.mem.order( |
| 3553 | u8, |
| 3554 | name_slice, |
| 3555 | coff.getNode(child_ni).object_section.name(coff).toSlice(coff), |
| 3556 | )) { |
| 3557 | .lt => break, |
| 3558 | .eq => unreachable, |
| 3559 | .gt => prev_oni = .wrap(child_ni), |
| 3560 | } |
| 3561 | } |
| 3562 | } |
| 3559 | 3563 | const ni = try parent_ni.addHeaderChildAfter(&coff.mf, gpa, prev_oni, .{ |
| 3560 | 3564 | .alignment = alignment, |
| 3561 | 3565 | }); |
| ... | ... | @@ -7025,7 +7029,7 @@ fn flushResized(coff: *Coff, ni: MappedFile.Node.Index) !void { |
| 7025 | 7029 | if (coff.isArchive() and coff.members.items.len > 0) { |
| 7026 | 7030 | const last_member = coff.members.items[coff.members.items.len - 1]; |
| 7027 | 7031 | // See .archive_member branch for reasoning |
| 7028 | | assert(Node.known.file.reverseChildren(&coff.mf).ni == last_member.content_ni.toOptional()); |
| 7032 | assert(Node.known.file.last(&coff.mf).unwrap().? == last_member.content_ni); |
| 7029 | 7033 | try coff.flushResized(last_member.content_ni); |
| 7030 | 7034 | } |
| 7031 | 7035 | }, |
| ... | ... | @@ -7717,30 +7721,31 @@ pub fn printNode( |
| 7717 | 7721 | if (mf_node.flags.has_content) " has_content" else "", |
| 7718 | 7722 | }); |
| 7719 | 7723 | } |
| 7720 | | var leaf = true; |
| 7721 | | var child_it = ni.children(&coff.mf); |
| 7722 | | while (child_it.next()) |child_ni| { |
| 7723 | | leaf = false; |
| 7724 | | try coff.printNode(tid, w, child_ni, indent + 1); |
| 7725 | | } |
| 7726 | | if (leaf) { |
| 7727 | | const file_loc = ni.fileLocation(&coff.mf, false); |
| 7728 | | if (file_loc.size == 0) return; |
| 7729 | | var address = file_loc.offset; |
| 7730 | | const line_len = 0x10; |
| 7731 | | var line_it = std.mem.window( |
| 7732 | | u8, |
| 7733 | | coff.mf.memory_map.memory[@intCast(file_loc.offset)..][0..@intCast(file_loc.size)], |
| 7734 | | line_len, |
| 7735 | | line_len, |
| 7736 | | ); |
| 7737 | | while (line_it.next()) |line_bytes| : (address += line_len) { |
| 7738 | | try w.splatByteAll(' ', indent + 1); |
| 7739 | | try w.print("{x:0>8} ", .{address}); |
| 7740 | | for (line_bytes) |byte| try w.print("{x:0>2} ", .{byte}); |
| 7741 | | try w.splatByteAll(' ', 3 * (line_len - line_bytes.len) + 1); |
| 7742 | | for (line_bytes) |byte| try w.writeByte(if (std.ascii.isPrint(byte)) byte else '.'); |
| 7743 | | try w.writeByte('\n'); |
| 7724 | if (ni.first(&coff.mf).unwrap()) |first_ni| { |
| 7725 | // non-leaf, just print children |
| 7726 | var child_ni = first_ni; |
| 7727 | while (true) { |
| 7728 | try coff.printNode(tid, w, child_ni, indent + 1); |
| 7729 | child_ni = child_ni.next(&coff.mf).unwrap() orelse break; |
| 7744 | 7730 | } |
| 7731 | return; |
| 7732 | } |
| 7733 | const file_loc = ni.fileLocation(&coff.mf, false); |
| 7734 | if (file_loc.size == 0) return; |
| 7735 | var address = file_loc.offset; |
| 7736 | const line_len = 0x10; |
| 7737 | var line_it = std.mem.window( |
| 7738 | u8, |
| 7739 | coff.mf.memory_map.memory[@intCast(file_loc.offset)..][0..@intCast(file_loc.size)], |
| 7740 | line_len, |
| 7741 | line_len, |
| 7742 | ); |
| 7743 | while (line_it.next()) |line_bytes| : (address += line_len) { |
| 7744 | try w.splatByteAll(' ', indent + 1); |
| 7745 | try w.print("{x:0>8} ", .{address}); |
| 7746 | for (line_bytes) |byte| try w.print("{x:0>2} ", .{byte}); |
| 7747 | try w.splatByteAll(' ', 3 * (line_len - line_bytes.len) + 1); |
| 7748 | for (line_bytes) |byte| try w.writeByte(if (std.ascii.isPrint(byte)) byte else '.'); |
| 7749 | try w.writeByte('\n'); |
| 7745 | 7750 | } |
| 7746 | 7751 | } |