]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
[PATCH] x86: Make _syscallX() macros compile in PIC mode
authorMarkus Gutschke <markus@google.com>
Thu, 23 Mar 2006 10:59:56 +0000 (02:59 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 23 Mar 2006 15:38:07 +0000 (07:38 -0800)
Gcc reserves %ebx when compiling position-independent-code on i386.  This
means, the _syscallX() macros in include/asm-i386/unistd.h will not
compile.  This patch is changes the existing macros to take special care to
preserve %ebx.

The bug can be tracked at http://bugzilla.kernel.org/show_bug.cgi?id=6204

Signed-off-by: Markus Gutschke <markus@google.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/asm-i386/unistd.h

index dc81a55dd94d08c0fa27bffb254b781bc6b1e1e5..d8afd0e3b81a77501f03473f42337b7efe4b2587 100644 (file)
@@ -347,9 +347,9 @@ __syscall_return(type,__res); \
 type name(type1 arg1) \
 { \
 long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
        : "=a" (__res) \
-       : "0" (__NR_##name),"b" ((long)(arg1)) : "memory"); \
+       : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
 __syscall_return(type,__res); \
 }
 
@@ -357,9 +357,10 @@ __syscall_return(type,__res); \
 type name(type1 arg1,type2 arg2) \
 { \
 long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
        : "=a" (__res) \
-       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)) : "memory"); \
+       : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
+       : "memory"); \
 __syscall_return(type,__res); \
 }
 
@@ -367,9 +368,9 @@ __syscall_return(type,__res); \
 type name(type1 arg1,type2 arg2,type3 arg3) \
 { \
 long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
        : "=a" (__res) \
-       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
+       : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
                  "d" ((long)(arg3)) : "memory"); \
 __syscall_return(type,__res); \
 }
@@ -378,9 +379,9 @@ __syscall_return(type,__res); \
 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
 { \
 long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
        : "=a" (__res) \
-       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
+       : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
          "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
 __syscall_return(type,__res); \
 } 
@@ -390,10 +391,12 @@ __syscall_return(type,__res); \
 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
 { \
 long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
+                  "int $0x80 ; pop %%ebx" \
        : "=a" (__res) \
-       : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) : "memory"); \
+       : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
+       : "memory"); \
 __syscall_return(type,__res); \
 }
 
@@ -402,11 +405,14 @@ __syscall_return(type,__res); \
 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
 { \
 long __res; \
-__asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; int $0x80 ; pop %%ebp" \
+  struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
+__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
+                  "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
+                  "pop %%ebx ;  pop %%ebp" \
        : "=a" (__res) \
-       : "i" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
-         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
-         "0" ((long)(arg6)) : "memory"); \
+       : "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
+       : "memory"); \
 __syscall_return(type,__res); \
 }