authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2026-06-05 01:55:36-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2026-06-23 00:26:56-04:00
log815ef725235cd4f5f0caed906bfe868225994f89
tree4382bcc66e8ddc7a2ba6d82f6b43c4df8d1257d5
parent9df2ca0d3382170a2d616d110073e7be25793778

objdump: fix --relocs not triggering object dump

- Reformat table headers

1 files changed, 14 insertions(+), 9 deletions(-)

lib/compiler/objdump.zig+14-9
...@@ -477,6 +477,7 @@ const coff = struct {...@@ -477,6 +477,7 @@ const coff = struct {
477477
478 if (opts.section_headers or478 if (opts.section_headers or
479 opts.file_headers or479 opts.file_headers or
480 opts.relocs or
480 opts.strings or481 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 Flags638 \\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);
693694
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});
698699
699 try w.print(700 if (opts.symbols)
700 \\Symbols ({s}):701 try w.print(
701 \\ Ord Value Sect Type Storage Name702 \\Symbols in {s}:
702 \\703 \\ Ord Value Sect Type Storage Name
703 , .{obj_name});704 \\
705 , .{obj_name});
704706
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);
735737
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 }
879884
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 }