[freetds] ct-lib unit tests link statically

James K. Lowden jklowden at freetds.org
Wed Jul 9 13:48:56 EDT 2008


Johnny C. Lam wrote:
> > When I configure, I set LDPATH:
                            ^^^^^^ I meant LDFLAGS
> > 
> > LD_search='-L/usr/local/lib -L/usr/pkg/lib'
> > LD_rpath='-Wl,--rpath -Wl,/usr/local/lib:/usr/pkg/lib'
> > export LDFLAGS="${LD_search} ${LD_rpath}"
> > 
> > And that rpath precedes the "local" one in the unit test binaries.
> > 
> > $ ldd datafmt
> > datafmt:
> >          -lpthread.0 => /usr/lib/libpthread.so.0
> >          -lct.4 => /usr/local/lib/libct.so.4
> >          -lc.12 => /usr/lib/libc.so.12
> > 
> > $ readelf -d datafmt | grep -i rpath
> >  0x0000000f (RPATH)                      Library rpath:
> > [/usr/local/lib:/usr/pkg/lib:/usr/users/home/jklowden/freetds/build/s
> > rc/c tlib/.libs]

> Setting LD_LIBRARY_PATH will override any embedded rpath 

Huh, so it does!  

OT: Now I *really* don't know why NetBSD doesn't ship by default with a
ld.so.conf that includes /usr/local/lib and /usr/pkg/lib.  I had been
given to understand that relying on RPATH was more secure than using
LD_LIBRARY_PATH but, because the environment variable overrides, any user
can cause any shared object to be used.  

I think maybe I should simplify my life by adding usr/local/lib and
/usr/pkg/lib to /etc/ld.so.conf.  

> How are you verifying that the wrong shared libraries are being used?

See above.  datafmt is a ct-lib unit test.  readelf(1) shows the embedded
RPATH.  The first part -- /usr/local/lib:/usr/pkg/lib -- comes directly
from LDFLAGS.  ldd(1) shows datafmt is dynmically linked to
/usr/local/lib/libct.so.4.  

--jkl



More information about the FreeTDS mailing list