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

ld --no-add-needed and multi-arch libraries



I noticed that some time ago that a few packages that used to FTBFS with --no-add-needed now build successfully without any source changes.

Here's a minimal example:

| $ cat test.c
| #include <dlfcn.h>
| int main(int argc, char **argv) { return !!dlopen((const char*) 0, 0); }
|
| $ gcc -c test.c
|
| $ ldd /usr/lib/libssl.so | grep -F dl.so
|         libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf75aa000)
|
| $ ld --no-add-needed test.o -ldl ### all righty
| ld: warning: cannot find entry symbol _start; defaulting to 00000000080481b0
|
| $ ld --no-add-needed test.o -lssl ### WTH? it should fail, but it does not
| ld: warning: cannot find entry symbol _start; defaulting to 00000000080481c0

Interestingly enough, the problem disappears if I unmultiarchify libdl:

| # mv -v /lib/*-*-*/libdl* /lib/ && mv -v /usr/lib/*-*-*/libdl* /usr/lib/
| `/lib/i386-linux-gnu/libdl-2.13.so' -> `/lib/libdl-2.13.so'
| `/lib/i386-linux-gnu/libdl.so.2' -> `/lib/libdl.so.2'
| `/usr/lib/i386-linux-gnu/libdl.a' -> `/usr/lib/libdl.a'
| `/usr/lib/i386-linux-gnu/libdl.so' -> `/usr/lib/libdl.so'
|
| # ln -sf /lib/libdl.so.2 /usr/lib/libdl.so
|
| $ ldd /usr/lib/libssl.so | grep -F dl.so
|         libdl.so.2 => /lib/libdl.so.2 (0xf75a9000)
|
| $ ld --no-add-needed test.o -ldl ### all righty
| ld: warning: cannot find entry symbol _start; defaulting to 00000000080481b0
|
| $ ld --no-add-needed test.o -lssl ### fails as expected
| ld: test.o: undefined reference to symbol 'dlopen@@GLIBC_2.1'
| ld: note: 'dlopen@@GLIBC_2.1' is defined in DSO /lib/libdl.so.2 so try adding it to the linker command line
| /lib/libdl.so.2: could not read symbols: Invalid operation

It smells like a bug to me, but maybe I'm missing something. Could someone explain what happens here?

--
Jakub Wilk


Reply to: