"Dan Nicholson" <[EMAIL PROTECTED]> writes:

[...]

> And now I've come upon this old thread:
>
> http://rpm5.org/community/rpm-devel/1554.html
>
> This is definitely the problem. When --as-needed is used, libc is
> bound first to tmire, causing regcomp and friends to be resolved
> through libc rather than libpcreposix.

the symbol conflict is a mess. pcreposix better be fixed
(http://rpm5.org/community/rpm-devel/1562.html)

it's hard to beat libc... here is what happens:

% echo 'int f() { regcomp(); }' > liba.c
% gcc -shared -o liba.so liba.c -lpcreposix 
% ldd liba.so
        libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7f76000)
        libc.so.6 => /lib/i686/libc.so.6 (0xb7e28000)
        libpcre.so.0 => /lib/libpcre.so.0 (0xb7e00000)
% gcc -shared -o liba_.so liba.so
% LD_LIBRARY_PATH=`pwd` ldd liba_.so
        liba.so => /tmp/liba.so (0xb7f44000)
        libc.so.6 => /lib/i686/libc.so.6 (0xb7de2000)
        libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7de0000)
        libpcre.so.0 => /lib/libpcre.so.0 (0xb7db8000)

one can see -lc has been added. confirmed by:

% gcc -nostdlib -shared -o liba_.so liba.so
% LD_LIBRARY_PATH=`pwd` ldd liba_.so
        liba.so => /tmp/liba.so (0xb7f19000)
        libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7f03000)
        libc.so.6 => /lib/i686/libc.so.6 (0xb7db5000)
        libpcre.so.0 => /lib/libpcre.so.0 (0xb7d8d000)

but using -nostdlib is harder when building a binary... hence the need
to force -lpcreposix at each linking steps:

% gcc -shared -o liba_.so liba.so -lpcreposix
% LD_LIBRARY_PATH=`pwd` ldd liba_.so
        liba.so => /tmp/liba.so (0xb7f9f000)
        libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7f89000)
        libc.so.6 => /lib/i686/libc.so.6 (0xb7e3b000)
        libpcre.so.0 => /lib/libpcre.so.0 (0xb7e13000)


which defeats the idea of DSO which should handle their deps themselves.
and such hacks do not play well with --as-needed:

export LD_LIBRARY_PATH=/tmp
cd /tmp
echo 'int f() { printf("fa "); }' > liba.c
echo 'int f() { printf("fb "); }' > libb.c
echo 'int g() { }' >> libb.c
echo 'int h() { f(); g(); }' > libx.c
echo 'main()  { h(); g(); printf("\n"); }' > t.c
gcc -o liba.so -shared liba.c
gcc -o libb.so -shared libb.c
gcc -o libx.so -shared libx.c -L. -la -lb
gcc                 t.c -L. -lx    ; ./a.out # fb
gcc                 t.c -L. -lx -la; ./a.out # fa
gcc -Wl,--as-needed t.c -L. -lx -la; ./a.out # fb


i wonder if ld could have a warning to detect about multiple symbols
in DSO and so tell about possible issues with --as-needed.
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
Developer Communication List                        rpm-devel@rpm5.org

Reply via email to