diff options
author | WANG Xuerui <git@xen0n.name> | 2020-02-13 00:57:03 +0800 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2020-02-12 22:13:59 +0000 |
commit | 4fbba6fe904d0094ddc4284066b3860d119cbd4a (patch) | |
tree | 4cd2fb0717f0aa12d49eec12f448f3950230b12e /sysdeps/unix/sysv/linux/mips/mips32 | |
parent | d3fbb18aa3164ca1d11e8acba81e1fc2ca70f43e (diff) | |
download | glibc-4fbba6fe904d0094ddc4284066b3860d119cbd4a.tar.gz glibc-4fbba6fe904d0094ddc4284066b3860d119cbd4a.tar.xz glibc-4fbba6fe904d0094ddc4284066b3860d119cbd4a.zip |
mips: Fix argument passing for inlined syscalls on Linux [BZ #25523]
According to [gcc documentation][1], temporary variables must be used for the desired content to not be call-clobbered. Fix the Linux inline syscall templates by adding temporary variables, much like what x86 did before (commit 381a0c26d73e0f074c962e0ab53b99a6c327066d). Tested with gcc 9.2.0, both cross-compiled and natively on Loongson 3A4000. [1]: https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html
Diffstat (limited to 'sysdeps/unix/sysv/linux/mips/mips32')
-rw-r--r-- | sysdeps/unix/sysv/linux/mips/mips32/sysdep.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h index 5cdac96b20..0c6a83e9b3 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h @@ -178,10 +178,11 @@ union __mips_syscall_return long int _sys_result; \ \ { \ + long int _arg1 = (long int) (arg1); \ register long int __s0 asm ("$16") __attribute__ ((unused)) \ = (number); \ register long int __v0 asm ("$2"); \ - register long int __a0 asm ("$4") = (long int) (arg1); \ + register long int __a0 asm ("$4") = _arg1; \ register long int __a3 asm ("$7"); \ __asm__ volatile ( \ ".set\tnoreorder\n\t" \ @@ -202,11 +203,13 @@ union __mips_syscall_return long int _sys_result; \ \ { \ + long int _arg1 = (long int) (arg1); \ + long int _arg2 = (long int) (arg2); \ register long int __s0 asm ("$16") __attribute__ ((unused)) \ = (number); \ register long int __v0 asm ("$2"); \ - register long int __a0 asm ("$4") = (long int) (arg1); \ - register long int __a1 asm ("$5") = (long int) (arg2); \ + register long int __a0 asm ("$4") = _arg1; \ + register long int __a1 asm ("$5") = _arg2; \ register long int __a3 asm ("$7"); \ __asm__ volatile ( \ ".set\tnoreorder\n\t" \ @@ -228,12 +231,15 @@ union __mips_syscall_return long int _sys_result; \ \ { \ + long int _arg1 = (long int) (arg1); \ + long int _arg2 = (long int) (arg2); \ + long int _arg3 = (long int) (arg3); \ register long int __s0 asm ("$16") __attribute__ ((unused)) \ = (number); \ register long int __v0 asm ("$2"); \ - register long int __a0 asm ("$4") = (long int) (arg1); \ - register long int __a1 asm ("$5") = (long int) (arg2); \ - register long int __a2 asm ("$6") = (long int) (arg3); \ + register long int __a0 asm ("$4") = _arg1; \ + register long int __a1 asm ("$5") = _arg2; \ + register long int __a2 asm ("$6") = _arg3; \ register long int __a3 asm ("$7"); \ __asm__ volatile ( \ ".set\tnoreorder\n\t" \ @@ -255,13 +261,17 @@ union __mips_syscall_return long int _sys_result; \ \ { \ + long int _arg1 = (long int) (arg1); \ + long int _arg2 = (long int) (arg2); \ + long int _arg3 = (long int) (arg3); \ + long int _arg4 = (long int) (arg4); \ register long int __s0 asm ("$16") __attribute__ ((unused)) \ = (number); \ register long int __v0 asm ("$2"); \ - register long int __a0 asm ("$4") = (long int) (arg1); \ - register long int __a1 asm ("$5") = (long int) (arg2); \ - register long int __a2 asm ("$6") = (long int) (arg3); \ - register long int __a3 asm ("$7") = (long int) (arg4); \ + register long int __a0 asm ("$4") = _arg1; \ + register long int __a1 asm ("$5") = _arg2; \ + register long int __a2 asm ("$6") = _arg3; \ + register long int __a3 asm ("$7") = _arg4; \ __asm__ volatile ( \ ".set\tnoreorder\n\t" \ v0_init \ |