Add REGISTERS_CLOBBERED_BY_SYSCALL for x86-64
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Dec 2015 13:19:57 +0000 (05:19 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Dec 2015 13:20:15 +0000 (05:20 -0800)
X86-64 system calls use a different calling convention, which clobbers
CC, %r11 an %rcx registers.  Define REGISTERS_CLOBBERED_BY_SYSCALL for
x86-64 inline asm statements.

* sysdeps/unix/sysv/linux/x86_64/sysdep.h
(REGISTERS_CLOBBERED_BY_SYSCALL): New.
(INTERNAL_SYSCALL_NCS): Use it.
(INTERNAL_SYSCALL_NCS_TYPES): Likewise.

ChangeLog
sysdeps/unix/sysv/linux/x86_64/sysdep.h

index 21e217a7c18500f72f05bd0db8c79153a66619ea..17b04cd45fb8ce06d3355ea9f57b00712660c9eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-12-16  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * sysdeps/unix/sysv/linux/x86_64/sysdep.h
+       (REGISTERS_CLOBBERED_BY_SYSCALL): New.
+       (INTERNAL_SYSCALL_NCS): Use it.
+       (INTERNAL_SYSCALL_NCS_TYPES): Likewise.
+
 2015-12-16  Florian Weimer  <fweimer@redhat.com>
 
        [BZ #19243]
index fc132f6791f2c2ee37c31284710d4eafb7e1f2a9..c364d0816a7bbadd282c78c2173039db16d350b3 100644 (file)
 # undef INTERNAL_SYSCALL_DECL
 # define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
+/* Registers clobbered by syscall.  */
+# define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx"
+
 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
   ({                                                                         \
     unsigned long int resultvar;                                             \
     asm volatile (                                                           \
     "syscall\n\t"                                                            \
     : "=a" (resultvar)                                                       \
-    : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx");               \
+    : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL);   \
     (long int) resultvar; })
 # undef INTERNAL_SYSCALL
 # define INTERNAL_SYSCALL(name, err, nr, args...) \
     asm volatile (                                                           \
     "syscall\n\t"                                                            \
     : "=a" (resultvar)                                                       \
-    : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx");               \
+    : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL);   \
     (long int) resultvar; })
 # undef INTERNAL_SYSCALL_TYPES
 # define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \