Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ObjectFile"
uuid = "d8793406-e978-5875-9003-1fc021f44a92"
authors = ["Elliot Saba <staticfloat@gmail.com>"]
version = "0.5.0"
version = "0.5.1"

[deps]
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Expand Down
11 changes: 11 additions & 0 deletions src/ELF/ELFSymbol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ function lastindex(syms::ELFSymbols{H}) where {H <: ELFHandle}
return div(sect_size, sym_size)
end

function Base.getindex(syms::ELFSymbols{H}, idx) where {H <: ELFHandle}
return getindex_ref(
syms,
section_offset(Section(syms)),
sizeof(symtab_entry_type(syms)),
symtab_entry_type(syms),
SymbolRef,
idx,
)
end


# Add an StrTab() override to be able to load the symbol string table
"""
Expand Down
14 changes: 13 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ function test_libfoo_and_fooifier(fooifier_path, libfoo_path)
@test isglobal(syms_exe[main_idx_exe])
@test isglobal(syms_lib[foo_idx_lib])
end

if isa(oh_exe, ELFHandle)
sections = Sections(oh_exe)
dynsym = Symbols(only(findall(sections, ".dynsym")))
symtab = Symbols(only(findall(sections, ".symtab")))

@test section_name(Section(dynsym)) == ".dynsym"
@test section_number(Section(dynsym)) != section_number(Section(symtab))
@test section_number(Section(dynsym)) == section_number(Section(Symbols(dynsym[2])))
@test symbol_number(dynsym[2]) == 2
@test length(dynsym) <= length(symtab)
@test symbol_name(dynsym[2]) == "_ITM_deregisterTMCloneTable"
end
end

@testset "Printing" begin
Expand Down Expand Up @@ -324,4 +337,3 @@ using Mmap
find_dep_libs(joinpath("./libjulias", file))
end
end

Loading