Skip to content

Commit

Permalink
elf/so: if sym is undef, set version to VER_NDX_GLOBAL
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Oct 13, 2024
1 parent cede569 commit 4ec0f64
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Elf/SharedObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,8 @@ fn parseVersions(self: *SharedObject, elf_file: *Elf, file: std.fs.File, opts: s
defer gpa.free(versyms_raw);
const nversyms = @divExact(versyms_raw.len, @sizeOf(elf.Elf64_Versym));
const versyms = @as([*]align(1) const elf.Elf64_Versym, @ptrCast(versyms_raw.ptr))[0..nversyms];
for (versyms) |ver| {
const normalized_ver = if (ver & elf.VERSYM_VERSION >= self.verstrings.items.len - 1)
elf.VER_NDX_GLOBAL
else
ver;
self.versyms.appendAssumeCapacity(normalized_ver);
for (versyms, opts.symtab) |ver, esym| {
self.versyms.appendAssumeCapacity(if (esym.st_shndx == elf.SHN_UNDEF) elf.VER_NDX_GLOBAL else ver);
}
} else for (0..opts.symtab.len) |_| {
self.versyms.appendAssumeCapacity(elf.VER_NDX_GLOBAL);
Expand Down

0 comments on commit 4ec0f64

Please sign in to comment.