"Fossies" - the Fresh Open Source Software Archive

Member "reptyr-reptyr-0.8.0/platform/linux/arch/amd64.h" (29 Sep 2020, 3478 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 "amd64.h" see the Fossies "Dox" file reference documentation.

    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 #include "x86_common.h"
   23 
   24 #define ARCH_HAVE_MULTIPLE_PERSONALITIES
   25 
   26 static struct ptrace_personality arch_personality[2] = {
   27     {
   28         offsetof(struct user_regs_struct, rax),
   29         offsetof(struct user_regs_struct, rdi),
   30         offsetof(struct user_regs_struct, rsi),
   31         offsetof(struct user_regs_struct, rdx),
   32         offsetof(struct user_regs_struct, r10),
   33         offsetof(struct user_regs_struct, r8),
   34         offsetof(struct user_regs_struct, r9),
   35         offsetof(struct user_regs_struct, rip),
   36     },
   37     {
   38         offsetof(struct user_regs_struct, rax),
   39         offsetof(struct user_regs_struct, rbx),
   40         offsetof(struct user_regs_struct, rcx),
   41         offsetof(struct user_regs_struct, rdx),
   42         offsetof(struct user_regs_struct, rsi),
   43         offsetof(struct user_regs_struct, rdi),
   44         offsetof(struct user_regs_struct, rbp),
   45         offsetof(struct user_regs_struct, rip),
   46     },
   47 };
   48 
   49 struct x86_personality x86_personality[2] = {
   50     {
   51         offsetof(struct user_regs_struct, orig_rax),
   52         offsetof(struct user_regs_struct, rax),
   53     },
   54     {
   55         offsetof(struct user_regs_struct, orig_rax),
   56         offsetof(struct user_regs_struct, rax),
   57     },
   58 };
   59 
   60 struct syscall_numbers arch_syscall_numbers[2] = {
   61 #include "default-syscalls.h"
   62     {
   63         /*
   64          * These don't seem to be available in any convenient header. We could
   65          * include unistd_32.h, but those definitions would conflict with the
   66          * standard ones. So, let's just hardcode the values for now. Probably
   67          * we should generate this from unistd_32.h during the build process or
   68          * something.
   69          */
   70         .nr_mmap    = 90,
   71         .nr_mmap2   = 192,
   72         .nr_munmap  = 91,
   73         .nr_getsid  = 147,
   74         .nr_setsid  = 66,
   75         .nr_setpgid = 57,
   76         .nr_fork    = 2,
   77         .nr_wait4   = 114,
   78         .nr_signal  = 48,
   79         .nr_rt_sigaction = 174,
   80         .nr_openat  = 295,
   81         .nr_close   = 6,
   82         .nr_ioctl   = 54,
   83         .nr_dup2    = 63,
   84         .nr_socketcall = 102,
   85     }
   86 };
   87 
   88 int arch_get_personality(struct ptrace_child *child) {
   89     unsigned long cs;
   90 
   91     cs = ptrace_command(child, PTRACE_PEEKUSER,
   92                         offsetof(struct user_regs_struct, cs));
   93     if (child->error)
   94         return -1;
   95     if (cs == 0x23)
   96         child->personality = 1;
   97     return 0;
   98 }