[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: DB3 symbol collisions solved...



> $ gcc a.o -o a -ldb -lsasl
> $ ldd a 
> 	libdb-3.1.so => /usr/lib/libdb-3.1.so (0x40020000)
> 	libsasl.so.7 => /usr/lib/libsasl.so.7 (0x40099000)
> 	libc.so.6 => /lib/libc.so.6 (0x400a4000)
> 	libdb2.so.2 => /usr/lib/libdb2.so.2 (0x401af000)
> 	libdl.so.2 => /lib/libdl.so.2 (0x401f3000)
> 	libcrypt.so.1 => /lib/libcrypt.so.1 (0x401f6000)
> 	libpam.so.0 => /lib/libpam.so.0 (0x40223000)
> 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
> $ ./a
> Sleepycat Software: Berkeley DB 2.7.7: (08/20/99)
> $ gcc a.o -o a -ldb
> $ ldd a
> 	libdb-3.1.so => /usr/lib/libdb-3.1.so (0x40020000)
> 	libc.so.6 => /lib/libc.so.6 (0x40099000)
> 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
> $ ./a
> Sleepycat Software: Berkeley DB 3.1.17: (November 15, 2000)
> 
> Sure, if you're lucky it will work for a while.  But if you're like me
> you'd be pretty nervous if your mail server (or whatever) was compiled with
> libdb3-dev but is actually running with libdb2.

You are misunderstanding how this works. When the dynamic loader binds
these, it uses direct linkage. What you are assuming is that your case
above is linked to both libdb3 and libdb2, when in fact it isn't. Watch
this:

blimpo:~# ldd /usr/sbin/slapd | grep libdb
        libdb-3.1.so => /usr/lib/libdb-3.1.so (0x70084000)
        libdb2.so.2 => /usr/lib/libdb2.so.2 (0x70360000)

blimpo:~# objdump --all /usr/sbin/slapd | grep NEEDED | grep libdb
  NEEDED      libdb-3.1.so

blimpo:~# objdump --all /usr/lib/libsasl.so.7.1.8 | grep NEEDED | grep libdb
  NEEDED      libdb2.so.2

Notice the *actual* linkage for slapd, is to libdb3, and the *actual*
linkage for libsasl is to libdb2. The elf loader knows this, and handles
it, by binding to the right one for each case. What my fix does is make
sure that a call to libdb2, doesn't in turn make libdb2 use some function
in libdb3 (which is what happens in slapd's case, before hacking the
symbols).

I did try using -Bsymbolic on both libraries, but this causes a segfault
on slapd startup.

-- 
 -----------=======-=-======-=========-----------=====------------=-=------
/  Ben Collins  --  ...on that fantastic voyage...  --  Debian GNU/Linux   \
`  bcollins@debian.org  --  bcollins@openldap.org  --  bcollins@linux.com  '
 `---=========------=======-------------=-=-----=-===-======-------=--=---'



Reply to: