-
-
Notifications
You must be signed in to change notification settings - Fork 486
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
patchelf breaks dylibs from recent Firefox Nightly builds #520
Comments
The problem is that the source code uses the _DYNAMIC symbol, which translates to the binary code accessing the .dynamic section at a fixed address. But patchelf moves it, and puts something else where it used to be, so the code reads garbage. |
Well this is fun. So I guess we need a custom fixup for this... |
Smaller (independent) reproducer:
|
Yeah sounds like we just have to special case that symbol. Not that it's not already special cased by the linker... |
The symbol is not used in Firefox's case. It uses the address directly. |
Actually, even in the small reproducer, the symbol is not used at runtime. |
So I guess we have two issues here - we still need to handle _DYNAMIC correctly AND we need to figure out what to do about Firefox... |
Actually, removing https://github.com/NixOS/patchelf/blob/master/src/patchelf.cc#L674 makes it work, because patchelf doesn't actually put another section where .dynamic used to be. It only overwrites its content with garbage. |
Oh, I actually thought we moved the sections properly and was going to try this as a workaround tomorrow. |
Works around NixOS#520, may be useful for other cursed self-modifying things.
Works around NixOS#520, may be useful for other cursed self-modifying things.
What is the original reasoning behind overwriting the old sections with |
Works around NixOS#520, may be useful for other cursed self-modifying things.
Works around NixOS#520, may be useful for other cursed self-modifying things.
Works around NixOS#520, may be useful for other cursed self-modifying things.
Works around #520, may be useful for other cursed self-modifying things.
The no-clobber workaround seems less than ideal, since it means that code referencing The relrhack is in https://github.com/mozilla/gecko-dev/blob/58c532751054863dbb9d277051d63e1e7e77929e/build/unix/elfhack/inject.c#L184. This could be changed to use |
Describe the bug
After using
patchelf --set-rpath
on a library from a recent Firefox Nightly build, the library can no longer be loaded because it segfaults the linker.Steps To Reproduce
libmozsqlite3.so
was my test target), e.g. withpython -c 'import ctypes; ctypes.cdll.LoadLibrary("./libmozsqlite3.so")'
patchelf --set-rpath "test" ./libmozsqlite3.so
dlopen
againExpected behavior
No segfault.
patchelf --version
outputAttempted both default nixpkgs 0.15.0 and current nixpkgs
patchelfUnstable
(c401289).Additional context
This seems to have been caused by upstream enabling some kind of advanced linker wizardry called "relrhack": https://hg.mozilla.org/mozilla-central/rev/032b87ff55061bcbdc7a85d9e18fde814797073a
The last build before that commit works fine.
The text was updated successfully, but these errors were encountered: