patchelf
patchelf copied to clipboard
Cleanup .gnu.version_r after removing symbol version
Continuation of https://github.com/NixOS/patchelf/pull/374 with some more safety checks.
Hello there! I have been trying out the verneed_fix
branch in my own build flow, but there seems to be a bug in that it does not check for the end of the list (where vna_next
is zero). Here is a patch that I used to fix that.
diff --git a/src/patchelf.cc b/src/patchelf.cc
index 5ea8259..c91a2f2 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -1755,8 +1755,13 @@ void ElfFile<ElfFileParamNames>::cleanDependencySymbolVersions()
auto next_off = (intptr_t)(vern_aux) + rdi(vern_aux->vna_next) - (intptr_t)(ver_r);
wri(ver_r->vn_aux, next_off);
} else {
- auto next_off = (intptr_t)(vern_aux) + rdi(vern_aux->vna_next) - (intptr_t)(prev);
- wri(prev->vna_next, next_off);
+ auto raw_next = rdi(vern_aux->vna_next);
+ if (raw_next == 0) {
+ wri(prev->vna_next, 0);
+ } else {
+ auto next_off = (intptr_t)(vern_aux) + raw_next - (intptr_t)(prev);
+ wri(prev->vna_next, next_off);
+ }
}
wri(ver_r->vn_cnt, rdi(ver_r->vn_cnt) - 1);
} else {
Hi, it seems this still not fully working.
I tried this branch just now and removed all version information from symbols which wanted the newer glibc (2.36 in my case) but I still get the error version GLIBC_2.36' not found when
ldd`'ing on Ubuntu 22 (glibc 2.35)