I have a shared object where file indicates it is a shared object, and it is used and behaves as a shared object.
% file libirc.so
libirc.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=9d54bda46b31ae048aae323dfd809f9ae6c8c55c, not stripped
%
But the ldd command indicates it is statically linked.
% ldd libirc.so
statically linked
%
When I run an executable, ./Solver, that uses this libirc.so it runs as expected. But when I run the same with LD_PRELOAD="io_functions.so" the run time linker, /lib64/ld-linux-x86-64.so.2, segfaults just after issuing the error message:
./Solver: Relink `./lib/libirc.so' with `/lib64/libc.so.6' for IFUNC symbol `memmove'
I can make the run using LD_PRELOAD work by also including libirc.so on the LD_PRELOAD. I don't have source for libirc.so so I can't figure out much on that end. I suspect that the troubles are centered on libirc.so being statically linked. It should not matter what code is in io_functions.so because ld.so doesn't even get to the point of calling the init functions as ld.so is segfaulting while binding symbols.
I have done a bit of investigating using LD_DEBUG. When I run with LD_PRELOAD=irc/libirc.so ld.so needs to find memmove for libstdc++ , and uses memmove [GLIBC_2.2.5] from /lib64/libc.so.6. Later ld.so needs to find memmove for libirc.so and also uses memmove from libc.so.6.
LD_DEBUG output from successfull run with LD_PRELOAD=irc/libirc.so
3677171: binding file /lib64/libstdc++.so.6 [0] to /lib64/libc.so.6 [0]: normal symbol `memmove' [GLIBC_2.2.5]
.
.
.
3677171: binding file irc/libirc.so [0] to /lib64/libc.so.6 [0]: normal symbol 'memmove'
When I run the failing job (without LD_PRELOAD=irc/libirc.so), ld.so first needs to find memmove for libirc.so and finds it in libc.so.6. ld.so then prints out the Relink message, followed by a segfault. Why does running this way cause the Relink message and segfault, even though its finding memmove for libirc.so in the same place ( libc.so.6 ) as the above successful run?
The last LD_DEBUG line for this process, followed by the print
3676728: binding file irc/libirc.so [0] to /lib64/libc.so.6 [0]: normal symbol `memmove'
./bin/SMAEqsDirSolverSymmetric: Relink `irc/libirc.so' with `/lib64/libc.so.6' for IFUNC symbol `memmove'
There is nothing inherently crooked about a DSO that
lddreports as statically linked. In that caselddis just telling you that the DSO has no dynamic dependencies itself.Here comes one such:
This compiler emits
PICcode by default.The stock muscl static
libcbuilt for and by my compiler containsPICobject files, so it harbours no relocation errors.and:
even though I did not attempt to link
-shared -static(which would fail).lddsays that because there is no dynamic section in the shared library:Because it doesn't need one. Whereas:
libhello-musl.sois fit for purpose.In this light:
seems to be a misplaced suspicion.
The internet throws up other examples of the same class of
error, in which the observation that
libsome.sois statically linked does not appear.These include:
in which as it happens the
libsome.so=/usr/lib/libgcc_s.so.1transpires to have been linked againstlibc.musl-x86_64.so.1.and:
which is identical to your error modulo paths.
and:
which implicates glibc patch:
committed Oct. 21st 2021.
In this light, like @n. m. could be an AI, I suggest that the version of
[g]libcthat yourlibirc.sohas been statically linked with is unaligned with the one that your./Solveris linked with. The likeliest remedy - as usual? - is to obey the diagnostic: get a newlibirc.sothat you know has been linked withlibc.so.6(or a static PIC version of same). If that's difficult just getting the latest version oflibirc.sofrom wherever you got it may be a fix.