Skip to content

Commit

Permalink
zacho: dump *_DYLIB load commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Dec 11, 2023
1 parent a00bfb7 commit c70d05e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ZachO.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {},
}

Expand All @@ -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 });
Expand Down

0 comments on commit c70d05e

Please sign in to comment.