Step/CheckObject: handle stab entries when dumping MachO symtab

This commit is contained in:
Jakub Konka 2024-05-24 22:32:14 +02:00
parent ed7073c630
commit 8e52d54c25

View File

@ -1087,9 +1087,25 @@ const MachODumper = struct {
try writer.writeAll(symtab_label ++ "\n"); try writer.writeAll(symtab_label ++ "\n");
for (ctx.symtab.items) |sym| { for (ctx.symtab.items) |sym| {
if (sym.stab()) continue;
const sym_name = ctx.getString(sym.n_strx); const sym_name = ctx.getString(sym.n_strx);
if (sym.sect()) { if (sym.stab()) {
const tt = switch (sym.n_type) {
macho.N_SO => "SO",
macho.N_OSO => "OSO",
macho.N_BNSYM => "BNSYM",
macho.N_ENSYM => "ENSYM",
macho.N_FUN => "FUN",
macho.N_GSYM => "GSYM",
macho.N_STSYM => "STSYM",
else => "UNKNOWN STAB",
};
try writer.print("{x}", .{sym.n_value});
if (sym.n_sect > 0) {
const sect = ctx.sections.items[sym.n_sect - 1];
try writer.print(" ({s},{s})", .{ sect.segName(), sect.sectName() });
}
try writer.print(" {s} (stab) {s}\n", .{ tt, sym_name });
} else if (sym.sect()) {
const sect = ctx.sections.items[sym.n_sect - 1]; const sect = ctx.sections.items[sym.n_sect - 1];
try writer.print("{x} ({s},{s})", .{ try writer.print("{x} ({s},{s})", .{
sym.n_value, sym.n_value,