[PATCH] mips: Fix argument passing for inlined syscalls on Linux [BZ #25523]

Matt Turner mattst88@gmail.com
Thu Feb 27 18:24:00 GMT 2020


On Sat, Feb 22, 2020 at 2:40 PM Maciej W. Rozycki <macro@linux-mips.org> wrote:
>
> On Mon, 10 Feb 2020, WANG Xuerui wrote:
>
> > According to [gcc documentation][1], temporary variables must be used for
> > the desired content to not be call-clobbered.
>
>  Why does it specifically matter here?
>
> > diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> > index beefcf284b..c275d63f67 100644
> > --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> > +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> [...]
> > @@ -202,11 +203,13 @@ union __mips_syscall_return
> >       long _sys_result;                                               \
> >                                                                       \
> >       {                                                               \
> > +     long _arg1 = (long) (arg1);                                     \
> > +     long _arg2 = (long) (arg2);                                     \
> >       register long __s0 asm ("$16") __attribute__ ((unused))         \
> >         = (number);                                                   \
> >       register long __v0 asm ("$2");                                  \
> > -     register long __a0 asm ("$4") = (long) (arg1);                  \
> > -     register long __a1 asm ("$5") = (long) (arg2);                  \
> > +     register long __a0 asm ("$4") = _arg1;                          \
> > +     register long __a1 asm ("$5") = _arg2;                          \
> >       register long __a3 asm ("$7");                                  \
> >       __asm__ volatile (                                              \
> >       ".set\tnoreorder\n\t"                                           \
>
>  Can e.g. `(long) (arg1)' end up as a library call?  Do you have a case,
> even potential, where such clobbering actually happens?

We found that GNU make 4.3 fails to work on MIPS without this patch to
glibc. See https://bugs.gentoo.org/708758



More information about the Libc-alpha mailing list