[RFC] ld sysroot prefix handling

Sven Rebhan odinshorse@googlemail.com
Wed May 27 06:46:00 GMT 2009


Please CC me as I'm not subscribed to the list!

Hello List,

while cross-compiling a Gentoo Linux system for an arm architecture I noticed
that in some cases the sysroot prefix is not prepended to absolute library path.
This especially can be seen after adding some debugging to  ldfile.c line 311.
For linking a simple C program "int main(void) { return 0; }" you see that the
entry->sysrooted flag is set to TRUE while the filename to link is
"/lib/libc.so.6".
The toolchain sysroot is /usr/armv4tl-softfloat-linux-gnueabi. In the
following the
sysroot prefix gets prepended. However, in my interpretation the sysroot prefix
should have been prepended before if  entry->sysrooted == TRUE!?

When linking against the following linker script

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

you get a entry->sysrooted == FALSE and filename == "/lib/libusb.so" in the
following the prefix gets not prepended as  entry->sysrooted == FALSE which
leads to sever problems during cross-compilation.

The questions are now:
- Should the sysroot prefix have been prepended when entry->sysrooted == TRUE?
- If so, why is the  filename then "/lib/libc.so.6" in the first case?
- If not, why isn't the sysroot prepended to the file specified in the
linker file?

I attached a RFC patch that solves both issues for me by testing if
the sysroot was
already prepended right before ld tries to prepend the prefix and
change the condition
to if ! entry->sysrooted.

Best regards,

   Sven 'sleipnir' Rebhan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-2.19.1-ld-sysroot.patch
Type: application/octet-stream
Size: 490 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20090527/0aa9c9bf/attachment.obj>


More information about the Binutils mailing list