From: Benedikt Huber Date: Wed, 29 Feb 2012 14:17:04 +0000 (+0100) Subject: Fix gcc inline assembler operand constraints for syscall -- as pushl modifies %esp... X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea904493370d2a752855cc93aad1e27b009dd917;p=pintos-anon Fix gcc inline assembler operand constraints for syscall -- as pushl modifies %esp, variable operands must not reference the stack pointer. Without this patch, gcc-4.6.1-9ubuntu3 miscompiles the read syscall to: 000000b6 : b6: ff 74 24 0c pushl 0xc(%esp) ba: ff 74 24 08 pushl 0x8(%esp) ; [!] be: ff 74 24 04 pushl 0x4(%esp) ; [!] ... --- diff --git a/src/lib/user/syscall.c b/src/lib/user/syscall.c index a9c5bc8..c8385bc 100644 --- a/src/lib/user/syscall.c +++ b/src/lib/user/syscall.c @@ -38,8 +38,8 @@ "pushl %[number]; int $0x30; addl $12, %%esp" \ : "=a" (retval) \ : [number] "i" (NUMBER), \ - [arg0] "g" (ARG0), \ - [arg1] "g" (ARG1) \ + [arg0] "r" (ARG0), \ + [arg1] "r" (ARG1) \ : "memory"); \ retval; \ }) @@ -54,9 +54,9 @@ "pushl %[number]; int $0x30; addl $16, %%esp" \ : "=a" (retval) \ : [number] "i" (NUMBER), \ - [arg0] "g" (ARG0), \ - [arg1] "g" (ARG1), \ - [arg2] "g" (ARG2) \ + [arg0] "r" (ARG0), \ + [arg1] "r" (ARG1), \ + [arg2] "r" (ARG2) \ : "memory"); \ retval; \ })