Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 275666

Summary: sys-devel/binutils: ld should search libraries in its sysroot first
Product: Gentoo Linux Reporter: Sven 'sleipnir' Rebhan <OdinsHorse>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: major CC: maxposedon
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://sourceware.org/bugzilla/show_bug.cgi?id=10340
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: ld should search libs in sysroot first

Description Sven 'sleipnir' Rebhan 2009-06-28 07:08:51 UTC
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
Comment 1 Sven 'sleipnir' Rebhan 2009-06-28 07:10:53 UTC
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.
Comment 2 SpanKY gentoo-dev 2009-07-05 19:57:51 UTC
*** Bug 266319 has been marked as a duplicate of this bug. ***
Comment 3 SpanKY gentoo-dev 2009-07-20 09:11:49 UTC
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.