| ... | @@ -477,6 +477,7 @@ const coff = struct { | ... | @@ -477,6 +477,7 @@ const coff = struct { |
| 477 | | 477 | |
| 478 | if (opts.section_headers or | 478 | if (opts.section_headers or |
| 479 | opts.file_headers or | 479 | opts.file_headers or |
| | 480 | opts.relocs or |
| 480 | opts.strings or | 481 | opts.strings or |
| 481 | opts.symbols) | 482 | opts.symbols) |
| 482 | { | 483 | { |
| ... | @@ -633,7 +634,7 @@ const coff = struct { | ... | @@ -633,7 +634,7 @@ const coff = struct { |
| 633 | if (load_sections) { | 634 | if (load_sections) { |
| 634 | if (opts.section_headers) | 635 | if (opts.section_headers) |
| 635 | try w.print( | 636 | try w.print( |
| 636 | \\Sections ({s}): | 637 | \\Sections in {s}: |
| 637 | \\Num Name RVA Virt Size Data Size & Data & Relocs & Lines # Relocs # Lines Flags | 638 | \\Num Name RVA Virt Size Data Size & Data & Relocs & Lines # Relocs # Lines Flags |
| 638 | \\ | 639 | \\ |
| 639 | , .{obj_name}); | 640 | , .{obj_name}); |
| ... | @@ -691,16 +692,17 @@ const coff = struct { | ... | @@ -691,16 +692,17 @@ const coff = struct { |
| 691 | if (opts.relocs) | 692 | if (opts.relocs) |
| 692 | try symbol_names.ensureUnusedCapacity(gpa, header.number_of_symbols); | 693 | try symbol_names.ensureUnusedCapacity(gpa, header.number_of_symbols); |
| 693 | | 694 | |
| 694 | if (opts.symbols) { | 695 | if (opts.symbols or opts.relocs) { |
| 695 | if (header.pointer_to_symbol_table > 0) { | 696 | if (header.pointer_to_symbol_table > 0) { |
| 696 | fr.seekTo(file_location + header.pointer_to_symbol_table) catch |err| | 697 | fr.seekTo(file_location + header.pointer_to_symbol_table) catch |err| |
| 697 | return failParse(opts, "unable to seek to symbol table: {t}", .{err}); | 698 | return failParse(opts, "unable to seek to symbol table: {t}", .{err}); |
| 698 | | 699 | |
| 699 | try w.print( | 700 | if (opts.symbols) |
| 700 | \\Symbols ({s}): | 701 | try w.print( |
| 701 | \\ Ord Value Sect Type Storage Name | 702 | \\Symbols in {s}: |
| 702 | \\ | 703 | \\ Ord Value Sect Type Storage Name |
| 703 | , .{obj_name}); | 704 | \\ |
| | 705 | , .{obj_name}); |
| 704 | | 706 | |
| 705 | const symbol_size = std.coff.Symbol.sizeOf(); | 707 | const symbol_size = std.coff.Symbol.sizeOf(); |
| 706 | var symbol_i: u32 = 0; | 708 | var symbol_i: u32 = 0; |
| ... | @@ -733,6 +735,9 @@ const coff = struct { | ... | @@ -733,6 +735,9 @@ const coff = struct { |
| 733 | if (opts.relocs) | 735 | if (opts.relocs) |
| 734 | symbol_names.appendNTimesAssumeCapacity(name, 1 + symbol.number_of_aux_symbols); | 736 | symbol_names.appendNTimesAssumeCapacity(name, 1 + symbol.number_of_aux_symbols); |
| 735 | | 737 | |
| | 738 | if (!opts.symbols) |
| | 739 | continue; |
| | 740 | |
| 736 | try w.print("{x: >4} {x:0>8} ", .{ symbol_i, symbol.value }); | 741 | try w.print("{x: >4} {x:0>8} ", .{ symbol_i, symbol.value }); |
| 737 | try switch (symbol.section_number) { | 742 | try switch (symbol.section_number) { |
| 738 | .UNDEFINED => w.writeAll("UNDEF"), | 743 | .UNDEFINED => w.writeAll("UNDEF"), |
| ... | @@ -877,8 +882,8 @@ const coff = struct { | ... | @@ -877,8 +882,8 @@ const coff = struct { |
| 877 | } | 882 | } |
| 878 | } | 883 | } |
| 879 | | 884 | |
| 880 | try w.writeByte('\n'); | 885 | if (opts.symbols) try w.writeByte('\n'); |
| 881 | } else { | 886 | } else if (opts.symbols) { |
| 882 | try w.writeAll("No symbol table found\n"); | 887 | try w.writeAll("No symbol table found\n"); |
| 883 | } | 888 | } |
| 884 | } | 889 | } |