From 714a162048c8ef2330c0305c9275fd73eafc62e6 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Sat, 20 Aug 2016 17:02:55 +0300 Subject: [PATCH] Move SH-specific argument number calculation to getllval This change prevents scattering of ll-related hacks and simplifies pread/pwrite syscalls parsers' logic a bit. * util.c (getllval): Add fixup for arg_no for SuperH when argument number is equal to 3. * io.c (PREAD_OFFSET_ARG): Remove. (SYS_FUNC(pread)): Always use argument number 3 for "count" argument printing. (SYS_FUNC(pwrite)): Likewise. --- io.c | 15 ++------------- util.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/io.c b/io.c index 58323a7c..ee849733 100644 --- a/io.c +++ b/io.c @@ -150,17 +150,6 @@ SYS_FUNC(writev) return RVAL_DECODED; } -/* The SH4 ABI does allow long longs in odd-numbered registers, but - does not allow them to be split between registers and memory - and - there are only four argument registers for normal functions. As a - result pread takes an extra padding argument before the offset. This - was changed late in the 2.4 series (around 2.4.20). */ -#if defined(SH) -#define PREAD_OFFSET_ARG 4 -#else -#define PREAD_OFFSET_ARG 3 -#endif - SYS_FUNC(pread) { if (entering(tcp)) { @@ -172,7 +161,7 @@ SYS_FUNC(pread) else printstr(tcp, tcp->u_arg[1], tcp->u_rval); tprintf(", %lu, ", tcp->u_arg[2]); - printllval(tcp, "%lld", PREAD_OFFSET_ARG); + printllval(tcp, "%lld", 3); } return 0; } @@ -183,7 +172,7 @@ SYS_FUNC(pwrite) tprints(", "); printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); tprintf(", %lu, ", tcp->u_arg[2]); - printllval(tcp, "%lld", PREAD_OFFSET_ARG); + printllval(tcp, "%lld", 3); return RVAL_DECODED; } diff --git a/util.c b/util.c index afa32903..056711d1 100644 --- a/util.c +++ b/util.c @@ -275,7 +275,17 @@ getllval(struct tcb *tcp, unsigned long long *val, int arg_no) defined XTENSA /* Align arg_no to the next even number. */ arg_no = (arg_no + 1) & 0xe; -# endif +# elif defined SH + /* + * The SH4 ABI does allow long longs in odd-numbered registers, but + * does not allow them to be split between registers and memory - and + * there are only four argument registers for normal functions. As a + * result, pread, for example, takes an extra padding argument before + * the offset. This was changed late in the 2.4 series (around 2.4.20). + */ + if (arg_no == 3) + arg_no++; +# endif /* __ARM_EABI__ || LINUX_MIPSO32 || POWERPC || XTENSA || SH */ *val = LONG_LONG(tcp->u_arg[arg_no], tcp->u_arg[arg_no + 1]); arg_no += 2; #endif -- 2.40.0