@@ -137,6 +137,39 @@ int __android_log_write(int prio, const char* tag, const char* text) { return 0;
137137STUB
138138 fi
139139
140+ # K2GO-411: translate aarch32 futex_time64 (#422) -> classic futex so 32-bit Go
141+ # binaries run on pre-5.1 kernels (e.g. Android 4.14, where futex_time64 is
142+ # ENOSYS). PRoot ships utimensat_time64 (v5.3.0); this follows the same path.
143+ # Safe: PRoot has no futex arg handling and FUTEX_WAKE carries no timespec;
144+ # on a 64-bit host PR_futex resolves to the native 64-bit-timespec futex.
145+ SYSD="$TERMUX_PKG_SRCDIR/src/syscall"
146+ # 1) abstract sysnum
147+ grep -q 'SYSNUM(futex_time64)' "$SYSD/sysnums.list" \
148+ || sed -i '/^SYSNUM(futex)$/a SYSNUM(futex_time64)' "$SYSD/sysnums.list"
149+ # 2) enter.c: rewrite PR_futex_time64 -> PR_futex at sysenter
150+ grep -q 'PR_futex_time64' "$SYSD/enter.c" \
151+ || { awk '/^\tcase PR_getcwd:/ && !p { print "\tcase PR_futex_time64:"; print "\t\tset_sysnum(tracee, PR_futex);"; print "\t\tstatus = 0;"; print "\t\tbreak;"; print ""; p=1 } { print }' "$SYSD/enter.c" > "$SYSD/enter.c.tmp" && mv "$SYSD/enter.c.tmp" "$SYSD/enter.c"; }
152+ # 3) ABI table: map the raw aarch32 number 422 -> PR_futex_time64 (i386 uses 422
153+ # too). WITHOUT THIS the sysnum never resolves to PR_futex_time64 and the enter.c
154+ # case never fires (verified on device: patch present but still ENOSYS). Anchor on
155+ # the classic futex(240) entry, which only 32-bit tables have -> arm64/x86_64 skip.
156+ # Mirrors the fchmodat2 [452] mapping below.
157+ for h in "$SYSD"/sysnums-*.h; do
158+ grep -q 'PR_futex_time64' "$h" && continue
159+ grep -q '\[ 240 \] = PR_futex,' "$h" \
160+ && sed -i 's/^\([[:space:]]*\)\[ 240 \] = PR_futex,/&\n\1[ 422 ] = PR_futex_time64,/' "$h"
161+ done
162+ # 4) seccomp: trap futex_time64 at sysenter so the rewrite runs in the DEFAULT
163+ # seccomp-accelerated mode (proot only TRACEs a curated list; futex is not in it,
164+ # so without this futex_time64 passes through untranslated unless PROOT_NO_SECCOMP).
165+ grep -q '{ PR_futex_time64,' "$SYSD/seccomp.c" \
166+ || sed -i 's/^\([[:space:]]*\){ PR_fchmodat,[[:space:]]*0 },$/&\n\1{ PR_futex_time64, 0 },/' "$SYSD/seccomp.c"
167+ # guards
168+ grep -q 'SYSNUM(futex_time64)' "$SYSD/sysnums.list" || { echo "!! [IIAB] sysnums.list anchor 'SYSNUM(futex)' not found"; exit 1; }
169+ grep -q 'case PR_futex_time64:' "$SYSD/enter.c" || { echo "!! [IIAB] enter.c anchor 'case PR_getcwd:' not found"; exit 1; }
170+ grep -q '\[ 422 \] = PR_futex_time64,' "$SYSD/sysnums-arm.h" || { echo "!! [IIAB] sysnums-arm.h anchor '[ 240 ] = PR_futex,' not found"; exit 1; }
171+ grep -q '{ PR_futex_time64,' "$SYSD/seccomp.c" || { echo "!! [IIAB] seccomp.c anchor '{ PR_fchmodat, 0 }' not found"; exit 1; }
172+
140173 # --- ADFA-5334 (ADR-5334): translate fchmodat2 (452) like fchmodat, mirroring faccessat2. ---
141174 # glibc>=2.39 restores directory modes via fchmodat2; proot passes it through untranslated, so
142175 # recursive perms-preserving copies (tar -x / cp -a) fail under proot on kernel>=6.6 build hosts.
0 commit comments