Rebase from upstream commit : 3bb9dcf44627ffdd313fe92c563ae454b6ff8aa6
[librecmc/librecmc.git] / package / devel / strace / patches / 001-mips-o32-fix-build.patch
1 From 2c8b6de913973274e877639658e9e7273a012adb Mon Sep 17 00:00:00 2001
2 From: "Dmitry V. Levin" <ldv@altlinux.org>
3 Date: Tue, 8 Jan 2019 19:23:44 +0000
4 Subject: [PATCH] mips o32: fix build
5
6 Commit 917c2ccf3a67 "Refactor stack pointers" moved mips_REG_* macros
7 from linux/mips/arch_regs.h to linux/mips/arch_regs.c because these
8 macros are no longer used outside syscall.c or files included by
9 syscall.c, but this caused a build regression on mips o32 because
10 decode_syscall_subcall() uses mips_REG_SP prior to its definition.
11
12 * syscall.c (decode_syscall_subcall): Move ...
13 * linux/mips/get_syscall_args.c: ... here.
14 * NEWS: Mention this fix.
15
16 Reported-by: Baruch Siach <baruch@tkos.co.il>
17 Fixes: v4.26~61 "Refactor stack pointers"
18 ---
19  NEWS                          |  1 +
20  linux/mips/get_syscall_args.c | 26 ++++++++++++++++++++++++++
21  syscall.c                     | 27 ++-------------------------
22  3 files changed, 29 insertions(+), 25 deletions(-)
23
24 --- a/linux/mips/get_syscall_args.c
25 +++ b/linux/mips/get_syscall_args.c
26 @@ -37,3 +37,29 @@ arch_get_syscall_args(struct tcb *tcp)
27  #endif
28         return 1;
29  }
30 +
31 +#ifdef SYS_syscall_subcall
32 +static void
33 +decode_syscall_subcall(struct tcb *tcp)
34 +{
35 +       if (!scno_is_valid(tcp->u_arg[0]))
36 +               return;
37 +       tcp->scno = tcp->u_arg[0];
38 +       tcp->qual_flg = qual_flags(tcp->scno);
39 +       tcp->s_ent = &sysent[tcp->scno];
40 +       memmove(&tcp->u_arg[0], &tcp->u_arg[1],
41 +               sizeof(tcp->u_arg) - sizeof(tcp->u_arg[0]));
42 +       /*
43 +        * Fetching the last arg of 7-arg syscalls (fadvise64_64
44 +        * and sync_file_range) requires additional code,
45 +        * see linux/mips/get_syscall_args.c
46 +        */
47 +       if (tcp->s_ent->nargs == MAX_ARGS) {
48 +               if (umoven(tcp,
49 +                          mips_REG_SP + MAX_ARGS * sizeof(tcp->u_arg[0]),
50 +                          sizeof(tcp->u_arg[0]),
51 +                          &tcp->u_arg[MAX_ARGS - 1]) < 0)
52 +               tcp->u_arg[MAX_ARGS - 1] = 0;
53 +       }
54 +}
55 +#endif /* SYS_syscall_subcall */
56 --- a/syscall.c
57 +++ b/syscall.c
58 @@ -349,31 +349,8 @@ decode_ipc_subcall(struct tcb *tcp)
59  #endif /* SYS_ipc_subcall */
60  
61  #ifdef SYS_syscall_subcall
62 -static void
63 -decode_syscall_subcall(struct tcb *tcp)
64 -{
65 -       if (!scno_is_valid(tcp->u_arg[0]))
66 -               return;
67 -       tcp->scno = tcp->u_arg[0];
68 -       tcp->qual_flg = qual_flags(tcp->scno);
69 -       tcp->s_ent = &sysent[tcp->scno];
70 -       memmove(&tcp->u_arg[0], &tcp->u_arg[1],
71 -               sizeof(tcp->u_arg) - sizeof(tcp->u_arg[0]));
72 -# ifdef LINUX_MIPSO32
73 -       /*
74 -        * Fetching the last arg of 7-arg syscalls (fadvise64_64
75 -        * and sync_file_range) requires additional code,
76 -        * see linux/mips/get_syscall_args.c
77 -        */
78 -       if (tcp->s_ent->nargs == MAX_ARGS) {
79 -               if (umoven(tcp,
80 -                          mips_REG_SP + MAX_ARGS * sizeof(tcp->u_arg[0]),
81 -                          sizeof(tcp->u_arg[0]),
82 -                          &tcp->u_arg[MAX_ARGS - 1]) < 0)
83 -               tcp->u_arg[MAX_ARGS - 1] = 0;
84 -       }
85 -# endif /* LINUX_MIPSO32 */
86 -}
87 +/* The implementation is architecture specific.  */
88 +static void decode_syscall_subcall(struct tcb *);
89  #endif /* SYS_syscall_subcall */
90  
91  static void