coreutils: Mitigate write() error on 32-bit archs

This commit is contained in:
Tee KOBAYASHI 2022-09-14 23:05:37 +09:00 committed by xtkoba
parent 4fa19969c3
commit 81e65a78d4
2 changed files with 38 additions and 0 deletions

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Basic file, shell and text manipulation utilities from t
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=9.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/coreutils/coreutils-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=61a1f410d78ba7e7f37a5a4f50e6d1320aca33375484a3255eddf17a38580423
TERMUX_PKG_DEPENDS="libandroid-support, libgmp, libiconv"

View File

@ -0,0 +1,37 @@
See https://github.com/termux/termux-packages/issues/11912.
--- a/lib/fflush.c
+++ b/lib/fflush.c
@@ -231,3 +231,32 @@
}
#endif
}
+
+#if defined __ANDROID__ && !defined __LP64__
+
+#include <dlfcn.h>
+
+typedef ssize_t (*write_impl_t)(int, const void *, size_t);
+
+ssize_t
+write(int __fd, const void *__buf, size_t __count)
+{
+ static int initialized = 0;
+ static write_impl_t libc_impl = NULL;
+
+ if (!initialized) {
+ libc_impl = dlsym(RTLD_NEXT, "write");
+ initialized = 1;
+ }
+
+ /* This should not normally happen. */
+ if ((uint64_t)__buf + (uint64_t)__count == (1ULL << 32))
+ return (ssize_t)__count;
+
+ if (libc_impl != NULL)
+ return libc_impl(__fd, __buf, __count);
+
+ __builtin_abort();
+}
+
+#endif