On 7/8/2020 2:32 PM, Frederick Gotham wrote:
> On Tuesday, July 7, 2020 at 6:57:16 PM UTC+1, Manfred wrote:
>
>> However you may want to check the referenced SONAME in the executable.
>> Usually the GNU linker puts the SONAME of the shared library in the
>> executable, and at runtime the dynamic linker loads the shared library
>> by SO_NAME rather than by filename (see ld -soname).
>
>
> I haven't investigated into this fully but I think you're right, Manfred. I used the program "patchelf" to change the "soname" inside my ".so" file, and now when I link with it, the resultant executable file is dependent upon the full filename.
If you are compiling and linking the .so yourself, then you'd probably
better use the "-soname" ld option rather than patching the binary
afterwards - if it is a 3rd party project, it is probably a good idea to
suggest this to the maintainer.
>
> Alternatively, and in similar fashion to "patchelf", I could have just altered a 5 - 10 bytes in the resultant binary to get it to look a file with a longer filename.
>
> By the way, does anyone know if these two lines do exactly the same thing on Linux?
>
> g++ -o prog main.cpp -L./ -l:libmonkey.so
>
> g++ -o prog main.cpp ./libmonkey.so
>
> From what I can see so far, these two commands are identical in effect.
>
I would guess so, anyway the documentation of both gcc and ld is usually
pretty accurate, so if you want to be sure better check "info gcc" and
"info ld" (or man gcc, man ld)
If you find some inconsistency, usually bug reports do get consideration
on these projects - note that ld is part of binutils.
(BTW I think there is one between the manpages of ld and ld.so on this
very topic)