From 5dab6a4533dbb5222be5b6309eea25115659bacf Mon Sep 17 00:00:00 2001 From: kcbanner Date: Sat, 19 Sep 2026 15:35:47 -0400 Subject: [PATCH] objdump: instead of crashing when using --strings and there is no string table, print a message --- lib/compiler/objdump.zig | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/compiler/objdump.zig b/lib/compiler/objdump.zig index c3507d9e66f3f616a50e454ae5350b4a5a50d2c3..94e3bec51b952c64c0b3065a34d54922e9b17ea4 100644 --- a/lib/compiler/objdump.zig +++ b/lib/compiler/objdump.zig @@ -828,19 +828,21 @@ const coff = struct { defer gpa.free(string_table); if (d.opts.strings) { - if (d.element(.@"table-header")) - try w.print( - \\String Table (0x{x} bytes): - \\ - , .{string_table.len}); + if (string_table.len > 0) { + if (d.element(.@"table-header")) + try w.print( + \\String Table (0x{x} bytes): + \\ + , .{string_table.len}); - var sr = Io.Reader.fixed(string_table[@sizeOf(u32)..]); - while (try sr.takeDelimiter(0)) |str| { - try w.writeAll(str); - try w.writeByte('\n'); - } + var sr = Io.Reader.fixed(string_table[@sizeOf(u32)..]); + while (try sr.takeDelimiter(0)) |str| { + try w.writeAll(str); + try w.writeByte('\n'); + } - if (d.element(.newlines)) try w.writeByte('\n'); + if (d.element(.newlines)) try w.writeByte('\n'); + } else try w.writeAll("String table not present\n"); } var sections: std.ArrayList(Section) = .empty; -- 2.54.0