diff --git a/src/extension_custom_scripts.c b/src/extension_custom_scripts.c index ef48bfc..fd1daef 100644 --- a/src/extension_custom_scripts.c +++ b/src/extension_custom_scripts.c @@ -3,6 +3,24 @@ #include #include +/* Link against __xstat so the module loads on glibc older than 2.33. */ +#if defined(__linux__) && defined(__GLIBC__) && \ + (defined(__x86_64__) || defined(__aarch64__)) +# if defined(__x86_64__) +# define SUPAUTILS_STAT_COMPAT_VER "GLIBC_2.2.5" +# define SUPAUTILS_STAT_VER 1 +# else +# define SUPAUTILS_STAT_COMPAT_VER "GLIBC_2.17" +# define SUPAUTILS_STAT_VER 0 +# endif +extern int __xstat(int ver, const char *path, struct stat *buf); +__asm__(".symver __xstat,__xstat@" SUPAUTILS_STAT_COMPAT_VER); +# undef stat +# define stat(path, buf) __xstat(SUPAUTILS_STAT_VER, path, buf) +# undef stat64 +# define stat64(path, buf) __xstat(SUPAUTILS_STAT_VER, path, buf) +#endif + /* * A list of extension names which are currently under creation. * Used to detect cyclic dependencies between extensions via