"Fossies" - the Fresh Open Source Software Archive

Member "reptyr-reptyr-0.8.0/platform/linux/arch/aarch64.h" (29 Sep 2020, 2633 Bytes) of package /linux/privat/reptyr-reptyr-0.8.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "aarch64.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 0.7.0_vs_0.8.0.

    1 /*
    2  * Copyright (C) 2011 by Nelson Elhage
    3  *
    4  * Permission is hereby granted, free of charge, to any person obtaining a copy
    5  * of this software and associated documentation files (the "Software"), to deal
    6  * in the Software without restriction, including without limitation the rights
    7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    8  * copies of the Software, and to permit persons to whom the Software is
    9  * furnished to do so, subject to the following conditions:
   10  *
   11  * The above copyright notice and this permission notice shall be included in
   12  * all copies or substantial portions of the Software.
   13  *
   14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   20  * THE SOFTWARE.
   21  */
   22 
   23 #ifndef NT_ARM_SYSTEM_CALL
   24 #define NT_ARM_SYSTEM_CALL  0x404   /* ARM system call number */
   25 #endif
   26 
   27 static struct ptrace_personality arch_personality[1] = {
   28     {
   29         offsetof(struct user_regs_struct, regs[0]),
   30         offsetof(struct user_regs_struct, regs[0]),
   31         offsetof(struct user_regs_struct, regs[1]),
   32         offsetof(struct user_regs_struct, regs[2]),
   33         offsetof(struct user_regs_struct, regs[3]),
   34         offsetof(struct user_regs_struct, regs[4]),
   35         offsetof(struct user_regs_struct, regs[5]),
   36         offsetof(struct user_regs_struct, pc),
   37     }
   38 };
   39 
   40 static inline void arch_fixup_regs(struct ptrace_child *child) {
   41     child->regs.pc -= 4;
   42 }
   43 
   44 static inline int arch_set_syscall(struct ptrace_child *child,
   45                                    unsigned long sysno) {
   46     int syscall_reg = sysno;
   47     struct iovec reg_iovec = {
   48         .iov_base = &syscall_reg,
   49         .iov_len = sizeof(syscall_reg)
   50     };
   51     return ptrace_command(child, PTRACE_SETREGSET, NT_ARM_SYSTEM_CALL, &reg_iovec);
   52 }
   53 
   54 static inline int arch_save_syscall(struct ptrace_child *child) {
   55     int syscall_reg;
   56     struct iovec reg_iovec = {
   57         .iov_base = &syscall_reg,
   58         .iov_len = sizeof(syscall_reg)
   59     };
   60     if (ptrace_command(child, PTRACE_GETREGSET, NT_ARM_SYSTEM_CALL, &reg_iovec) < 0)
   61         return -1;
   62 
   63     child->saved_syscall = syscall_reg;
   64     return 0;
   65 }
   66 
   67 static inline int arch_restore_syscall(struct ptrace_child *child) {
   68     return arch_set_syscall(child, child->saved_syscall);
   69 }