Skip to content

Commit

Permalink
Further 1.0 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat committed Aug 8, 2018
1 parent 8e935f3 commit 9f6944e
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Abstract/DynamicLink.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Export DynamicLinks API
export DynamicLinks,
getindex, endof, length, iterate, lastindex, eltype,
getindex, length, iterate, lastindex, eltype,
handle, header

# Export Dynamic Link API
Expand Down
4 changes: 2 additions & 2 deletions src/Abstract/ObjectHandle.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Export ObjectHandle API
export ObjectHandle,
readmeta,
seek, seekstart, skip, start, iostream, position, read, readuntil, eof,
seek, seekstart, skip, iostream, position, read, readuntil, eof,
endianness, is64bit, isrelocatable, isexecutable, islibrary, isdynamic,
mangle_section_name, mangle_symbol_name, handle, header, format_string,
section_header_offset, section_header_size, section_header_type,
Expand All @@ -12,7 +12,7 @@ export ObjectHandle,
export MagicMismatch

# Import methods for extension
import Base: seek, seekstart, skip, start, position, read, readuntil, eof,
import Base: seek, seekstart, skip, position, read, readuntil, eof,
getindex
import StructIO: unpack

Expand Down
20 changes: 10 additions & 10 deletions src/Abstract/Section.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Export Sections API
export Sections,
getindex, endof, length, lastindex, iterate, eltype,
find, findfirst,
getindex, length, lastindex, iterate, eltype,
findall, findfirst,
handle, header, format_string

# Export Section API
Expand All @@ -14,7 +14,7 @@ export SectionRef,
read, seekstart, seek, eof, section_number

# Import Base methods for extension
import Base: read, seek, seekstart, eof, length, eltype, find,
import Base: read, seek, seekstart, eof, length, eltype, findall,
findfirst, iterate, lastindex

"""
Expand All @@ -38,7 +38,7 @@ in emphasis:
- eltype()
### Search
- find()
- findall()
- findfirst()
### Misc.
Expand Down Expand Up @@ -66,20 +66,20 @@ function getindex(sections::Sections, idx)
end

"""
find(sections::Sections, name::String)
findall(sections::Sections, name::String)
Return a list of sections that match the given `name`.
"""
function find(sections::Sections, name::AbstractString)
return find(sections, [name])
function findall(sections::Sections, name::AbstractString)
return findall(sections, [name])
end

"""
find(sections::Sections, name::String)
findall(sections::Sections, name::String)
Return a list of sections that match one of the given `names`.
"""
function find(sections::Sections, names::Vector{S}) where {S <: AbstractString}
function findall(sections::Sections, names::Vector{S}) where {S <: AbstractString}
return [s for s in sections if section_name(s) in names]
end

Expand All @@ -98,7 +98,7 @@ end
Return the first section that matches on of the given `names`.
"""
function findfirst(sections::Sections, names::Vector{String})
results = find(sections, names)
results = findall(sections, names)
if isempty(results)
error("Could not find any sections that match $(names)")
end
Expand Down
4 changes: 2 additions & 2 deletions src/Abstract/Segment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export Segment, deref, segment_name, segment_offset, segment_file_size,
export SegmentRef, segment_number

# Import Base stuff for extension
import Base: getindex, length, eltype, find, findfirst, iterate, lastindex
import Base: getindex, length, eltype, findfirst, findall, iterate, lastindex

"""
Segments
Expand All @@ -31,7 +31,7 @@ in emphasis:
- eltype()
### Search
- find()
- findall()
- findfirst()
### Misc.
Expand Down
2 changes: 1 addition & 1 deletion src/Abstract/Symbol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Export Symbols API
export Symbols,
getindex, endof, length, iterate, lastindex, eltype,
getindex, length, iterate, lastindex, eltype,
handle, header

# Export SymtabEntry API
Expand Down
6 changes: 3 additions & 3 deletions src/COFF/COFF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ using StructIO
using ObjectFile
import ObjectFile: DynamicLink, DynamicLinks, RPath, ObjectHandle, Section, Sections, SectionRef,
Segment, Segments, SegmentRef, StrTab, Symbols, SymtabEntry, SymbolRef,
getindex, endof, length, lastindex, iterate, eltype, handle, header, path,
getindex, length, lastindex, iterate, eltype, handle, header, path,
rpaths, canonical_rpaths, find_library, readmeta, seek, seekstart, skip,
iostream, position, read, readuntil, eof, endianness, is64bit, isrelocatable,
isexecutable, islibrary, isdynamic, mangle_section_name, mangle_symbol_name,
format_string, section_header_offset, section_header_size, section_header_type,
segment_header_offset, segment_header_size, segment_header_type, start,
segment_header_offset, segment_header_size, segment_header_type, startaddr,
symtab_entry_offset, symtab_entry_size, symtab_entry_type, find_libraries,
find, findfirst, deref, contents, section_name, section_size,
findfirst, deref, contents, section_name, section_size,
section_offset, section_address, section_number, segment_name, segment_offset,
segment_file_size, segment_memory_size, segment_address, strtab_lookup,
symbol_name, symbol_value, isundef, isglobal, islocal, isweak, symbol_number
Expand Down
2 changes: 1 addition & 1 deletion src/COFF/COFFHandle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ is64bit(oh::COFFHandle) = coff_header_is64bit(header(oh))
isrelocatable(oh::COFFHandle) = isrelocatable(header(oh))
isexecutable(oh::COFFHandle) = isexecutable(header(oh))
islibrary(oh::COFFHandle) = islibrary(header(oh))
isdynamic(oh::COFFHandle) = !isempty(find(Sections(oh), [".idata"]))
isdynamic(oh::COFFHandle) = !isempty(findall(Sections(oh), [".idata"]))
mangle_section_name(oh::COFFHandle, name::AbstractString) = string(".", name)
function mangle_symbol_name(oh::COFFHandle, name::AbstractString)
# sob
Expand Down
6 changes: 3 additions & 3 deletions src/ELF/ELF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ using StructIO
using ObjectFile
import ObjectFile: DynamicLink, DynamicLinks, RPath, ObjectHandle, Section, Sections, SectionRef,
Segment, Segments, SegmentRef, StrTab, Symbols, SymtabEntry, SymbolRef,
getindex, endof, length, iterate, lastindex, eltype, handle, header, path,
getindex, length, iterate, lastindex, eltype, handle, header, path,
rpaths, canonical_rpaths, find_library, readmeta, seek, seekstart, skip,
iostream, position, read, readuntil, eof, endianness, is64bit, isrelocatable,
isexecutable, islibrary, isdynamic, mangle_section_name, mangle_symbol_name,
format_string, section_header_offset, section_header_size, section_header_type,
segment_header_offset, segment_header_size, segment_header_type, start,
segment_header_offset, segment_header_size, segment_header_type, startaddr,
symtab_entry_offset, symtab_entry_size, symtab_entry_type, find_libraries,
find, findfirst, deref, contents, section_name, section_size,
findfirst, deref, contents, section_name, section_size,
section_offset, section_address, section_number, segment_name, segment_offset,
segment_file_size, segment_memory_size, segment_address, strtab_lookup,
symbol_name, symbol_value, isundef, isglobal, islocal, isweak, symbol_number
Expand Down
4 changes: 2 additions & 2 deletions src/ELF/ELFHandle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export ELFHandle

# Import Base methods
import Base: start, getindex
import Base: getindex


"""
Expand Down Expand Up @@ -72,7 +72,7 @@ is64bit(oh::ELFHandle) = elf_internal_is64bit(oh.ei)
isrelocatable(oh::ELFHandle) = header(oh).e_type == ET_REL
isexecutable(oh::ELFHandle) = header(oh).e_type == ET_EXEC
islibrary(oh::ELFHandle) = header(oh).e_type == ET_DYN
isdynamic(oh::ELFHandle) = !isempty(find(Sections(oh), ".dynamic"))
isdynamic(oh::ELFHandle) = !isempty(findall(Sections(oh), ".dynamic"))
mangle_section_name(oh::ELFHandle, name::AbstractString) = string(".", name)
mangle_symbol_name(oh::ELFHandle, name::AbstractString) = name
format_string(::Type{H}) where {H <: ELFHandle} = "ELF"
Expand Down
2 changes: 1 addition & 1 deletion src/ELF/ELFRelocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end
deref(x::RelocationRef) = x.reloc

entrysize{T}(s::Relocations{T}) = sizeof(T)
endof{T}(s::Relocations{T}) = div(s.sec.header.sh_size,entrysize(s))
lastindex{T}(s::Relocations{T}) = div(s.sec.header.sh_size,entrysize(s))
length(r::Relocations) = lastindex(r)
function getindex{T}(s::Relocations{T},n)
if n < 1 || n > length(s)
Expand Down
4 changes: 2 additions & 2 deletions src/ELF/ELFSymbol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ function Symbols(oh::H) where {H <: ELFHandle}
sections = Sections(oh)
# First, try to load `.symtab`. If we can't load that guy, we'll fall back
# to `.dynsym` which has less information, but is more likely to exist.
dyn_sections = find(sections, ".symtab")
dyn_sections = findall(sections, ".symtab")
if !isempty(dyn_sections)
return ELFSymbols(first(dyn_sections))
end

dyn_sections = find(sections, ".dynsym")
dyn_sections = findall(sections, ".dynsym")
if !isempty(dyn_sections)
return ELFSymbols(first(dyn_sections))
end
Expand Down
6 changes: 3 additions & 3 deletions src/MachO/MachO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ using StructIO
using ObjectFile
import ObjectFile: DynamicLink, DynamicLinks, RPath, ObjectHandle, Section, Sections, SectionRef,
Segment, Segments, SegmentRef, StrTab, Symbols, SymtabEntry, SymbolRef,
getindex, endof, length, iterate, lastindex, eltype, handle, header, path,
getindex, length, iterate, lastindex, eltype, handle, header, path,
rpaths, canonical_rpaths, find_library, readmeta, seek, seekstart, skip,
iostream, position, read, readuntil, eof, endianness, is64bit, isrelocatable,
isexecutable, islibrary, isdynamic, mangle_section_name, mangle_symbol_name,
format_string, section_header_offset, section_header_size, section_header_type,
segment_header_offset, segment_header_size, segment_header_type, start,
segment_header_offset, segment_header_size, segment_header_type, startaddr,
symtab_entry_offset, symtab_entry_size, symtab_entry_type, find_libraries,
find, findfirst, deref, contents, section_name, section_size,
findfirst, deref, contents, section_name, section_size,
section_offset, section_address, section_number, segment_name, segment_offset,
segment_file_size, segment_memory_size, segment_address, strtab_lookup,
symbol_name, symbol_value, isundef, isglobal, islocal, isweak, symbol_number
Expand Down
4 changes: 2 additions & 2 deletions src/MachO/MachODynamicLink.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct MachODynamicLinks{H <: MachOHandle, C <: MachOLoadCmdRef{H,MachOLoadDylib
end

function MachODynamicLinks(lcs::MachOLoadCmds)
ld_cmds = find(lcs, [MachOLoadDylibCmd])
ld_cmds = findall(lcs, [MachOLoadDylibCmd])
return MachODynamicLinks(handle(lcs), ld_cmds)
end
MachODynamicLinks(oh::MachOHandle) = MachODynamicLinks(MachOLoadCmds(oh))
Expand Down Expand Up @@ -44,7 +44,7 @@ struct MachORPath{H <: MachOHandle} <: RPath{H}
end

function MachORPath(lcs::MachOLoadCmds)
cmds = find(lcs, [MachORPathCmd])
cmds = findall(lcs, [MachORPathCmd])
return MachORPath(handle(lcs), cmds)
end

Expand Down
2 changes: 1 addition & 1 deletion src/MachO/MachOHandle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ is64bit(oh::MachOHandle) = macho_is64bit(header(oh).magic)
isrelocatable(oh::MachOHandle) = header(oh).filetype == MH_OBJECT
isexecutable(oh::MachOHandle) = header(oh).filetype == MH_EXECUTE
islibrary(oh::MachOHandle) = header(oh).filetype == MH_DYLIB
isdynamic(oh::MachOHandle) = !isempty(find(MachOLoadCmds(oh), [MachOLoadDylibCmd]))
isdynamic(oh::MachOHandle) = !isempty(findall(MachOLoadCmds(oh), [MachOLoadDylibCmd]))
mangle_section_names(oh::MachOHandle, name) = string("__", name)
mangle_symbol_name(oh::MachOHandle, name::AbstractString) = string("_", name)
format_string(::Type{H}) where {H <: MachOHandle} = "MachO"
Expand Down
8 changes: 4 additions & 4 deletions src/MachO/MachOLoadCmd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ end

# Searching
"""
find(lcs::MachOLoadCmds, lc_types::Vector{Type})
findall(lcs::MachOLoadCmds, lc_types::Vector{Type})
Given a list of `Type`s, filter out all load commands within `lcs` that are not
of that type. This method returns a `Vector` of `MachOLoadCmdRef` objects,
containing only load commands that are of the requested types. For example, to
find all segments within a file:
find(MachOLoadCmds(oh), [MachOSegmentCmd])
findall(MachOLoadCmds(oh), [MachOSegmentCmd])
"""
function find(lcs::MachOLoadCmds, lc_types::Vector{T}) where {T <: Type}
function findall(lcs::MachOLoadCmds, lc_types::Vector{T}) where {T <: Type}
indices = Integer[]
for idx in 1:length(lcs.cmds)
if any(typeof(lcs.cmds[idx]) <: lct for lct in lc_types)
Expand All @@ -174,7 +174,7 @@ function find(lcs::MachOLoadCmds, lc_types::Vector{T}) where {T <: Type}
# Return a new MachOLoadCmds object, that has those headers defined within it
return [lcs[idx] for idx in indices]
end
find(lcs::MachOLoadCmds, lc_type::T) where {T <: Type} = find(lcs, [lc_type])
findall(lcs::MachOLoadCmds, lc_type::T) where {T <: Type} = findall(lcs, [lc_type])


function load_cmd_type(header::MachOLoadCmdHeader{H}) where {H <: MachOHandle}
Expand Down
2 changes: 1 addition & 1 deletion src/MachO/MachOSegment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct MachOSegments{H <: MachOHandle, S <: MachOLoadCmdRef} <: Segments{H}
end

function Segments(lcs::MachOLoadCmds)
return MachOSegments(handle(lcs), find(lcs, [MachOSegmentCmd]))
return MachOSegments(handle(lcs), findall(lcs, [MachOSegmentCmd]))
end
function Segments(oh::MachOHandle)
# Sub out to our MachOLoadCmds-based constructor
Expand Down
2 changes: 1 addition & 1 deletion src/MachO/MachOStrTab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function StrTab(cmd::MachOLoadCmdRef{H,MachOSymtabCmd{H}}) where {H <: MachOHand
return MachOStrTab(cmd)
end
function StrTab(oh::MachOHandle)
cmds = find(MachOLoadCmds(oh), [MachOSymtabCmd])
cmds = findall(MachOLoadCmds(oh), [MachOSymtabCmd])
if isempty(cmds)
error("Mach-O file does not contain Symtab load commands")
end
Expand Down
2 changes: 1 addition & 1 deletion src/MachO/MachOSymbol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct MachOSymbols{H <: MachOHandle} <: Symbols{H}
end

function MachOSymbols(oh::MachOHandle)
cmds = find(MachOLoadCmds(oh), [MachOSymtabCmd])
cmds = findall(MachOLoadCmds(oh), [MachOSymtabCmd])
if isempty(cmds)
error("Mach-O file does not contain Symtab load commands")
end
Expand Down

0 comments on commit 9f6944e

Please sign in to comment.