-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi
While compiling uclibc on thumb and running LTP tests on it I noticed
that the sched_setaffinity system calls were failing. The reason is that
when the parameters to syscall macros on ARM contain function calls, gcc
places the calls to evaluate the parameters at the very end just before
the system call instruction (SVC) is called.
This corrupts the registers that has been set up for the system call.
This patch evaluates the arguments in LOAD_ARGS_x macros and also
separates declaration to make it more PPC like. Thanks to Daniel
Jacobowitz for this suggestion.
OK ?
- --
Khem Raj
MontaVista Software Inc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFH62FZUjbQJxVzeZQRAsL4AJ9d/5tq7oI5j83WGV4A6X+RNffr4ACcCxSs
umaI9CW4WfDAxndSPjGwEwg=
=wr+D
-----END PGP SIGNATURE-----
Signed-off-by: Khem Raj <[EMAIL PROTECTED]>
Load the arguments into local variables this will avoid the late evaluation of
the variable arguments which can destroy the registers
<Verbose description of the change>
Index: uclibc-0.9.29/libc/sysdeps/linux/arm/bits/syscalls.h
===================================================================
--- uclibc-0.9.29.orig/libc/sysdeps/linux/arm/bits/syscalls.h
+++ uclibc-0.9.29/libc/sysdeps/linux/arm/bits/syscalls.h
@@ -111,7 +111,8 @@ return (type) (INLINE_SYSCALL(name, 7, a
#define INTERNAL_SYSCALL(name, err, nr, args...) \
({unsigned int __sys_result; \
{ \
- register int _a1 __asm__ ("r0"), _nr __asm__ ("r7");
\
+ register int _a1 __asm__ ("r0"), _nr __asm__ ("r7"); \
+ DECL_ARGS_##nr (args) \
LOAD_ARGS_##nr (args) \
_nr = SYS_ify(name); \
__asm__ volatile ("swi 0x0 @ syscall " #name \
@@ -134,6 +135,7 @@ return (type) (INLINE_SYSCALL(name, 7, a
int _sys_buf[2]; \
register int _a1 asm ("a1"); \
register int *_v3 asm ("v3") = _sys_buf; \
+ DECL_ARGS_##nr (args) \
*_v3 = (int) (SYS_ify(name)); \
LOAD_ARGS_##nr (args) \
asm volatile ("str r7, [v3, #4]\n" \
@@ -153,6 +155,7 @@ return (type) (INLINE_SYSCALL(name, 7, a
({ unsigned int __sys_result; \
{ \
register int _a1 __asm__ ("a1"); \
+ DECL_ARGS_##nr (args) \
LOAD_ARGS_##nr (args) \
__asm__ volatile ("swi %1 @ syscall " #name \
: "=r" (_a1) \
@@ -189,6 +192,7 @@ return (type) (INLINE_SYSCALL(name, 7, a
({ unsigned int __sys_result; \
{ \
register int _a1 __asm__ ("a1"); \
+ DECL_ARGS_##nr (args) \
LOAD_ARGS_##nr (args) \
register int _v3 __asm__ ("v3") = (int) (SYS_ify(name)); \
__asm__ volatile ("push {r7}\n" \
@@ -212,37 +216,63 @@ return (type) (INLINE_SYSCALL(name, 7, a
#undef INTERNAL_SYSCALL_ERRNO
#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+#define DECL_ARGS_0()
#define LOAD_ARGS_0()
#define ASM_ARGS_0
+#define DECL_ARGS_1(a1)
#define LOAD_ARGS_1(a1) \
- _a1 = (int) (a1); \
+ int arg1 = (int) a1; \
+ _a1 = arg1; \
LOAD_ARGS_0 ()
#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
+#define DECL_ARGS_2(a1, a2) \
+ register int _a2 __asm__ ("a2"); \
+ DECL_ARGS_1 (a1)
#define LOAD_ARGS_2(a1, a2) \
- register int _a2 __asm__ ("a2") = (int) (a2); \
- LOAD_ARGS_1 (a1)
+ int arg2 = (int) a2; \
+ LOAD_ARGS_1 (a1) \
+ _a2 = arg2;
#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
+#define DECL_ARGS_3(a1, a2, a3) \
+ register int _a3 __asm__ ("a3"); \
+ DECL_ARGS_2 (a1, a2)
#define LOAD_ARGS_3(a1, a2, a3) \
- register int _a3 __asm__ ("a3") = (int) (a3); \
- LOAD_ARGS_2 (a1, a2)
+ int arg3 = (int) a3; \
+ LOAD_ARGS_2 (a1, a2) \
+ _a3 = arg3;
#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
+#define DECL_ARGS_4(a1, a2, a3, a4) \
+ register int _a4 __asm__ ("a4"); \
+ DECL_ARGS_3 (a1, a2, a3)
#define LOAD_ARGS_4(a1, a2, a3, a4) \
- register int _a4 __asm__ ("a4") = (int) (a4); \
- LOAD_ARGS_3 (a1, a2, a3)
+ int arg4 = (int) a4; \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ _a4 = arg4;
#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
+#define DECL_ARGS_5(a1, a2, a3, a4, a5) \
+ register int _v1 __asm__ ("v1"); \
+ DECL_ARGS_4 (a1, a2, a3, a4)
#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
- register int _v1 __asm__ ("v1") = (int) (a5); \
- LOAD_ARGS_4 (a1, a2, a3, a4)
+ int arg5 = (int) a5; \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ _v1 = arg5;
#define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1)
+#define DECL_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ register int _v2 __asm__ ("v2"); \
+ DECL_ARGS_5 (a1, a2, a3, a4, a5)
#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
- register int _v2 __asm__ ("v2") = (int) (a6); \
- LOAD_ARGS_5 (a1, a2, a3, a4, a5)
+ int arg6 = (int) a6; \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ _v2 = arg6;
#define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2)
+#define DECL_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \
+ register int _v3 __asm__ ("v3"); \
+ DECL_ARGS_6 (a1, a2, a3, a4, a5, a6)
#define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \
- register int _v3 __asm__ ("v3") = (int) (a7); \
- LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6)
+ int arg7 = (int) a7; \
+ LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6) \
+ _v3 = arg7;
#define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3)
-
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc