Skip to content

Commit 6eefb9e

Browse files
committed
Improve printing of MachO load commands
1 parent 88dd0fe commit 6eefb9e

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/MachO/LoadCmds/DylibCmds.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct MachOLoadDylibCmd{H <: MachOHandle} <: MachOLoadCmd{H}
4444
name::String
4545
end
4646

47+
show(io::IO, lc::MachOLoadDylibCmd) = write(io, "LoadDylibCmd: \"$(dylib_name(lc))\"")
48+
4749

4850
"""
4951
MachOIdDylibCmd
@@ -59,6 +61,7 @@ struct MachOIdDylibCmd{H <: MachOHandle} <: MachOLoadCmd{H}
5961
stub::MachODylibStub
6062
name::String
6163
end
64+
show(io::IO, lc::MachOIdDylibCmd) = write(io, "IdDylibCmd: \"$(dylib_name(lc))\"")
6265

6366
"""
6467
MachODylibCmd
@@ -134,6 +137,8 @@ struct MachORPathCmd{H <: MachOHandle} <: MachOLoadCmd{H}
134137
rpath::String
135138
end
136139

140+
show(io::IO, lc::MachORPathCmd) = write(io, "RPathCmd: \"$(rpath(lc))\"")
141+
137142
"""
138143
MachOLoadCmd(oh::MachOHeader, CT::Type{MachORPathCmd}, header)
139144
@@ -153,4 +158,4 @@ function MachOLoadCmd(oh::H, CT::Type{CTT}, header) where {CTT <: MachORPathCmd}
153158
end
154159

155160
rpath(cmd::MachORPathCmd) = cmd.rpath
156-
@derefmethod rpath(cmd::MachOLoadCmdRef{H,MachORPathCmd{H}}) where {H <: MachOHandle}
161+
@derefmethod rpath(cmd::MachOLoadCmdRef{H,MachORPathCmd{H}}) where {H <: MachOHandle}

src/MachO/LoadCmds/SegmentCmds.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ end
5252
flags::UInt32
5353
end
5454

55+
show(io::IO, lc::MachOSegment32Cmd) = write(io, "Segment32Cmd \"$(segment_name(lc))\"")
56+
show(io::IO, lc::MachOSegment64Cmd) = write(io, "Segment64Cmd \"$(segment_name(lc))\"")
57+
5558
segment_name(cmd::MachOSegmentCmd) = cmd.segname
5659
segment_offset(cmd::MachOSegmentCmd) = cmd.fileoff
5760
segment_file_size(cmd::MachOSegmentCmd) = cmd.filesize
@@ -62,4 +65,4 @@ segment_num_sections(cmd::MachOSegmentCmd) = cmd.nsects
6265
@derefmethod segment_offset(cmd::MachOLoadCmdRef{H,S}) where {H <: MachOHandle} where {S <: MachOSegmentCmd}
6366
@derefmethod segment_file_size(cmd::MachOLoadCmdRef{H,S}) where {H <: MachOHandle} where {S <: MachOSegmentCmd}
6467
@derefmethod segment_memory_size(cmd::MachOLoadCmdRef{H,S}) where {H <: MachOHandle} where {S <: MachOSegmentCmd}
65-
@derefmethod segment_num_sections(cmd::MachOLoadCmdRef{H,S}) where {H <: MachOHandle} where {S <: MachOSegmentCmd}
68+
@derefmethod segment_num_sections(cmd::MachOLoadCmdRef{H,S}) where {H <: MachOHandle} where {S <: MachOSegmentCmd}

src/MachO/LoadCmds/SymtabCmds.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
stroff::UInt32
55
strsize::UInt32
66
end
7+
8+
show(io::IO, lc::MachOSymtabCmd) = write(io, "SymtabCmd")
9+
710
# Accessors for symbols info
811
symtab_symbols_offset(cmd::MachOSymtabCmd) = cmd.symoff
912
symtab_num_symbols(cmd::MachOSymtabCmd) = cmd.nsyms
@@ -43,4 +46,4 @@ end
4346
nextrel::UInt32
4447
locreloff::UInt32
4548
nlocrel::UInt32
46-
end
49+
end

src/MachO/MachOLoadCmd.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ function show(io::IO, lcs::MachOLoadCmds)
214214
print(io, "MachO Load Commands")
215215
for lc in lcs
216216
print(io, "\n ")
217-
showcompact(io, lc)
217+
show(io, lc)
218218
end
219219
end
220220

0 commit comments

Comments
 (0)