-
-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To patch a binary with patchelf lead to inconsistency. #250
Comments
I would say the GNU_HASH section or offset is incorrect now. Do you have a simpler binary to reproduce this? |
This is the assertion that broke. https://github.com/bminor/glibc/blob/1d7b32ee6145c46c4f4f8a208a6b72e0668d7cf3/elf/dl-lookup.c#L966 |
Unfortunately I am seeing this as well. Note that this is a different issue from #365. patchelf --set-rpath causes corruption, but patchelf --set-interpreter works correctly. To reproduce, clone this branch, edit
and then on a mips64el host,
which leads to:
If you leave |
Is this also reproducible with binfmt/qemu-user? That would greatly help with reproducing the issue. |
Hang on. |
I found the culprit. patchelf isn't corrupting the executable binaries. It's corrupting librt-2.33.so, which is then loaded by (all of) the binaries, causing a crash in the dynamic loader. Curiously, librt-2.33.so has no rpath at all, so there really is no need to --set-rpath it. I wonder if this is the source of the bug: that "patchelf --force-rpath --set-rpath" does not cope well with being invoked on a library that has no rpath to begin with? In any event, the fix for nixpkgs is now easy: simply don't patchelf librt-2.33.so. This fixes it: https://github.com/a-m-joseph/nixpkgs/tree/bootstrap-tools-dont-patchelf-librt I'm not sure if I should submit this PR to nixpkgs, however... I can imagine that they might say "noticing empty RPATHs is patchelf's job". What do people think? The branch below (which builds on the patch above) is now well on its way with the bootstrap on mips64el. Notably, this is the first time I've been able to get that to happen without inserting https://github.com/a-m-joseph/nixpkgs/tree/mips64-bootstrap |
Either case (change unpack-bootstrap-tools.sh vs change patchelf) will force a global rebuild of nixpkgs, so I proposed the PR to nixpkgs: NixOS/nixpkgs#161925 |
I'm no longer sure that the issue I'm experiencing is the same one as the person who opened this bug, so I have created a separate bug #368 with reproducible steps to trigger the bug. |
Describe the bug
Hello. I patched a binary with:
./patchelf --set-interpreter /media/34GB/Arquivos-de-Programas-Linux/Glibc-2.17-32bit/lib/ld-linux.so.2 --set-rpath /media/34GB/Arquivos-de-Programas-Linux/Glibc-2.17-32bit/ /media/34GB/Arquivos-de-Programas-Linux/palemoon/palemoon
then tried to run it with: "./palemoon", which returned:
"Inconsistency detected by ld.so: dl-lookup.c: 877: _dl_setup_hash: Assertion `(bitmask_nwords & (bitmask_nwords - 1)) == 0' failed!"
So, what is happening?
The text was updated successfully, but these errors were encountered: