# Compiles, but unused (proot will perhaps use it)
TERMUX_PKG_HOMEPAGE=https://talloc.samba.org/talloc/doc/html/index.html
TERMUX_PKG_DESCRIPTION="Hierarchical, reference counted memory pool system with destructors"
-TERMUX_PKG_VERSION=2.1.3
+TERMUX_PKG_VERSION=2.1.5
TERMUX_PKG_SRCURL=https://www.samba.org/ftp/talloc/talloc-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_BUILD_IN_SRC="yes"
--- /dev/null
+diff -u -r ../talloc-2.1.5/wscript ./wscript
+--- ../talloc-2.1.5/wscript 2015-11-06 08:28:25.000000000 -0500
++++ ./wscript 2016-01-08 19:19:24.233750343 -0500
+@@ -95,15 +95,6 @@
+ if bld.CONFIG_SET('HAVE_PTHREAD'):
+ testsuite_deps += ' pthread'
+
+- bld.SAMBA_BINARY('talloc_testsuite',
+- 'testsuite_main.c testsuite.c',
+- testsuite_deps,
+- install=False)
+-
+- bld.SAMBA_BINARY('talloc_test_magic_differs_helper',
+- 'test_magic_differs_helper.c',
+- 'talloc', install=False)
+-
+ else:
+ private_library = True
+
-# Fails to build with __ptrace_request being undefined
TERMUX_PKG_HOMEPAGE=http://proot.me/
TERMUX_PKG_DESCRIPTION="Emulate chroot, bind mount and binfmt_misc for non-root users"
TERMUX_PKG_VERSION=5.1.0
TERMUX_PKG_SRCURL=https://github.com/proot-me/PRoot/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_FOLDERNAME=PRoot-${TERMUX_PKG_VERSION}
+TERMUX_PKG_DEPENDS="libtalloc"
+
+export LD=$CC
termux_step_make_install () {
+ export CROSS_COMPILE=${TERMUX_HOST_PLATFORM}-
+
cd $TERMUX_PKG_SRCDIR/src
- make
+ make V=1
make install
+
+ mkdir -p $TERMUX_PREFIX/share/man/man1
+ cp $TERMUX_PKG_SRCDIR/doc/proot/man.1 $TERMUX_PREFIX/share/man/man1/proot.1
}
--- /dev/null
+From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788113
+
+diff -u -r ../PRoot-5.1.0/src/arch.h ./src/arch.h
+--- ../PRoot-5.1.0/src/arch.h 2014-12-15 09:18:11.000000000 -0500
++++ ./src/arch.h 2016-01-08 19:53:23.789378336 -0500
+@@ -125,6 +125,9 @@
+ #define OFFSETOF_STAT_UID_32 0
+ #define OFFSETOF_STAT_GID_32 0
+
++ #define EXEC_PIC_ADDRESS 0x500000000000
++ #define INTERP_PIC_ADDRESS 0x6f0000000000
++
+ #elif defined(ARCH_X86)
+
+ #define SYSNUMS_HEADER1 "syscall/sysnums-i386.h"
--- /dev/null
+diff -u -r ../PRoot-5.1.0/src/cli/cli.c ./src/cli/cli.c
+--- ../PRoot-5.1.0/src/cli/cli.c 2014-12-15 09:18:11.000000000 -0500
++++ ./src/cli/cli.c 2016-01-08 15:16:33.393030857 -0500
+@@ -30,7 +30,9 @@
+ #include <sys/types.h> /* getpid(2), */
+ #include <unistd.h> /* getpid(2), */
+ #include <errno.h> /* errno(3), */
++#ifndef __ANDROID__
+ #include <execinfo.h> /* backtrace_symbols(3), */
++#endif
+ #include <limits.h> /* INT_MAX, */
+
+ #include "cli/cli.h"
+@@ -558,7 +560,12 @@
+ void *const pointers[] = { this_function, call_site };
+ char **symbols = NULL;
+
++#ifdef __ANDROID__
++ fprintf(stderr, "backtrace_symbols() not available on Android\n");
++ exit(1);
++#else
+ symbols = backtrace_symbols(pointers, 2);
++#endif
+ if (symbols == NULL)
+ goto end;
+
--- /dev/null
+See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788113
+
+diff -N -u -r ../PRoot-5.1.0/src/loader/assemble-arm64.h ./src/loader/assemble-arm64.h
+--- ../PRoot-5.1.0/src/loader/assembly-arm64.h 1969-12-31 19:00:00.000000000 -0500
++++ ./src/loader/assembly-arm64.h 2016-01-08 20:12:46.494779723 -0500
+@@ -0,0 +1,93 @@
++/* -*- c-set-style: "K&R"; c-basic-offset: 8 -*-
++ *
++ * This file is part of PRoot.
++ *
++ * Copyright (C) 2014 STMicroelectronics
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
++ * 02110-1301 USA.
++ */
++
++#define BRANCH(stack_pointer, destination) do { \
++ asm volatile ( \
++ "// Restore initial stack pointer. \n\t" \
++ "mov sp, %0 \n\t" \
++ " \n\t" \
++ "// Clear rtld_fini. \n\t" \
++ "mov x0, #0 \n\t" \
++ " \n\t" \
++ "// Start the program. \n\t" \
++ "br %1 \n" \
++ : /* no output */ \
++ : "r" (stack_pointer), "r" (destination) \
++ : "memory", "sp", "x0"); \
++ __builtin_unreachable(); \
++ } while (0)
++
++#define PREPARE_ARGS_1(arg1_) \
++ register word_t arg1 asm("x0") = arg1_; \
++
++#define PREPARE_ARGS_3(arg1_, arg2_, arg3_) \
++ PREPARE_ARGS_1(arg1_) \
++ register word_t arg2 asm("x1") = arg2_; \
++ register word_t arg3 asm("x2") = arg3_; \
++
++#define PREPARE_ARGS_4(arg1_, arg2_, arg3_, arg4_) \
++ PREPARE_ARGS_3(arg1_, arg2_, arg3_) \
++ register word_t arg4 asm("x3") = arg4_;
++
++#define PREPARE_ARGS_6(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_) \
++ PREPARE_ARGS_3(arg1_, arg2_, arg3_) \
++ register word_t arg4 asm("x3") = arg4_; \
++ register word_t arg5 asm("x4") = arg5_; \
++ register word_t arg6 asm("x5") = arg6_;
++
++#define OUTPUT_CONTRAINTS_1 \
++ "r" (arg1)
++
++#define OUTPUT_CONTRAINTS_3 \
++ OUTPUT_CONTRAINTS_1, \
++ "r" (arg2), "r" (arg3)
++
++#define OUTPUT_CONTRAINTS_4 \
++ OUTPUT_CONTRAINTS_3, \
++ "r" (arg4)
++
++#define OUTPUT_CONTRAINTS_6 \
++ OUTPUT_CONTRAINTS_3, \
++ "r" (arg4), "r" (arg5), "r" (arg6)
++
++#define SYSCALL(number_, nb_args, args...) \
++ ({ \
++ register word_t number asm("w8") = number_; \
++ register word_t result asm("x0"); \
++ PREPARE_ARGS_##nb_args(args) \
++ asm volatile ( \
++ "svc #0x00000000 \n\t" \
++ : "=r" (result) \
++ : "r" (number), \
++ OUTPUT_CONTRAINTS_##nb_args \
++ : "memory"); \
++ result; \
++ })
++
++#define OPENAT 56
++#define CLOSE 57
++#define MMAP 222
++#define MMAP_OFFSET_SHIFT 0
++#define EXECVE 221
++#define EXIT 93
++#define PRCTL 167
++
--- /dev/null
+See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788113
+
+diff -N -u -r ../PRoot-5.1.0/src/loader/loader.c ./src/loader/loader.c
+--- ../PRoot-5.1.0/src/loader/loader.c 2014-12-15 09:18:11.000000000 -0500
++++ ./src/loader/loader.c 2016-01-08 20:16:54.746809929 -0500
+@@ -39,6 +39,8 @@
+ # include "loader/assembly-x86_64.h"
+ #elif defined(ARCH_ARM_EABI)
+ # include "loader/assembly-arm.h"
++#elif defined(ARCH_ARM64)
++# include "loader/assembly-arm64.h"
+ #elif defined(ARCH_X86)
+ # include "loader/assembly-x86.h"
+ #else
+@@ -134,7 +136,11 @@
+ /* Fall through. */
+
+ case LOAD_ACTION_OPEN:
++#ifdef OPENAT
++ fd = SYSCALL(OPENAT, 4, AT_FDCWD, stmt->open.string_address, O_RDONLY, 0);
++#else
+ fd = SYSCALL(OPEN, 3, stmt->open.string_address, O_RDONLY, 0);
++#endif
+ if (unlikely((int) fd < 0))
+ FATAL();
+
--- /dev/null
+diff -u -r ../PRoot-5.1.0/src/path/temp.c ./src/path/temp.c
+--- ../PRoot-5.1.0/src/path/temp.c 2014-12-15 09:18:11.000000000 -0500
++++ ./src/path/temp.c 2016-01-08 19:40:46.901462550 -0500
+@@ -120,9 +120,14 @@
+ {
+ int result;
+ int status;
+- char *cwd;
+
++#ifdef __ANDROID__
++ char cwd[PATH_MAX];
++ getcwd(cwd, PATH_MAX);
++#else
++ char *cwd;
+ cwd = get_current_dir_name();
++#endif
+
+ status = chmod(path, 0700);
+ if (status < 0) {
+@@ -163,7 +168,9 @@
+ result = -1;
+ note(NULL, ERROR, SYSTEM, "can't chdir to '%s'", cwd);
+ }
++#ifndef __ANDROID__
+ free(cwd);
++#endif
+ }
+
+ return result;
--- /dev/null
+diff -u -r ../PRoot-5.1.0/src/ptrace/ptrace.c ./src/ptrace/ptrace.c
+--- ../PRoot-5.1.0/src/ptrace/ptrace.c 2014-12-15 09:18:11.000000000 -0500
++++ ./src/ptrace/ptrace.c 2016-01-08 15:12:27.089144325 -0500
+@@ -27,6 +27,7 @@
+ #include <signal.h> /* siginfo_t, */
+ #include <sys/uio.h> /* struct iovec, */
+ #include <sys/param.h> /* MIN(), MAX(), */
++#include <sys/wait.h> /* __WALL */
+ #include <string.h> /* memcpy(3), */
+
+ #include "ptrace/ptrace.h"
+@@ -58,7 +59,13 @@
+ #define user_fpregs_struct user_fpsimd_struct
+ #endif
+
+-static const char *stringify_ptrace(enum __ptrace_request request)
++static const char *stringify_ptrace(
++#ifdef __ANDROID__
++ int
++#else
++ enum __ptrace_request
++#endif
++ request)
+ {
+ #define CASE_STR(a) case a: return #a; break;
+ switch ((int) request) {
--- /dev/null
+diff -u -r ../PRoot-5.1.0/src/ptrace/wait.h ./src/ptrace/wait.h
+--- ../PRoot-5.1.0/src/ptrace/wait.h 2014-12-15 09:18:11.000000000 -0500
++++ ./src/ptrace/wait.h 2016-01-08 09:07:20.342650218 -0500
+@@ -25,6 +25,8 @@
+
+ #include "tracee/tracee.h"
+
++#include <sys/wait.h> /* for __WALL */
++
+ extern int translate_wait_enter(Tracee *ptracer);
+ extern int translate_wait_exit(Tracee *ptracer);
+ extern bool handle_ptracee_event(Tracee *ptracee, int wait_status);
--- /dev/null
+diff -u -r ../PRoot-5.1.0/src/tracee/tracee.c ./src/tracee/tracee.c
+--- ../PRoot-5.1.0/src/tracee/tracee.c 2014-12-15 09:18:11.000000000 -0500
++++ ./src/tracee/tracee.c 2016-01-08 19:32:43.493157624 -0500
+@@ -538,6 +538,9 @@
+ /* Sanity check. */
+ assert(!child->as_ptracee.tracing_started);
+
++#ifndef __W_STOPCODE
++#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
++#endif
+ keep_stopped = handle_ptracee_event(child, __W_STOPCODE(SIGSTOP));
+
+ /* Note that this event was already handled by
--- /dev/null
+diff -u -r ../PRoot-5.1.0/src/tracee/tracee.h ./src/tracee/tracee.h
+--- ../PRoot-5.1.0/src/tracee/tracee.h 2014-12-15 09:18:11.000000000 -0500
++++ ./src/tracee/tracee.h 2016-01-08 09:04:52.144913929 -0500
+@@ -140,7 +140,12 @@
+ && get_sysnum((tracee), ORIGINAL) == sysnum)
+
+ /* How this tracee is restarted. */
+- enum __ptrace_request restart_how;
++#ifdef __ANDROID__
++ int
++#else
++ enum __ptrace_request
++#endif
++ restart_how;
+
+ /* Value of the tracee's general purpose registers. */
+ struct user_regs_struct _regs[NB_REG_VERSION];
--- /dev/null
+diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm64/usr/include/sys/user.h ./usr/include/sys/user.h
+--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm64/usr/include/sys/user.h 2014-12-08 21:59:41.000000000 -0500
++++ ./usr/include/sys/user.h 2016-01-08 20:08:08.327228220 -0500
+@@ -99,6 +99,13 @@
+ int u_debugreg[8];
+ };
+
++/* Needed by binutils on x86 */
++/* http://osxr.org/android/source/bionic/libc/kernel/arch-x86/asm/user_32.h#0089 */
++#define NBPG PAGE_SIZE
++#define UPAGES 1
++#define HOST_TEXT_START_ADDR (u.start_code)
++#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
++
+ #elif defined(__x86_64__)
+
+ struct user_fpregs_struct {
+@@ -234,7 +240,18 @@
+
+ #elif defined(__aarch64__)
+
+-// There are no user structures for 64 bit arm.
++/* From https://codereview.chromium.org/1291983003 */
++struct user_regs_struct {
++ __u64 regs[31];
++ __u64 sp;
++ __u64 pc;
++ __u64 pstate;
++};
++struct user_fpsimd_struct {
++ __uint128_t vregs[32];
++ __u32 fpsr;
++ __u32 fpcr;
++};
+
+ #else
+
+++ /dev/null
-Needed for binutils on x86.
-
-diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-x86/usr/include/sys/user.h ./usr/include/sys/user.h
---- /home/fornwall/lib/android-ndk/platforms/android-21/arch-x86/usr/include/sys/user.h 2014-12-01 19:05:05.000000000 -0500
-+++ ./usr/include/sys/user.h 2014-12-23 10:31:31.343768553 -0500
-@@ -99,6 +99,12 @@
- int u_debugreg[8];
- };
-
-+/* http://osxr.org/android/source/bionic/libc/kernel/arch-x86/asm/user_32.h#0089 */
-+#define NBPG PAGE_SIZE
-+#define UPAGES 1
-+#define HOST_TEXT_START_ADDR (u.start_code)
-+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
-+
- #elif defined(__x86_64__)
-
- struct user_fpregs_struct {