Message ID | 20151215205725.GA11164@intel.com |
---|---|
State | New |
Headers | show |
On 15 Dec 2015 12:57, H.J. Lu wrote: > 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. > > Tested on x86-64. OK for master? lgtm -mike
"H.J. Lu" <hongjiu.lu@intel.com> writes:
> X86-64 system calls use a different calling convention, which clobbers
Different than what?
Andreas.
On Tue, Dec 15, 2015 at 3:32 PM, Andreas Schwab <schwab@linux-m68k.org> wrote: > "H.J. Lu" <hongjiu.lu@intel.com> writes: > >> X86-64 system calls use a different calling convention, which clobbers > > Different than what? > Different from x86-64 function calls.
On Tue, Dec 15, 2015 at 12:57:25PM -0800, H.J. Lu wrote: > 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. > > Tested on x86-64. OK for master? I don't object, but is there a purpose to it? I agree the "different" wording is confusing since there's normally no reason to expect syscalls to look anything like function calls. Rich
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index fc132f6..c364d08 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -218,6 +218,9 @@ # 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; \ @@ -226,7 +229,7 @@ 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...) \ @@ -240,7 +243,7 @@ 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...) \