When cross-compiling and linking against a #4411 linker script, ld will search the library on the host first. For an amd64 host the following test script echo "Testing with absolute linker script (systems libz)..." echo "int main(void) { return 0; }" > test.c echo "GROUP ( /lib/libz.so )" > "${PWD}/libfoo-script.so" armv4tl-softfloat-linux-gnueabi-gcc test.c -o test libfoo-script.so will fail with Testing with absolute linker script (systems libz)... /lib/libz.so: file not recognized: File format not recognized collect2: ld returned 1 exit status because the lib (/lib/libz.so) specified in the linker script is searched on host first. The following patch solves this problem (upstream bug http://sourceware.org/bugzilla/show_bug.cgi?id=10340). Reproducible: Always
Created attachment 195936 [details, diff] ld should search libs in sysroot first When ld was configured with a sysroot, it should always search for libraries with absolute filename in this sysroot first. This patch was tested on x86_64-pc-linux-gnu without sysroot and armv4tl-softfloat-linux-gnueabi cross-compilation with sysroot and works fine on both.
*** Bug 266319 has been marked as a duplicate of this bug. ***
patch has been added to binutils-2.19.51.0.12. if things work out, we can also put it into binutils-2.19.1.