]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/uclibc/uclibc-0.9.28/thumb-swi-r7.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / uclibc / uclibc-0.9.28 / thumb-swi-r7.patch
1 # This is a work round for a fairly serious GCC compiler bug - when
2 # the syscall assembler overwrites r7 (required on thumb) the
3 # compiler fails to protect the register when it is using it as a
4 # frame pointer.
5 #
6 --- uClibc-0.9.28/libc/sysdeps/linux/arm/bits/syscalls.h        2005-09-12 17:51:26.062205918 -0700
7 +++ uClibc-0.9.28/libc/sysdeps/linux/arm/bits/syscalls.h        2005-09-12 18:16:15.507930828 -0700
8 @@ -111,6 +111,11 @@
9       }                                                         \
10       (int) _sys_result; })
11  #else
12 +#if 0
13 +/* This doesn't work because GCC uses r7 as a frame pointer in
14 + * some cases and doesn't notice that the _r7 value changes
15 + * it, resulting in mysterious crashes after the SWI.
16 + */
17  #define INTERNAL_SYSCALL(name, err, nr, args...)               \
18    ({ unsigned int _sys_result;                                 \
19       {                                                         \
20 @@ -124,6 +129,28 @@
21         _sys_result = _a1;                                      \
22       }                                                         \
23       (int) _sys_result; })
24 +#else
25 +/* So hide the use of r7 from the compiler, this would be a lot
26 + * easier but for the fact that the syscalls can exceed 255.
27 + * For the moment the LOAD_ARG_7 is sacrificed.
28 + */
29 +#define INTERNAL_SYSCALL(name, err, nr, args...)               \
30 +  ({ unsigned int _sys_result;                                 \
31 +     {                                                         \
32 +       register int _a1 asm ("a1");                            \
33 +       LOAD_ARGS_##nr (args)                                   \
34 +       register int _v3 asm ("v3") = (int) (SYS_ify(name));    \
35 +       asm volatile ("push     {r7}\n"                         \
36 +                    "\tmov     r7, v3\n"                       \
37 +                    "\tswi     0       @ syscall " #name "\n"  \
38 +                    "\tpop     {r7}"                           \
39 +                    : "=r" (_a1)                               \
40 +                    : "r" (_v3) ASM_ARGS_##nr                  \
41 +                    : "memory");                               \
42 +       _sys_result = _a1;                                      \
43 +     }                                                         \
44 +     (int) _sys_result; })
45 +#endif
46  #endif
47  
48  #undef INTERNAL_SYSCALL_ERROR_P