This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Please CC me, as I'm not subscribed to the list!
Hello List,
when ld was configured with a sysroot, it should always search
libraries first in this sysroot. This is especially important when
cross-compiling. The following test illustrates the problem (you need
a cross-compile toolchain and a target lib called "libfoo.so" in the
dir of the test script):
----
#!/bin/bash
echo "int main(void) { return 0; }" > test.c
echo "Testing without lib..."
armv4tl-softfloat-linux-gnueabi-gcc test.c -o test
echo "Testing with relative lib..."
armv4tl-softfloat-linux-gnueabi-gcc test.c -o test ./libfoo.so
echo "Testing with relative linker script..."
echo "GROUP ( ./libfoo.so )" > "${PWD}/libfoo-script.so"
armv4tl-softfloat-linux-gnueabi-gcc test.c -o test libfoo-script.so
echo "Testing with absolute linker script (local libfoo)..."
echo "GROUP ( ${PWD}/libfoo.so )" > "${PWD}/libfoo-script.so"
armv4tl-softfloat-linux-gnueabi-gcc test.c -o test libfoo-script.so
echo "Testing with absolute linker script (systems libz)..."
echo "GROUP ( /lib/libz.so )" > "${PWD}/libfoo-script.so"
armv4tl-softfloat-linux-gnueabi-gcc test.c -o test libfoo-script.so
----
The output of this script for the stock ld-2.19.1 is:
----
Testing without lib...
Testing with relative lib...
Testing with relative linker script...
Testing with absolute linker script (local libfoo)...
Testing with absolute linker script (systems libz)...
/lib/libz.so: file not recognized: File format not recognized
collect2: ld returned 1 exit status
----
as the "/lib/libz.so" in the linker script is not prepended with the
sysroot prefix. By applying the attached patch, the test runs
successfully also for this case. The patch was tested agains a native
compilation (no sysroot prefix) amd64 Gentoo system and a
cross-compiled armv4tl-softfloat-linux-gnueabi Gentoo system. Both
systems work.
Best regards,
Sven
Attachment:
binutils-2.19.1-ld-sysroot.patch
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |