[PATCH] ldso: 64-bit clean stat (was "ldso: "can't load library" due to not using (f)stat64 calls")

Jody Bruchon jody at jodybruchon.com
Wed Feb 5 22:53:34 UTC 2014


This quick-and-dirty patch fixes the problem detailed in my previous bug 
reports relating to not using stat64 family calls in the uClibc dynamic 
loader.

I have confirmed that this patch enables a uClibc/i386 system to 
properly load libraries and dynamic executables that are referenced by 
64-bit inode numbers, avoiding the -EOVERFLOW failure I originally reported.

I have not tested this on any platforms other than i386. I hope this 
will assist someone with more uClibc expertise to craft a proper patch.

-Jody Bruchon


--- a/ldso/include/dl-syscall.h 2013-10-07 10:46:11.000000000 -0400
+++ b/ldso/include/dl-syscall.h 2014-02-05 17:31:46.014902106 -0500
@@ -28,7 +28,8 @@
  #if defined(__sparc_v9__) && (__WORDSIZE == 64)
  #define kernel_stat64 stat
  #else
-#define kernel_stat stat
+/* #define kernel_stat stat */
+#define kernel_stat64 stat
  #endif
  #include <bits/kernel_stat.h>
  #include <bits/kernel_types.h>
@@ -82,7 +83,7 @@
  static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
                          unsigned long, len, int, prot)

-#if defined __NR_fstatat64 && !defined __NR_stat
+#if defined __NR_fstatat64
  # define __NR__dl_fstatat64 __NR_fstatat64
  static __always_inline _syscall4(int, _dl_fstatat64, int, fd, const 
char *,
                                  fn, struct stat *, stat, int, flags)
@@ -98,7 +99,7 @@
                          struct stat *, buf)
  #endif

-#if defined __NR_fstat64 && !defined __NR_fstat
+#if defined __NR_fstat64
  # define __NR__dl_fstat __NR_fstat64
  #elif defined __NR_fstat
  # define __NR__dl_fstat __NR_fstat


More information about the uClibc mailing list