From 8eed5b2f19c24804c3069ac6078fd3bea8c3380e Mon Sep 17 00:00:00 2001 From: Hailiang Date: Tue, 18 Mar 2025 11:19:14 +0800 Subject: [PATCH] Add support for sw_64 (cherry picked from commit 17d6b82cc8269dd6767b54ebf7c9908e69d5154d) --- ltrace-0.7.91-add-support-for-sw_64.patch | 898 ++++++++++++++++++++++ ltrace.spec | 6 +- 2 files changed, 903 insertions(+), 1 deletion(-) create mode 100644 ltrace-0.7.91-add-support-for-sw_64.patch diff --git a/ltrace-0.7.91-add-support-for-sw_64.patch b/ltrace-0.7.91-add-support-for-sw_64.patch new file mode 100644 index 0000000..544ac7f --- /dev/null +++ b/ltrace-0.7.91-add-support-for-sw_64.patch @@ -0,0 +1,898 @@ +From a664997b9a9438ff5f7ff560bf5f1214bbc1ba80 Mon Sep 17 00:00:00 2001 +From: Hailiang +Date: Tue, 18 Mar 2025 11:16:03 +0800 +Subject: [PATCH] ltrace 0.7.91 add support for sw_64 + +--- + configure.ac | 2 + + sysdeps/linux-gnu/Makefile.am | 2 +- + sysdeps/linux-gnu/sw_64/Makefile.am | 34 ++ + sysdeps/linux-gnu/sw_64/arch.h | 29 ++ + sysdeps/linux-gnu/sw_64/plt.c | 36 +++ + sysdeps/linux-gnu/sw_64/ptrace.h | 21 ++ + sysdeps/linux-gnu/sw_64/regs.c | 61 ++++ + sysdeps/linux-gnu/sw_64/signalent.h | 52 +++ + sysdeps/linux-gnu/sw_64/syscallent.h | 459 +++++++++++++++++++++++++++ + sysdeps/linux-gnu/sw_64/trace.c | 96 ++++++ + 10 files changed, 791 insertions(+), 1 deletion(-) + create mode 100644 sysdeps/linux-gnu/sw_64/Makefile.am + create mode 100644 sysdeps/linux-gnu/sw_64/arch.h + create mode 100644 sysdeps/linux-gnu/sw_64/plt.c + create mode 100644 sysdeps/linux-gnu/sw_64/ptrace.h + create mode 100644 sysdeps/linux-gnu/sw_64/regs.c + create mode 100644 sysdeps/linux-gnu/sw_64/signalent.h + create mode 100644 sysdeps/linux-gnu/sw_64/syscallent.h + create mode 100644 sysdeps/linux-gnu/sw_64/trace.c + +diff --git a/configure.ac b/configure.ac +index fb030f2..3f615c7 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -48,6 +48,7 @@ case "${host_cpu}" in + powerpc|powerpc64*) HOST_CPU="ppc" ;; + riscv64) HOST_CPU="riscv64" ;; + sun4u|sparc64) HOST_CPU="sparc" ;; ++ sw_64) HOST_CPU="sw_64" ;; + s390x) HOST_CPU="s390" ;; + i?86|x86_64) HOST_CPU="x86" ;; + *) HOST_CPU="${host_cpu}" ;; +@@ -417,6 +418,7 @@ AC_CONFIG_FILES([ + sysdeps/linux-gnu/riscv64/Makefile + sysdeps/linux-gnu/s390/Makefile + sysdeps/linux-gnu/sparc/Makefile ++ sysdeps/linux-gnu/sw_64/Makefile + sysdeps/linux-gnu/x86/Makefile + testsuite/Makefile + testsuite/ltrace.main/Makefile +diff --git a/sysdeps/linux-gnu/Makefile.am b/sysdeps/linux-gnu/Makefile.am +index d7df1f9..b9a8daa 100644 +--- a/sysdeps/linux-gnu/Makefile.am ++++ b/sysdeps/linux-gnu/Makefile.am +@@ -18,7 +18,7 @@ + # 02110-1301 USA + + DIST_SUBDIRS = aarch64 alpha arm cris ia64 loongarch m68k metag mips \ +- ppc riscv64 s390 sparc x86 ++ ppc riscv64 s390 sw_64 sparc x86 + + SUBDIRS = \ + $(HOST_CPU) +diff --git a/sysdeps/linux-gnu/sw_64/Makefile.am b/sysdeps/linux-gnu/sw_64/Makefile.am +new file mode 100644 +index 0000000..5c6ecc2 +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/Makefile.am +@@ -0,0 +1,34 @@ ++# This file is part of ltrace. ++# Copyright (C) 2010 Marc Kleine-Budde, Pengutronix ++# ++# 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 St, Fifth Floor, Boston, MA ++# 02110-1301 USA ++ ++noinst_LTLIBRARIES = \ ++ ../libcpu.la ++ ++___libcpu_la_SOURCES = \ ++ plt.c \ ++ regs.c \ ++ trace.c ++ ++noinst_HEADERS = \ ++ arch.h \ ++ ptrace.h \ ++ signalent.h \ ++ syscallent.h ++ ++MAINTAINERCLEANFILES = \ ++ Makefile.in +diff --git a/sysdeps/linux-gnu/sw_64/arch.h b/sysdeps/linux-gnu/sw_64/arch.h +new file mode 100644 +index 0000000..e1c310b +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/arch.h +@@ -0,0 +1,29 @@ ++/* ++ * This file is part of ltrace. ++ * Copyright (C) 2004 Juan Cespedes ++ * ++ * 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 St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++#define BREAKPOINT_VALUE { 0x80, 0x00, 0x00, 0x00 } ++#define BREAKPOINT_LENGTH 4 ++#define DECR_PC_AFTER_BREAK 4 ++#define ARCH_ENDIAN_LITTLE ++ ++#define LT_ELFCLASS ELFCLASS64 ++#define LT_ELF_MACHINE EM_SW_64 ++#define LT_ELFCLASS2 ELFCLASS64 ++#define LT_ELF_MACHINE2 EM_FAKE_ALPHA +diff --git a/sysdeps/linux-gnu/sw_64/plt.c b/sysdeps/linux-gnu/sw_64/plt.c +new file mode 100644 +index 0000000..70a35b3 +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/plt.c +@@ -0,0 +1,36 @@ ++/* ++ * This file is part of ltrace. ++ * Copyright (C) 2004,2008,2009 Juan Cespedes ++ * ++ * 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 St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++#include ++#include "proc.h" ++#include "common.h" ++#ifdef __sw_64__ ++#include "library.h" ++#endif ++ ++GElf_Addr ++arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) { ++ return lte->plt_addr + ndx * 12 + 32; ++} ++ ++void * ++sym2addr(struct process *proc, struct library_symbol *sym) { ++ return sym->enter_addr; ++} +diff --git a/sysdeps/linux-gnu/sw_64/ptrace.h b/sysdeps/linux-gnu/sw_64/ptrace.h +new file mode 100644 +index 0000000..ad7e0d6 +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/ptrace.h +@@ -0,0 +1,21 @@ ++/* ++ * This file is part of ltrace. ++ * Copyright (C) 2004 Juan Cespedes ++ * ++ * 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 St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++#include +diff --git a/sysdeps/linux-gnu/sw_64/regs.c b/sysdeps/linux-gnu/sw_64/regs.c +new file mode 100644 +index 0000000..ff0dff8 +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/regs.c +@@ -0,0 +1,61 @@ ++/* ++ * This file is part of ltrace. ++ * Copyright (C) 2004,2008,2009 Juan Cespedes ++ * ++ * 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 St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++ ++#include "proc.h" ++#include "common.h" ++ ++#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) ++# define PTRACE_PEEKUSER PTRACE_PEEKUSR ++#endif ++ ++#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR)) ++# define PTRACE_POKEUSER PTRACE_POKEUSR ++#endif ++ ++void * ++get_instruction_pointer(struct process *proc) { ++ return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 64 /* REG_PC */ , 0); ++} ++ ++void ++set_instruction_pointer(struct process *proc, void *addr) { ++ ptrace(PTRACE_POKEUSER, proc->pid, 64 /* REG_PC */ , addr); ++} ++ ++void * ++get_stack_pointer(struct process *proc) { ++ return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 30 /* REG_FP */ , 0); ++} ++ ++void * ++get_return_addr(struct process *proc, void *stack_pointer) { ++ return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 26 /* RA */ , 0); ++} ++ ++void ++set_return_addr(struct process *proc, void *addr) { ++ ptrace(PTRACE_POKEUSER, proc->pid, 26 /* RA */ , addr); ++} +diff --git a/sysdeps/linux-gnu/sw_64/signalent.h b/sysdeps/linux-gnu/sw_64/signalent.h +new file mode 100644 +index 0000000..e9588fa +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/signalent.h +@@ -0,0 +1,52 @@ ++/* ++ * This file is part of ltrace. ++ * Copyright (C) 2006 Ian Wienand ++ * ++ * 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 St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++"SIG_0", /* 0 */ ++ "SIGHUP", /* 1 */ ++ "SIGINT", /* 2 */ ++ "SIGQUIT", /* 3 */ ++ "SIGILL", /* 4 */ ++ "SIGTRAP", /* 5 */ ++ "SIGABRT", /* 6 */ ++ "SIGEMT", /* 7 */ ++ "SIGFPE", /* 8 */ ++ "SIGKILL", /* 9 */ ++ "SIGBUS", /* 10 */ ++ "SIGSEGV", /* 11 */ ++ "SIGSYS", /* 12 */ ++ "SIGPIPE", /* 13 */ ++ "SIGALRM", /* 14 */ ++ "SIGTERM", /* 15 */ ++ "SIGURG", /* 16 */ ++ "SIGSTOP", /* 17 */ ++ "SIGTSTP", /* 18 */ ++ "SIGCONT", /* 19 */ ++ "SIGCHLD", /* 20 */ ++ "SIGTTIN", /* 21 */ ++ "SIGTTOU", /* 22 */ ++ "SIGIO", /* 23 */ ++ "SIGXCPU", /* 24 */ ++ "SIGXFSZ", /* 25 */ ++ "SIGVTALRM", /* 26 */ ++ "SIGPROF", /* 27 */ ++ "SIGWINCH", /* 28 */ ++ "SIGINFO", /* 29 */ ++ "SIGUSR1", /* 30 */ ++ "SIGUSR2", /* 31 */ +diff --git a/sysdeps/linux-gnu/sw_64/syscallent.h b/sysdeps/linux-gnu/sw_64/syscallent.h +new file mode 100644 +index 0000000..9a24315 +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/syscallent.h +@@ -0,0 +1,459 @@ ++/* ++ * This file is part of ltrace. ++ * Copyright (C) 2006 Ian Wienand ++ * ++ * 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 St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++"osf_syscall", /* 0, not implemented */ ++ "exit", /* 1 */ ++ "fork", /* 2 */ ++ "read", /* 3 */ ++ "write", /* 4 */ ++ "osf_old_open", /* 5, not implemented */ ++ "close", /* 6 */ ++ "osf_wait4", /* 7 */ ++ "osf_old_creat", /* 8, not implemented */ ++ "link", /* 9 */ ++ "unlink", /* 10 */ ++ "osf_execve", /* 11, not implemented */ ++ "chdir", /* 12 */ ++ "fchdir", /* 13 */ ++ "mknod", /* 14 */ ++ "chmod", /* 15 */ ++ "chown", /* 16 */ ++ "brk", /* 17 */ ++ "osf_getfsstat", /* 18, not implemented */ ++ "lseek", /* 19 */ ++ "getxpid", /* 20 */ ++ "osf_mount", /* 21 */ ++ "umount", /* 22 */ ++ "setuid", /* 23 */ ++ "getxuid", /* 24 */ ++ "exec_with_loader", /* 25, not implemented */ ++ "ptrace", /* 26 */ ++ "osf_nrecmsg", /* 27, not implemented */ ++ "osf_nsendmsg", /* 28, not implemented */ ++ "osf_nrecvfrom", /* 29, not implemented */ ++ "osf_naccept", /* 30, not implemented */ ++ "osf_ngetpeername", /* 31, not implemented */ ++ "osf_ngetsocketname", /* 32, not implemented */ ++ "access", /* 33 */ ++ "osf_chflags", /* 34, not implemented */ ++ "osf_fchflags", /* 35, not implemented */ ++ "sync", /* 36 */ ++ "kill", /* 37 */ ++ "osf_old_stat", /* 38, not implemented */ ++ "setpgid", /* 39 */ ++ "osf_old_lstat", /* 40, not implemented */ ++ "dup", /* 41 */ ++ "pipe", /* 42 */ ++ "osf_set_program_attributes", /* 43 */ ++ "osf_profil", /* 44, not implemented */ ++ "open", /* 45 */ ++ "osf_old_sigaction", /* 46, not implemented */ ++ "getxgid", /* 47 */ ++ "osf_sigprocmask", /* 48 */ ++ "osf_getlogin", /* 49, not implemented */ ++ "osf_setlogin", /* 50, not implemented */ ++ "acct", /* 51 */ ++ "sigpending", /* 52 */ ++ "SYS_53", /* 53 */ ++ "ioctl", /* 54 */ ++ "osf_reboot", /* 55, not implemented */ ++ "osf_revoke", /* 56, not implemented */ ++ "symlink", /* 57 */ ++ "readlink", /* 58 */ ++ "execve", /* 59 */ ++ "umask", /* 60 */ ++ "chroot", /* 61 */ ++ "osf_old_fstat", /* 62, not implemented */ ++ "getpgrp", /* 63 */ ++ "getpagesize", /* 64 */ ++ "osf_mremap", /* 65, not implemented */ ++ "vfork", /* 66 */ ++ "stat", /* 67 */ ++ "lstat", /* 68 */ ++ "osf_sbrk", /* 69, not implemented */ ++ "osf_sstk", /* 70, not implemented */ ++ "mmap", /* 71 */ ++ "osf_old_vadvise", /* 72, not implemented */ ++ "munmap", /* 73 */ ++ "mprotect", /* 74 */ ++ "madvise", /* 75 */ ++ "vhangup", /* 76 */ ++ "osf_kmodcall", /* 77, not implemented */ ++ "osf_mincore", /* 78, not implemented */ ++ "getgroups", /* 79 */ ++ "setgroups", /* 80 */ ++ "osf_old_getpgrp", /* 81, not implemented */ ++ "setpgrp", /* 82 */ ++ "osf_setitimer", /* 83 */ ++ "osf_old_wait", /* 84, not implemented */ ++ "osf_table", /* 85, not implemented */ ++ "osf_getitimer", /* 86 */ ++ "gethostname", /* 87 */ ++ "sethostname", /* 88 */ ++ "getdtablesize", /* 89 */ ++ "dup2", /* 90 */ ++ "fstat", /* 91 */ ++ "fcntl", /* 92 */ ++ "osf_select", /* 93 */ ++ "poll", /* 94 */ ++ "fsync", /* 95 */ ++ "setpriority", /* 96 */ ++ "socket", /* 97 */ ++ "connect", /* 98 */ ++ "accept", /* 99 */ ++ "osf_getpriority", /* 100 */ ++ "send", /* 101 */ ++ "recv", /* 102 */ ++ "sigreturn", /* 103 */ ++ "bind", /* 104 */ ++ "setsockopt", /* 105 */ ++ "listen", /* 106 */ ++ "osf_plock", /* 107, not implemented */ ++ "osf_old_sigvec", /* 108, not implemented */ ++ "osf_old_sigblock", /* 109, not implemented */ ++ "osf_old_sigsetmask", /* 110, not implemented */ ++ "sigsuspend", /* 111 */ ++ "sigstack", /* 112 */ ++ "recvmsg", /* 113 */ ++ "sendmsg", /* 114 */ ++ "osf_old_vtrace", /* 115, not implemented */ ++ "osf_gettimeofday", /* 116 */ ++ "osf_getrusage", /* 117 */ ++ "getsockopt", /* 118 */ ++ "SYS_119", /* 119 */ ++ "readv", /* 120 */ ++ "writev", /* 121 */ ++ "osf_settimeofday", /* 122 */ ++ "fchown", /* 123 */ ++ "fchmod", /* 124 */ ++ "recvfrom", /* 125 */ ++ "setreuid", /* 126 */ ++ "setregid", /* 127 */ ++ "rename", /* 128 */ ++ "truncate", /* 129 */ ++ "ftruncate", /* 130 */ ++ "flock", /* 131 */ ++ "setgid", /* 132 */ ++ "sendto", /* 133 */ ++ "shutdown", /* 134 */ ++ "socketpair", /* 135 */ ++ "mkdir", /* 136 */ ++ "rmdir", /* 137 */ ++ "osf_utimes", /* 138 */ ++ "osf_old_sigreturn", /* 139 */ ++ "osf_adjtime", /* 140, not implemented */ ++ "getpeername", /* 141 */ ++ "osf_gethostid", /* 142, not implemented */ ++ "osf_sethostid", /* 143, not implemented */ ++ "getrlimit", /* 144 */ ++ "setrlimit", /* 145 */ ++ "osf_old_killpg", /* 146, not implemented */ ++ "setsid", /* 147 */ ++ "quotactl", /* 148 */ ++ "osf_oldquota", /* 149, not implemented */ ++ "getsockname", /* 150 */ ++ "SYS_151", /* 151 */ ++ "SYS_152", /* 152 */ ++ "osf_pid_block", /* 153, not implemented */ ++ "osf_pid_unblock", /* 154, not implemented */ ++ "SYS_155", /* 155 */ ++ "sigaction", /* 156 */ ++ "osf_sigwaitprim", /* 157, not implemented */ ++ "osf_nfssvc", /* 158, not implemented */ ++ "osf_getdirentries", /* 159 */ ++ "osf_statfs", /* 160 */ ++ "osf_fstatfs", /* 161 */ ++ "SYS_162", /* 162 */ ++ "osf_asynch_daemon", /* 163, not implemented */ ++ "osf_getfh", /* 164, not implemented */ ++ "osf_getdomainname", /* 165 */ ++ "setdomainname", /* 166 */ ++ "SYS_167", /* 167 */ ++ "SYS_168", /* 168 */ ++ "osf_exportfs", /* 169, not implemented */ ++ "SYS_170", /* 170 */ ++ "SYS_171", /* 171 */ ++ "SYS_172", /* 172 */ ++ "SYS_173", /* 173 */ ++ "SYS_174", /* 174 */ ++ "SYS_175", /* 175 */ ++ "SYS_176", /* 176 */ ++ "SYS_177", /* 177 */ ++ "SYS_178", /* 178 */ ++ "SYS_179", /* 179 */ ++ "SYS_180", /* 180 */ ++ "osf_alt_plock", /* 181, not implemented */ ++ "SYS_182", /* 182 */ ++ "SYS_183", /* 183 */ ++ "osf_getmnt", /* 184, not implemented */ ++ "SYS_185", /* 185 */ ++ "SYS_186", /* 186 */ ++ "osf_alt_sigpending", /* 187, not implemented */ ++ "osf_alt_setsid", /* 188, not implemented */ ++ "SYS_189", /* 189 */ ++ "SYS_190", /* 190 */ ++ "SYS_191", /* 191 */ ++ "SYS_192", /* 192 */ ++ "SYS_193", /* 193 */ ++ "SYS_194", /* 194 */ ++ "SYS_195", /* 195 */ ++ "SYS_196", /* 196 */ ++ "SYS_197", /* 197 */ ++ "SYS_198", /* 198 */ ++ "osf_swapon", /* 199 */ ++ "msgctl", /* 200 */ ++ "msgget", /* 201 */ ++ "msgrcv", /* 202 */ ++ "msgsnd", /* 203 */ ++ "semctl", /* 204 */ ++ "semget", /* 205 */ ++ "semop", /* 206 */ ++ "osf_utsname", /* 207 */ ++ "lchown", /* 208 */ ++ "osf_shmat", /* 209 */ ++ "shmctl", /* 210 */ ++ "shmdt", /* 211 */ ++ "shmget", /* 212 */ ++ "osf_mvalid", /* 213, not implemented */ ++ "osf_getaddressconf", /* 214, not implemented */ ++ "osf_msleep", /* 215, not implemented */ ++ "osf_mwakeup", /* 216, not implemented */ ++ "msync", /* 217 */ ++ "osf_signal", /* 218, not implemented */ ++ "osf_utc_gettime", /* 219, not implemented */ ++ "osf_utc_adjtime", /* 220, not implemented */ ++ "SYS_221", /* 221 */ ++ "osf_security", /* 222, not implemented */ ++ "osf_kloadcall", /* 223, not implemented */ ++ "SYS_224", /* 224 */ ++ "SYS_225", /* 225 */ ++ "SYS_226", /* 226 */ ++ "SYS_227", /* 227 */ ++ "SYS_228", /* 228 */ ++ "SYS_229", /* 229 */ ++ "SYS_230", /* 230 */ ++ "SYS_231", /* 231 */ ++ "SYS_232", /* 232 */ ++ "getpgid", /* 233 */ ++ "getsid", /* 234 */ ++ "sigaltstack", /* 235 */ ++ "osf_waitid", /* 236, not implemented */ ++ "osf_priocntlset", /* 237, not implemented */ ++ "osf_sigsendset", /* 238, not implemented */ ++ "osf_set_speculative", /* 239, not implemented */ ++ "osf_msfs_syscall", /* 240, not implemented */ ++ "osf_sysinfo", /* 241 */ ++ "osf_uadmin", /* 242, not implemented */ ++ "osf_fuser", /* 243, not implemented */ ++ "osf_proplist_syscall", /* 244 */ ++ "osf_ntp_adjtime", /* 245, not implemented */ ++ "osf_ntp_gettime", /* 246, not implemented */ ++ "osf_pathconf", /* 247, not implemented */ ++ "osf_fpathconf", /* 248, not implemented */ ++ "SYS_249", /* 249 */ ++ "osf_uswitch", /* 250, not implemented */ ++ "osf_usleep_thread", /* 251 */ ++ "osf_audcntl", /* 252, not implemented */ ++ "osf_audgen", /* 253, not implemented */ ++ "sysfs", /* 254 */ ++ "osf_subsysinfo", /* 255, not implemented */ ++ "osf_getsysinfo", /* 256 */ ++ "osf_setsysinfo", /* 257 */ ++ "osf_afs_syscall", /* 258, not implemented */ ++ "osf_swapctl", /* 259, not implemented */ ++ "osf_memcntl", /* 260, not implemented */ ++ "osf_fdatasync", /* 261, not implemented */ ++ "SYS_262", /* 262 */ ++ "SYS_263", /* 263 */ ++ "SYS_264", /* 264 */ ++ "SYS_265", /* 265 */ ++ "SYS_266", /* 266 */ ++ "SYS_267", /* 267 */ ++ "SYS_268", /* 268 */ ++ "SYS_269", /* 269 */ ++ "SYS_270", /* 270 */ ++ "SYS_271", /* 271 */ ++ "SYS_272", /* 272 */ ++ "SYS_273", /* 273 */ ++ "SYS_274", /* 274 */ ++ "SYS_275", /* 275 */ ++ "SYS_276", /* 276 */ ++ "SYS_277", /* 277 */ ++ "SYS_278", /* 278 */ ++ "SYS_279", /* 279 */ ++ "SYS_280", /* 280 */ ++ "SYS_281", /* 281 */ ++ "SYS_282", /* 282 */ ++ "SYS_283", /* 283 */ ++ "SYS_284", /* 284 */ ++ "SYS_285", /* 285 */ ++ "SYS_286", /* 286 */ ++ "SYS_287", /* 287 */ ++ "SYS_288", /* 288 */ ++ "SYS_289", /* 289 */ ++ "SYS_290", /* 290 */ ++ "SYS_291", /* 291 */ ++ "SYS_292", /* 292 */ ++ "SYS_293", /* 293 */ ++ "SYS_294", /* 294 */ ++ "SYS_295", /* 295 */ ++ "SYS_296", /* 296 */ ++ "SYS_297", /* 297 */ ++ "SYS_298", /* 298 */ ++ "SYS_299", /* 299 */ ++ "bdflush", /* 300 */ ++ "sethae", /* 301 */ ++ "mount", /* 302 */ ++ "adjtimex32", /* 303 */ ++ "swapoff", /* 304 */ ++ "getdents", /* 305 */ ++ "create_module", /* 306 */ ++ "init_module", /* 307 */ ++ "delete_module", /* 308 */ ++ "get_kernel_syms", /* 309 */ ++ "syslog", /* 310 */ ++ "reboot", /* 311 */ ++ "clone", /* 312 */ ++ "uselib", /* 313 */ ++ "mlock", /* 314 */ ++ "munlock", /* 315 */ ++ "mlockall", /* 316 */ ++ "munlockall", /* 317 */ ++ "sysinfo", /* 318 */ ++ "sysctl", /* 319 */ ++ "idle", /* 320 */ ++ "oldumount", /* 321 */ ++ "swapon", /* 322 */ ++ "times", /* 323 */ ++ "personality", /* 324 */ ++ "setfsuid", /* 325 */ ++ "setfsgid", /* 326 */ ++ "ustat", /* 327 */ ++ "statfs", /* 328 */ ++ "fstatfs", /* 329 */ ++ "sched_setparam", /* 330 */ ++ "sched_getparam", /* 331 */ ++ "sched_setscheduler", /* 332 */ ++ "sched_getscheduler", /* 333 */ ++ "sched_yield", /* 334 */ ++ "sched_get_priority_max", /* 335 */ ++ "sched_get_priority_min", /* 336 */ ++ "sched_rr_get_interval", /* 337 */ ++ "afs_syscall", /* 338 */ ++ "uname", /* 339 */ ++ "nanosleep", /* 340 */ ++ "mremap", /* 341 */ ++ "nfsservctl", /* 342 */ ++ "setresuid", /* 343 */ ++ "getresuid", /* 344 */ ++ "pciconfig_read", /* 345 */ ++ "pciconfig_write", /* 346 */ ++ "query_module", /* 347 */ ++ "prctl", /* 348 */ ++ "pread", /* 349 */ ++ "pwrite", /* 350 */ ++ "rt_sigreturn", /* 351 */ ++ "rt_sigaction", /* 352 */ ++ "rt_sigprocmask", /* 353 */ ++ "rt_sigpending", /* 354 */ ++ "rt_sigtimedwait", /* 355 */ ++ "rt_sigqueueinfo", /* 356 */ ++ "rt_sigsuspend", /* 357 */ ++ "select", /* 358 */ ++ "gettimeofday", /* 359 */ ++ "settimeofday", /* 360 */ ++ "getitimer", /* 361 */ ++ "setitimer", /* 362 */ ++ "utimes", /* 363 */ ++ "getrusage", /* 364 */ ++ "wait4", /* 365 */ ++ "adjtimex", /* 366 */ ++ "getcwd", /* 367 */ ++ "capget", /* 368 */ ++ "capset", /* 369 */ ++ "sendfile", /* 370 */ ++ "setresgid", /* 371 */ ++ "getresgid", /* 372 */ ++ "dipc", /* 373, not implemented */ ++ "pivot_root", /* 374 */ ++ "mincore", /* 375 */ ++ "pciconfig_iobase", /* 376 */ ++ "getdents64", /* 377 */ ++ "gettid", /* 378 */ ++ "readahead", /* 379 */ ++ "SYS_380", /* 380 */ ++ "tkill", /* 381 */ ++ "setxattr", /* 382 */ ++ "lsetxattr", /* 383 */ ++ "fsetxattr", /* 384 */ ++ "getxattr", /* 385 */ ++ "lgetxattr", /* 386 */ ++ "fgetxattr", /* 387 */ ++ "listxattr", /* 388 */ ++ "llistxattr", /* 389 */ ++ "flistxattr", /* 390 */ ++ "removexattr", /* 391 */ ++ "lremovexattr", /* 392 */ ++ "fremovexattr", /* 393 */ ++ "futex", /* 394 */ ++ "sched_setaffinity", /* 395 */ ++ "sched_getaffinity", /* 396 */ ++ "tuxcall", /* 397 */ ++ "io_setup", /* 398 */ ++ "io_destroy", /* 399 */ ++ "io_getevents", /* 400 */ ++ "io_submit", /* 401 */ ++ "io_cancel", /* 402 */ ++ "SYS_403", /* 403 */ ++ "SYS_404", /* 404 */ ++ "exit_group", /* 405 */ ++ "lookup_dcookie", /* 406 */ ++ "epoll_create", /* 407 */ ++ "epoll_ctl", /* 408 */ ++ "epoll_wait", /* 409 */ ++ "remap_file_pages", /* 410 */ ++ "set_tid_address", /* 411 */ ++ "restart_syscall", /* 412 */ ++ "fadvise", /* 413 */ ++ "timer_create", /* 414 */ ++ "timer_settime", /* 415 */ ++ "timer_gettime", /* 416 */ ++ "timer_getoverrun", /* 417 */ ++ "timer_delete", /* 418 */ ++ "clock_settime", /* 419 */ ++ "clock_gettime", /* 420 */ ++ "clock_getres", /* 421 */ ++ "clock_nanosleep", /* 422 */ ++ "semtimedop", /* 423 */ ++ "tgkill", /* 424 */ ++ "stat64", /* 425 */ ++ "lstat64", /* 426 */ ++ "fstat64", /* 427 */ ++ "vserver", /* 428 */ ++ "mbind", /* 429 */ ++ "get_mempolicy", /* 430 */ ++ "set_mempolicy", /* 431 */ ++ "mq_open", /* 432 */ ++ "mq_unlink", /* 433 */ ++ "mq_timedsend", /* 434 */ ++ "mq_timedreceive", /* 435 */ ++ "mq_notify", /* 436 */ ++ "mq_getsetattr", /* 437 */ ++ "waitid" /* 438 */ +diff --git a/sysdeps/linux-gnu/sw_64/trace.c b/sysdeps/linux-gnu/sw_64/trace.c +new file mode 100644 +index 0000000..aeafa45 +--- /dev/null ++++ b/sysdeps/linux-gnu/sw_64/trace.c +@@ -0,0 +1,96 @@ ++/* ++ * This file is part of ltrace. ++ * Copyright (C) 2004,2008,2009 Juan Cespedes ++ * Copyright (C) 2006 Ian Wienand ++ * ++ * 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 St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "proc.h" ++#include "common.h" ++#ifdef __sw_64__ ++#include "backend.h" ++#endif ++ ++#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) ++# define PTRACE_PEEKUSER PTRACE_PEEKUSR ++#endif ++ ++#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR)) ++# define PTRACE_POKEUSER PTRACE_POKEUSR ++#endif ++ ++void ++get_arch_dep(struct process *proc) { ++} ++ ++/* Returns 1 if syscall, 2 if sysret, 0 otherwise. ++ */ ++int ++syscall_p(struct process *proc, int status, int *sysnum) { ++ if (WIFSTOPPED(status) ++ && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) { ++ char *ip = get_instruction_pointer(proc) - 4; ++ long x = ptrace(PTRACE_PEEKTEXT, proc->pid, ip, 0); ++ debug(2, "instr: %016lx", x); ++ if ((x & 0xffffffff) != 0x00000083) ++ return 0; ++ *sysnum = ++ ptrace(PTRACE_PEEKUSER, proc->pid, 0 /* REG_R0 */ , 0); ++ if (proc->callstack_depth > 0 && ++ proc->callstack[proc->callstack_depth - 1].is_syscall && ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) { ++ return 2; ++ } ++ if (*sysnum >= 0 && *sysnum < 500) { ++ return 1; ++ } ++ } ++ return 0; ++} ++ ++long ++gimme_arg(enum tof type, struct process *proc, int arg_num, struct arg_type_info *info) ++{ ++ if (arg_num == -1) { /* return value */ ++ return ptrace(PTRACE_PEEKUSER, proc->pid, 0 /* REG_R0 */ , 0); ++ } ++ ++ if (type == LT_TOF_FUNCTION || type == LT_TOF_FUNCTIONR) { ++ if (arg_num <= 5) ++ return ptrace(PTRACE_PEEKUSER, proc->pid, ++ arg_num + 16 /* REG_A0 */ , 0); ++ else ++ return ptrace(PTRACE_PEEKTEXT, proc->pid, ++ proc->stack_pointer + 8 * (arg_num - 6), ++ 0); ++ } else if (type == LT_TOF_SYSCALL || type == LT_TOF_SYSCALLR) { ++ return ptrace(PTRACE_PEEKUSER, proc->pid, ++ arg_num + 16 /* REG_A0 */ , 0); ++ } else { ++ fprintf(stderr, "gimme_arg called with wrong arguments\n"); ++ exit(1); ++ } ++ return 0; ++} +-- +2.20.1 + diff --git a/ltrace.spec b/ltrace.spec index 28a9fb3..b92ea2f 100644 --- a/ltrace.spec +++ b/ltrace.spec @@ -1,6 +1,6 @@ name: ltrace Version: 0.7.91 -Release: 34 +Release: 35 Summary: Trace the Library and System Calls a Program Makes License: GPLv2+ @@ -35,6 +35,7 @@ Patch9004: Initialize-nrhs-to-avoid-gcc-warning.patch Patch8000: ltrace-0.7.91-add-support-for-loongarch.patch Patch8001: ltrace-0.7.91-add-initial-riscv64-support.patch Patch8002: ltrace-0.7.91-add-support-for-ppc64le.patch +Patch8003: ltrace-0.7.91-add-support-for-sw_64.patch BuildRequires: elfutils-devel dejagnu libselinux-devel autoconf automake libtool @@ -80,6 +81,9 @@ autoreconf -i %{_mandir}/man5/ltrace.conf.5* %changelog +* Tue Mar 18 2025 mahailiang - 0.7.91-35 +- Add support for sw_64 + * Tue Dec 19 2023 peng.zou - 0.7.91-34 - Add support for ppc64le -- Gitee