ldso: "can't load library" due to not using (f)stat64 calls

Jody Bruchon jody at jodybruchon.com
Wed Feb 5 20:23:07 UTC 2014


On 1/22/2014 4:29 PM, Bernhard Reutner-Fischer wrote:
> On 22 January 2014 22:15, Jody Bruchon <jody at jodybruchon.com> wrote:
>> On 1/22/2014 4:09 PM, Bernhard Reutner-Fischer wrote:
>>>
>>> Well, did you build uClibc with LFS on or off?
>>> If you are using something like xfs you generally want largefile
>>> support and thus
>>> UCLIBC_HAS_LFS=y i suppose :)
>>>
>>> please double-check, rebuild if in doubt and let us know.
>>
>>
>> I have confirmed that uClibc is built with UCLIBC_HAS_LFS=y, recompiled and
>> replaced as a sanity check, and I also have reconfirmed that my uClibc i486
>> userspace works properly if I boot a 32-bit Linux kernel instead of 64-bit
>> (tested with linux-3.13). chroot under a 64-bit kernel with similar compile
>> options continues to not work.
>
> Works for me..
> maybe it's XFS? Can you try on an ext[234] instead, please?
>

I've confirmed that the problem is [f]stat() calls in ld-uClibc.so.0 and 
that the reason for the overflow is 64-bit inode numbers. I copied 
everything in my uClibc-i386 chroot environment to a new folder in /tmp 
and confirmed all /lib/* inode numbers dropped below the 32-bit boundary 
(4294967296) and was able to chroot into it normally.

This issue should affect any uClibc i386 32-bit userland where an 
executable file or library being linked has an inode number above the 
32-bit boundary. Here's the additional information I've gathered that 
confirms these 64-bit-unclean stat() family calls are causing the issue. 
Particularly note the inode numbers are all above 4294967296.

Irrelevant command output is omitted for clarity.

$ objdump -d ld-uClibc.so.0 | grep -B 1 'int.*0x80' | cut -d: -f2- | 
sort | uniq -c

       3         b8 6a 00 00 00          mov    $0x6a,%eax
       1         b8 6c 00 00 00          mov    $0x6c,%eax
      78         cd 80                   int    $0x80


$ grep 'stat' /usr/include/asm/unistd_32.h

#define __NR_stat 106
#define __NR_lstat 107
#define __NR_fstat 108
#define __NR_stat64 195
#define __NR_lstat64 196
#define __NR_fstat64 197


$ stat -c %n:%i lib/ lib/*

lib/:6982701085
lib/ld-uClibc-0.9.34.so:6982701120
lib/ld-uClibc.so.0:6982701110
lib/libc.so.0:6982701111
lib/libcrypt-0.9.34.so:6982701101
lib/libcrypt.so.0:6982701112
lib/libcurses.so:6982701099
lib/libdl-0.9.34.so:6982701102
lib/libdl.so.0:6982701113
lib/libm-0.9.34.so:6982701103
lib/libm.so.0:6982701114
lib/libncurses.so:6982701089
lib/libncurses.so.5:6982701090
lib/libncurses.so.5.9:6982701091
lib/libuClibc-0.9.34.so:6982701108


-Jody Bruchon


More information about the uClibc mailing list