From c70d05ed2cf1c993638c61d1dd1f772bcaa19f14 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 11 Dec 2023 17:34:34 +0100 Subject: [PATCH] zacho: dump *_DYLIB load commands --- src/ZachO.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ZachO.zig b/src/ZachO.zig index a289a3f..69285aa 100644 --- a/src/ZachO.zig +++ b/src/ZachO.zig @@ -191,6 +191,12 @@ pub fn printLoadCommands(self: ZachO, writer: anytype) !void { .DYLD_INFO_ONLY => try printDyldInfoOnlyLC(fmt, lc, writer), .UUID => try printUuidLC(fmt, lc, writer), .RPATH => try printRpathLC(fmt, lc, writer), + .ID_DYLIB, + .LOAD_DYLIB, + .LOAD_WEAK_DYLIB, + .LOAD_UPWARD_DYLIB, + .REEXPORT_DYLIB, + => try printDylibLC(fmt, lc, writer), else => {}, } @@ -215,6 +221,15 @@ fn printUuidLC(f: anytype, lc: macho.LoadCommandIterator.LoadCommand, writer: an try writer.print(f.fmt("s"), .{ "UUID:", encoded }); } +fn printDylibLC(f: anytype, lc: macho.LoadCommandIterator.LoadCommand, writer: anytype) !void { + const name = lc.getDylibPathName(); + const cmd = lc.cast(macho.dylib_command).?; + try writer.print(f.fmt("s"), .{ "Name:", name }); + try writer.print(f.fmt("d"), .{ "Timestamp:", cmd.dylib.timestamp }); + try writer.print(f.fmt("d"), .{ "Current version:", cmd.dylib.current_version }); + try writer.print(f.fmt("d"), .{ "Compat version:", cmd.dylib.compatibility_version }); +} + fn printDyldInfoOnlyLC(f: anytype, lc: macho.LoadCommandIterator.LoadCommand, writer: anytype) !void { const cmd = lc.cast(macho.dyld_info_command).?; try writer.print(f.fmt("x"), .{ "Rebase offset:", cmd.rebase_off });