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]

Re: [RFC] ld sysroot prefix handling


As I was obviously unclear I put facts in here we can discuss. We are
only talking about the ld/ldfile.c file, function
ldfile_open_file_search in the if (! entry->is_archive) { ... } block
(line 309). First my test program:

Fafnir binutils-test # cat test.c
int main(void) { return 0; }

I used the attached patch to get the following debug messages:

Fafnir binutils-test # armv4tl-softfloat-linux-gnueabi-gcc -o test test.c
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 1
    entry->filename   == /lib/libc.so.6
    is sysrooted func == 0
    Result: Opened file sysrooted!
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 1
    entry->filename   == /usr/lib/libc_nonshared.a
    is sysrooted func == 0
    Result: Opened file sysrooted!
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 1
    entry->filename   == /lib/ld-linux.so.3
    is sysrooted func == 0
    Result: Opened file sysrooted!

You see that entry-> sysrooted is set, but the filename is not
prefixed! In the original setting the sysroot prefix is prepended
then. For

Fafnir binutils-test # armv4tl-softfloat-linux-gnueabi-gcc -o test
test.c /usr/armv4tl-softfloat-linux-gnueabi/usr/lib/libusb.so
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 0
    entry->filename   == /lib/libusb-0.1.so.4
    is sysrooted func == 0
    Result: Couldn't open file.
/usr/libexec/gcc/armv4tl-softfloat-linux-gnueabi/ld: cannot find
/lib/libusb-0.1.so.4
collect2: ld returned 1 exit status

where the file /usr/armv4tl-softfloat-linux-gnueabi/usr/lib/libusb.so
is a ld-script containing

OUTPUT_FORMAT ( elf32-littlearm )
GROUP ( /lib/libusb-0.1.so.4 )

For Mike's libfoo script example, I get with the original stuff:

Fafnir binutils-test # armv4tl-softfloat-linux-gnueabi-gcc -o test
test.c lib/scripts/libfoo.so
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 0
    entry->filename   == /root/binutils-test/lib/libfoo.so
    is sysrooted func == 0
    Result: Opened file in / (entry->sysrooted == 0)!
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 1
    entry->filename   == /lib/libc.so.6
    is sysrooted func == 0
    Result: Opened file sysrooted!
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 1
    entry->filename   == /usr/lib/libc_nonshared.a
    is sysrooted func == 0
    Result: Opened file sysrooted!
/var/tmp/cross/armv4tl-softfloat-linux-gnueabi/portage/cross-armv4tl-softfloat-linux-gnueabi/binutils-2.19.1-r1/work/binutils-2.19.1/ld/ldfile.c
line 311: before sysroot handling...
    is absolute path  == 1
    entry->sysrooted  == 1
    entry->filename   == /lib/ld-linux.so.3
    is sysrooted func == 0
    Result: Opened file sysrooted!

So what you can see is that most cases are handled correct right now,
the only thing that fails badly is when you have an ld-script that
contains an absolute path. Here the sysroot prefix is _NOT_ prepended
and thus linking against such a script breaks most packages during
cross-compilation as the linker tries to link against a host library.

Hope this clarifies a bit what I want!? :-)

Sven

Attachment: binutils-2.19.1-debug.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]