From: Markus Gutschke <markus@google.com>
To: linux-kernel@vger.kernel.org
Cc: Daniel Kegel <dkegel@google.com>
Subject: [PATCH 1/1] x86: Make _syscallX() macros compile in PIC mode on i386
Date: Thu, 09 Mar 2006 15:33:06 -0800 [thread overview]
Message-ID: <4410BB32.1020905@google.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
From: Markus Gutschke <markus@google.com>
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 against 2.6.15.6 and adds a new set of macros
which will be used in PIC mode. These macros 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>
---
[-- Attachment #2: i386-unistd.h.diff --]
[-- Type: text/x-patch, Size: 3029 bytes --]
--- linux/include/asm-i386/unistd.h.orig 2006-03-05 11:07:54.000000000 -0800
+++ linux/include/asm-i386/unistd.h 2006-03-09 14:25:45.000000000 -0800
@@ -326,6 +326,7 @@
__syscall_return(type,__res); \
}
+#ifndef __PIC__
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
@@ -393,6 +394,82 @@
__syscall_return(type,__res); \
}
+#else /* __PIC__ */
+
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
+ : "memory"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
+ "d" ((long)(arg3)) : "memory"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
+ "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
+ "int $0x80 ; pop %%ebx" \
+ : "=a" (__res) \
+ : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
+ "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
+ : "memory"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+long __res; \
+ 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),"0" ((long)(&__s)),"c" ((long)(arg2)), \
+ "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
+ : "memory"); \
+__syscall_return(type,__res); \
+}
+#endif /* __PIC__ */
+
#ifdef __KERNEL__
#define __ARCH_WANT_IPC_PARSE_VERSION
#define __ARCH_WANT_OLD_READDIR
next reply other threads:[~2006-03-09 23:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-09 23:33 Markus Gutschke [this message]
2006-03-10 2:47 ` [PATCH 1/1] x86: Make _syscallX() macros compile in PIC mode on i386 Andrew Morton
2006-03-10 3:03 ` Markus Gutschke
2006-03-10 3:22 ` Andrew Morton
2006-03-10 3:36 ` dkegel
2006-03-10 23:40 ` Daniel Jacobowitz
2006-03-10 23:53 ` dkegel
2006-03-10 22:42 ` [PATCH 1/1] x86: Make _syscallX() macros compile in PIC mode on i386 (updated patch) Markus Gutschke
2006-03-10 23:02 ` dkegel
2006-03-11 0:05 ` [PATCH 1/1] x86: Make _syscallX() macros compile in PIC mode on i386 Arnd Bergmann
2006-03-10 14:37 ` Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4410BB32.1020905@google.com \
--to=markus@google.com \
--cc=dkegel@google.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox