Skip to content

Commit 5076fba

Browse files
committed
Fix MachO section handling.
1 parent f6ed8d8 commit 5076fba

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/MachO/MachOSection.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ end
9898

9999
handle(sections::MachOSections) = sections.handle
100100
lastindex(sections::MachOSections) = lastindex(sections.sections)
101-
getindex(sections::MachOSections, idx) = getindex(sections.sections, idx)
101+
function getindex(sections::MachOSections{H}, idx) where {H <: MachOHandle}
102+
section = sections.sections[idx]
103+
return MachOSectionRef(sections, section, UInt32(idx))
104+
end
102105

103106
Sections(segs::MachOSegments) = MachOSections(segs)
104107
Sections(oh::MachOHandle) = Sections(Segments(oh))
@@ -108,7 +111,7 @@ Sections(oh::MachOHandle) = Sections(Segments(oh))
108111
109112
Mach-O `SectionRef` type
110113
"""
111-
struct MachOSectionRef{H <: MachOHandle} <: Sections{H}
114+
struct MachOSectionRef{H <: MachOHandle} <: SectionRef{H}
112115
sections::MachOSections{H}
113116
section::MachOSection{H}
114117
idx::UInt32
@@ -117,4 +120,8 @@ end
117120
function SectionRef(sections::MachOSections, s::MachOSection, idx)
118121
return MachOSectionRef(sections, s, UInt32(idx))
119122
end
120-
@derefmethod is64bit(s::MachOSectionRef)
123+
deref(s::MachOSectionRef) = s.section
124+
sections(s::MachOSectionRef) = s.sections
125+
handle(s::MachOSectionRef) = handle(sections(s))
126+
section_number(s::MachOSectionRef) = s.idx
127+
@derefmethod is64bit(s::MachOSectionRef)

0 commit comments

Comments
 (0)