-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Add option to remove the SONAME #257
Comments
There is some mailing list discussion about this, for example starting at http://mail-index.netbsd.org/pkgsrc-users/2020/07/30/msg031864.html and a bunch of "Next by Thread" links. |
Also related NixOS/nixpkgs#45105 |
Have you tried to make soname an absolute path? I think this is what https://github.com/NixOS/nixpkgs/pull/45105/files tries on Linux. |
Ah interesting idea! So if I understand right, the idea is to set the SONAME of a library to an absolute path. Then when that library is referenced (by the compile time linker), the output file will have a DT_NEEDED with that absolute path in it. An interesting alternative approach to mine: a library with no SONAME will cause the referring file to get an absolute DT_NEEDED (but only if it is specified on the command line that way). So I tried this on NetBSD (which has at least its own runtime linker, but the compiler and compile time linker are gnu or llvm).
which had an interesting result:
where the last line is the result of attempting to run I'm not sure what that error entails exactly, but I noticed that there is some strange change caused by the
So it seems that ETA: I found out why The NetBSD
from |
Oh, and if I overwrite the patched library with the original,
All this on NetBSD/amd64 9.2. |
Maybe issue #244 is related? I see changes in the order of program headers and sections, but the main change seems to be with |
+1. Please add the option to remove SONAME. There are such use cases and I think it's quite common in production environment. For example, I have a bunch of different versions of third-party .so files with all the same SONAME and RPATH in them, and each of them are not compatible with each other, and then I want to link to a certain version of .so file. So I have to remove the SONAME and RPATH to get a full path linkage to the certain .so file. patchelf has --remove-rpath now, and just lacks an option like --remove-soname. .so filenames are subject to change. It's not a good idea to reset a bunch of SONAMEs to the full path each time when the filenames or directories change, because it's annoying, and another problem is that the .dynstr section may not have enough room to hold the change. My current workaround:
|
Hi! ❯ patchelf --print-soname libsimple.so
libsimple.so.1.1
❯ patchelf --set-soname "" libsimple.so
❯ patchelf --print-soname libsimple.so Another example:
|
Sounds good to me. |
@Mic92 It both does and doesn't, in a way :) It does, in the sense that with the linker I tried, it seemed to have the same effect as a missing SONAME. The argument I gave to the linker was recorded verbatim in the DT_NEEDED record. It doesn't, in the sense that this doesn't actually remove the record:
whereas I was expecting that |
Mhm but truncating a string seems to me like the less invasive option because we don't actually need to remove any entries from the dynamic section. Any downsides? |
Sometimes, search paths for libraries cause conflicts between incompatible libraries that have the same SONAME. I once ran into that when I installed multiple versions of g++ which used the same SONAME for the C++ library, but they were incompatible. For some programs, the wrong version was loaded, resulting in mysterious problems.
For cases like this, sometimes it isn't even enough to avoid system-global search paths, and even RPATH in an executable can still not solve this. In that case you want to record the absolute path to a library.
It turns out that current tooling already supports this. I looked in NetBSD's runtime linker and in the binutils compile time linker. You get a full path to a library recorded in the linker output, if the library has no SONAME.
So if you can remove a SONAME from a library, you can use this escape hatch.
I tried in the past to make shim libraries that have no SONAME of themselves, and link to only one other library, with only one directory in the RPATH. That works, but is more complicated.
The text was updated successfully, but these errors were encountered: