| 1 | See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788113 |
| 2 | |
| 3 | diff -N -u -r ../PRoot-5.1.0/src/loader/assemble-arm64.h ./src/loader/assemble-arm64.h |
| 4 | --- ../PRoot-5.1.0/src/loader/assembly-arm64.h 1969-12-31 19:00:00.000000000 -0500 |
| 5 | +++ ./src/loader/assembly-arm64.h 2016-01-08 20:12:46.494779723 -0500 |
| 6 | @@ -0,0 +1,93 @@ |
| 7 | +/* -*- c-set-style: "K&R"; c-basic-offset: 8 -*- |
| 8 | + * |
| 9 | + * This file is part of PRoot. |
| 10 | + * |
| 11 | + * Copyright (C) 2014 STMicroelectronics |
| 12 | + * |
| 13 | + * This program is free software; you can redistribute it and/or |
| 14 | + * modify it under the terms of the GNU General Public License as |
| 15 | + * published by the Free Software Foundation; either version 2 of the |
| 16 | + * License, or (at your option) any later version. |
| 17 | + * |
| 18 | + * This program is distributed in the hope that it will be useful, but |
| 19 | + * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | + * General Public License for more details. |
| 22 | + * |
| 23 | + * You should have received a copy of the GNU General Public License |
| 24 | + * along with this program; if not, write to the Free Software |
| 25 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 26 | + * 02110-1301 USA. |
| 27 | + */ |
| 28 | + |
| 29 | +#define BRANCH(stack_pointer, destination) do { \ |
| 30 | + asm volatile ( \ |
| 31 | + "// Restore initial stack pointer. \n\t" \ |
| 32 | + "mov sp, %0 \n\t" \ |
| 33 | + " \n\t" \ |
| 34 | + "// Clear rtld_fini. \n\t" \ |
| 35 | + "mov x0, #0 \n\t" \ |
| 36 | + " \n\t" \ |
| 37 | + "// Start the program. \n\t" \ |
| 38 | + "br %1 \n" \ |
| 39 | + : /* no output */ \ |
| 40 | + : "r" (stack_pointer), "r" (destination) \ |
| 41 | + : "memory", "sp", "x0"); \ |
| 42 | + __builtin_unreachable(); \ |
| 43 | + } while (0) |
| 44 | + |
| 45 | +#define PREPARE_ARGS_1(arg1_) \ |
| 46 | + register word_t arg1 asm("x0") = arg1_; \ |
| 47 | + |
| 48 | +#define PREPARE_ARGS_3(arg1_, arg2_, arg3_) \ |
| 49 | + PREPARE_ARGS_1(arg1_) \ |
| 50 | + register word_t arg2 asm("x1") = arg2_; \ |
| 51 | + register word_t arg3 asm("x2") = arg3_; \ |
| 52 | + |
| 53 | +#define PREPARE_ARGS_4(arg1_, arg2_, arg3_, arg4_) \ |
| 54 | + PREPARE_ARGS_3(arg1_, arg2_, arg3_) \ |
| 55 | + register word_t arg4 asm("x3") = arg4_; |
| 56 | + |
| 57 | +#define PREPARE_ARGS_6(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_) \ |
| 58 | + PREPARE_ARGS_3(arg1_, arg2_, arg3_) \ |
| 59 | + register word_t arg4 asm("x3") = arg4_; \ |
| 60 | + register word_t arg5 asm("x4") = arg5_; \ |
| 61 | + register word_t arg6 asm("x5") = arg6_; |
| 62 | + |
| 63 | +#define OUTPUT_CONTRAINTS_1 \ |
| 64 | + "r" (arg1) |
| 65 | + |
| 66 | +#define OUTPUT_CONTRAINTS_3 \ |
| 67 | + OUTPUT_CONTRAINTS_1, \ |
| 68 | + "r" (arg2), "r" (arg3) |
| 69 | + |
| 70 | +#define OUTPUT_CONTRAINTS_4 \ |
| 71 | + OUTPUT_CONTRAINTS_3, \ |
| 72 | + "r" (arg4) |
| 73 | + |
| 74 | +#define OUTPUT_CONTRAINTS_6 \ |
| 75 | + OUTPUT_CONTRAINTS_3, \ |
| 76 | + "r" (arg4), "r" (arg5), "r" (arg6) |
| 77 | + |
| 78 | +#define SYSCALL(number_, nb_args, args...) \ |
| 79 | + ({ \ |
| 80 | + register word_t number asm("w8") = number_; \ |
| 81 | + register word_t result asm("x0"); \ |
| 82 | + PREPARE_ARGS_##nb_args(args) \ |
| 83 | + asm volatile ( \ |
| 84 | + "svc #0x00000000 \n\t" \ |
| 85 | + : "=r" (result) \ |
| 86 | + : "r" (number), \ |
| 87 | + OUTPUT_CONTRAINTS_##nb_args \ |
| 88 | + : "memory"); \ |
| 89 | + result; \ |
| 90 | + }) |
| 91 | + |
| 92 | +#define OPENAT 56 |
| 93 | +#define CLOSE 57 |
| 94 | +#define MMAP 222 |
| 95 | +#define MMAP_OFFSET_SHIFT 0 |
| 96 | +#define EXECVE 221 |
| 97 | +#define EXIT 93 |
| 98 | +#define PRCTL 167 |
| 99 | + |