Sample Header Ad - 728x90

ldconfig creating links with strange names after patching libraries with patchelf?

1 vote
1 answer
395 views
I am patching several libraries on my development server to remove unneeded dependencies using the patchelf tool. These get packaged into an RPM and installed on my runtime system. After the install, ldconfig gets called, and strange links are created. The locations of the patched libraries on the runtime system is something like /usr1/blah/lib and a few subfolders. This location and the location of the subfolders is specified in my /etc/ld.so.conf file. When I run ldconfig, a bunch of links with strange names are created, such as: ?N -> libFoo.so ??r? -> libBar.so as well as links whose names are partial function names of functions in the library, e.g. if I do objdump -x and look at the function names, the link will have part of that function as its name. My understanding was that ldconfig looks at the SONAME of the libraries and creates a link with that name. However when I do an objdump -x on all the affected libraries and grep for SONAME, nothing is out of the ordinary, they all end in .so and have none of the weird question marks. ldconfig -v provides no helpful information. Any ideas as to what could be going on? Maybe the SONAME is getting screwed up in some way that I'm missing? Thanks for any help. edit: if I merely remove dependencies as a part of my patching process (e.g. only call patchelf --remove-needed , then this issue doesn't happen. it's only when I use the --add-needed flag. edit 2: If I just add and remove a garbage dependency (e.g. patchelf --add-needed garbage libFoo.so followed immediately by patchelf --remove-needed garbage libFoo.so), that causes the weird link issue as well. The final dependency list in each library is the exact same, and it works when I just use the --remove-needed flag, which leads me to think that the issue is the --add-needed flag and whatever patchelf does to the header when it does that. edit 3: at this point I am going with the assumption that this is a bug with either patchelf or ldconfig. I'm guessing it's the latter since we're using glibc version 2.17 which is from ~2012, but the latest version of patchelf. perhaps the ELF standard has changed. tl;dr with patchelf version 0.10 and glibc version 2.17, the --add-needed option appears to mess with the ELF such that ldconfig is creating some wonky links.
Asked by swaggy p (111 rep)
Oct 28, 2019, 09:56 PM
Last activity: Mar 2, 2022, 12:59 AM