mitzen / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Fix soname in shared library #127

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As a rule “soname” should be the name of the library, not the full path.

Before patch (Linux x86_64):
readelf -d libleveldb.so | grep SONAME
 0x000000000000000e (SONAME)             Library soname: [/home/.../leveldb/leveldblibleveldb.so.1]

After patch:
readelf -d libleveldb.so | grep SONAME
 0x000000000000000e (SONAME)             Library soname: [libleveldb.so.1]

Original issue reported on code.google.com by Alexande...@gmail.com on 15 Oct 2012 at 11:31

Attachments:

GoogleCodeExporter commented 9 years ago
What about issue 111 which is arguing for the opposite
Should I drop INSTALL_PATH completely?
Is this a difference between OSX and Linux?

PS. the current code is broken even w.r.t issue 111 since it
is missing a '/' between INSTALL_PATH and SHARED2, but I was
planning on fixing that soon.

Original comment by san...@google.com on 15 Oct 2012 at 8:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
According to man pages, this is a difference between OSX and other Unixes.
---------------------------------------------
OSX
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages
/man1/ld.1.html
-install_name name: Sets an internal "install path" (LC_ID_DYLIB) in a dynamic 
library.

---------------------------------------------
Linux
man ld
-soname=name: ... set the internal DT_SONAME field to the specified name
-rpath dir: ... Add a directory to the runtime library search path

All libraries on linux have no path in SONAME:
#readelf -d /usr/lib64/libc*.so | grep SONAME
0x000000000000000e (SONAME)             Library soname: [libcairo.so.2]
0x000000000000000e (SONAME)             Library soname: [libcdda_interface.so.0]
0x000000000000000e (SONAME)             Library soname: [libcdda_paranoia.so.0]
0x000000000000000e (SONAME)             Library soname: [libcidn.so.1]
0x000000000000000e (SONAME)             Library soname: [libcom_err.so.2]
0x000000000000000e (SONAME)             Library soname: [libcrack.so.2]
0x000000000000000e (SONAME)             Library soname: [libcrypt.so.1]
0x000000000000000e (SONAME)             Library soname: [libcrypto.so.6]
0x000000000000000e (SONAME)             Library soname: [libcurl.so.3]
0x000000000000000e (SONAME)             Library soname: [libncurses.so.5]
0x000000000000000e (SONAME)             Library soname: [libncursesw.so.5]
---------------------------------------------

Solaris
man ld
-h name: ... records  name  in  the object's dynamic section
-R path: ... to  specify  library  search  directories  to  the runtime linker

elfdump -d /usr/lib/sparcv9/libc*.so | grep SONAME
       [5]  SONAME            0x5578              libc.so.1
       [3]  SONAME            0x51c               libc_db.so.1
       [4]  SONAME            0x2fa               libcfgadm.so.1
       [3]  SONAME            0x1ef               libcmd.so.1
       [3]  SONAME            0x258               libcommputil.so.1
       [4]  SONAME            0x61e               libcontract.so.1
       [6]  SONAME            0x5f9               libcpc.so.1
       [5]  SONAME            0x1ff               libcrypt_d.so.1
       [5]  SONAME            0x1ff               libcrypt_d.so.1
       [5]  SONAME            0x186               libcrypt_i.so.1
       [3]  SONAME            0x23a               libcryptoutil.so.1
       [3]  SONAME            0x4c4               libctf.so.1
       [3]  SONAME            0x1205              libcurses.so.1

So, in Linux, Solaris, ... library name defined in SONAME, and path to library 
is defined in –rpath, or in LD_LIBRARY_PATH env variable, or in the other 
“ld” options.

---------------------------------------------
I think INSTALL_PATH should not be used in "soname" for Linux/Solaris/HP...
For OSX pwd or INSTALL_PATH can be used.
Another patch attached.

Original comment by Alexande...@gmail.com on 16 Oct 2012 at 6:42

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in 1.7.0.

Original comment by san...@google.com on 16 Oct 2012 at 11:29