From: Dmitry V. Levin Date: Wed, 5 Dec 2018 18:37:34 +0000 (+0000) Subject: x86_64: remove some annoying pieces of unused code X-Git-Tag: v4.26~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f84eefc409291354d0dc7db0866eaf27967da42;p=strace x86_64: remove some annoying pieces of unused code * linux/x86_64/get_scno.c (X32_PERSONALITY_NUMBER): Remove. (arch_get_scno): Remove ifdefed archeological artefacts. --- diff --git a/linux/x86_64/get_scno.c b/linux/x86_64/get_scno.c index 4b066387..c3032a62 100644 --- a/linux/x86_64/get_scno.c +++ b/linux/x86_64/get_scno.c @@ -31,12 +31,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef X86_64 -# define X32_PERSONALITY_NUMBER 2 -#else -# define X32_PERSONALITY_NUMBER 0 -#endif - /* Return codes: 1 - ok, 0 - ignore, other - error. */ static int arch_get_scno(struct tcb *tcp) @@ -48,7 +42,6 @@ arch_get_scno(struct tcb *tcp) # define __X32_SYSCALL_BIT 0x40000000 #endif -#if 1 /* * GETREGSET of NT_PRSTATUS tells us regset size, * which unambiguously detects i386. @@ -84,61 +77,6 @@ arch_get_scno(struct tcb *tcp) } } -#elif 0 - /* - * cs = 0x33 for long mode (native 64 bit and x32) - * cs = 0x23 for compatibility mode (32 bit) - * ds = 0x2b for x32 mode (x86-64 in 32 bit) - */ - scno = x86_64_regs.orig_rax; - switch (x86_64_regs.cs) { - case 0x23: - currpers = 1; - break; - case 0x33: - if (x86_64_regs.ds == 0x2b) { - currpers = 2; - } else - currpers = 0; - break; - default: - error_msg("Unknown value CS=0x%08X while " - "detecting personality of process PID=%d", - (int)x86_64_regs.cs, tcp->pid); - currpers = current_personality; - break; - } -#elif 0 - /* - * This version analyzes the opcode of a syscall instruction. - * (int 0x80 on i386 vs. syscall on x86-64) - * It works, but is too complicated, and strictly speaking, unreliable. - */ - unsigned long call, rip = x86_64_regs.rip; - /* sizeof(syscall) == sizeof(int 0x80) == 2 */ - rip -= 2; - errno = 0; - call = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)rip, (char *)0); - if (errno) - perror_msg("ptrace_peektext failed"); - switch (call & 0xffff) { - /* x86-64: syscall = 0x0f 0x05 */ - case 0x050f: - currpers = 0; - break; - /* i386: int 0x80 = 0xcd 0x80 */ - case 0x80cd: - currpers = 1; - break; - default: - currpers = current_personality; - error_msg("Unknown syscall opcode (0x%04X) while " - "detecting personality of process PID=%d", - (int)call, tcp->pid); - break; - } -#endif - #ifdef X32 /* * If we are built for a x32 system, then personality 0 is x32