Skip to content

Commit 222f222

Browse files
committed
Add ELF vernaux struct and hash function
1 parent 427b624 commit 222f222

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/ELF/ELFVersion.jl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ end
2424
vn_next::UInt32
2525
end
2626

27+
@io struct ELFVernAux{H <: ELFHandle}
28+
vna_hash::UInt32
29+
vna_flags::UInt16
30+
vna_other::UInt16
31+
vna_name::UInt32
32+
vna_next::UInt32
33+
end
34+
2735
struct ELFVersionEntry{H <: ELFHandle}
2836
ver_def::ELFVerDef{H}
2937
names::Vector{String}
@@ -62,4 +70,20 @@ function ELFVersionData(oh::H) where {H <: ELFHandle}
6270
end
6371

6472
return version_defs
65-
end
73+
end
74+
75+
"""
76+
Hash function used to create vd_hash from vda_name, or vna_hash from vna_name
77+
"""
78+
function ELFHash(v::Vector{UInt8})
79+
h = UInt32(0)
80+
for b in v
81+
h = (h << 4) + b
82+
hi = h & 0xf0000000
83+
if (hi != 0)
84+
h ⊻= (hi >> 24)
85+
end
86+
h &= ~hi
87+
end
88+
return h
89+
end

0 commit comments

Comments
 (0)