]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/gcc/gcc-3.4.4/gcc34-thumb-support.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / gcc / gcc-3.4.4 / gcc34-thumb-support.patch
1 # This patch contains various fixes for the thumb code handling in GCC 3.4.4
2 #
3 # Most of these are minor fixes to code which is either missing (Linux thumb
4 # div0, thumb clear instruction cache) or uses the wrong return mechanism
5 # (libffi)
6 #
7 # There is also a significant design problem with the _call_via_rx code -
8 # it cannot be in a shared library because a call via PLT simply won't
9 # work (for _call_via_ip) and is very inefficient anyway.
10 #
11 # This is fixed in uclibc simply by incorporating the code into crti.S
12 # (an extra 30 bytes for the 15 functions) even though not all link units
13 # require all the code - there is so little of it.  That doesn't work with
14 # the crti.asm here because it is linked with libgcc.a which already defines
15 # these symbols
16 #
17 --- gcc-3.4.4/gcc/config/arm/t-linux.orig       2005-08-09 08:55:02.181797492 -0700
18 +++ gcc-3.4.4/gcc/config/arm/t-linux    2005-08-09 08:58:22.766419486 -0700
19 @@ -7,6 +7,7 @@
20  LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
21         _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
22         _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
23 +       _call_via_rX \
24         _fixsfsi _fixunssfsi
25  
26  # MULTILIB_OPTIONS = mhard-float/msoft-float
27 --- gcc-3.4.4/.pc/gcc34-thumb-support.patch/gcc/config/arm/lib1funcs.asm        2004-01-15 08:56:34.000000000 -0800
28 +++ gcc-3.4.4/gcc/config/arm/lib1funcs.asm      2005-09-21 21:32:03.376927755 -0700
29 @@ -811,13 +811,18 @@
30  
31  /* Constants taken from <asm/unistd.h> and <asm/signal.h> */
32  #define SIGFPE 8
33 +#if !defined __thumb__
34  #define __NR_SYSCALL_BASE      0x900000
35 +#else
36 +#define __NR_SYSCALL_BASE      0
37 +#endif
38  #define __NR_getpid                    (__NR_SYSCALL_BASE+ 20)
39  #define __NR_kill                      (__NR_SYSCALL_BASE+ 37)
40  
41         .code   32
42         FUNC_START div0
43  
44 +#if ! defined __thumb__
45         stmfd   sp!, {r1, lr}
46         swi     __NR_getpid
47         cmn     r0, #1000
48 @@ -825,6 +830,28 @@
49         mov     r1, #SIGFPE
50         swi     __NR_kill
51         RETLDM  r1
52 +#else
53 +       push    {r1, r7, lr}
54 +       mov     r7, #__NR_getpid
55 +       swi     0
56 +       @ above the compare is with -1000, but the standard syscall
57 +       @ macro checks for -1..-125
58 +       add     r0, #125
59 +       bcs     90f
60 +       sub     r0, #125
61 +       mov     r1, #SIGFPE
62 +       mov     r7, #__NR_kill
63 +       swi     0
64 +90:    
65 +#if __ARM_ARCH__ > 4
66 +       pop     {r1, r7, pc}
67 +#else
68 +       @ on 4T that won't work
69 +       pop     {r1, r7}
70 +       pop     {r3}
71 +       bx      r3
72 +#endif
73 +#endif
74  
75         FUNC_END div0
76         
77 @@ -845,14 +872,14 @@
78     code here switches to the correct mode before executing the function.  */
79         
80         .text
81 -       .align 0
82 +       .align 1
83          .force_thumb
84  
85  .macro call_via register
86         THUMB_FUNC_START _call_via_\register
87 +       .hidden SYM (_call_via_\register)
88  
89         bx      \register
90 -       nop
91  
92         SIZE    (_call_via_\register)
93  .endm
94 @@ -903,6 +930,7 @@
95         .code   16
96  
97         THUMB_FUNC_START _interwork_call_via_\register
98 +       .hidden SYM (_interwork_call_via_\register)
99  
100         bx      pc
101         nop
102 --- gcc-3.4.4/.pc/gcc34-thumb-support.patch/gcc/config/arm/linux-gas.h  2003-06-19 14:47:06.000000000 -0700
103 +++ gcc-3.4.4/gcc/config/arm/linux-gas.h        2005-09-20 16:09:55.027862200 -0700
104 @@ -56,6 +56,7 @@
105  
106  /* Clear the instruction cache from `beg' to `end'.  This makes an
107     inline system call to SYS_cacheflush.  */
108 +#if !defined(__thumb__)
109  #define CLEAR_INSN_CACHE(BEG, END)                                     \
110  {                                                                      \
111    register unsigned long _beg __asm ("a1") = (unsigned long) (BEG);    \
112 @@ -65,3 +66,18 @@
113                     : "=r" (_beg)                                       \
114                     : "0" (_beg), "r" (_end), "r" (_flg));              \
115  }
116 +#else
117 +#define CLEAR_INSN_CACHE(BEG, END)                                     \
118 +{                                                                      \
119 +  register unsigned long _beg __asm ("a1") = (unsigned long) (BEG);    \
120 +  register unsigned long _end __asm ("a2") = (unsigned long) (END);    \
121 +  register unsigned long _flg __asm ("a3") = 0;                                \
122 +  register unsigned long _swi __asm ("a4") = 0xf0002;                  \
123 +  __asm __volatile ("push      {r7}\n"                                 \
124 +               "       mov     r7,a4\n"                                \
125 +               "       swi     0       @ sys_cacheflush\n"             \
126 +               "       pop     {r7}\n"                                 \
127 +                   : "=r" (_beg)                                       \
128 +                   : "0" (_beg), "r" (_end), "r" (_flg), "r" (_swi));  \
129 +}
130 +#endif
131 --- gcc-3.4.4/.pc/gcc34-thumb-support.patch/libffi/src/arm/sysv.S       2003-10-21 12:01:55.000000000 -0700
132 +++ gcc-3.4.4/libffi/src/arm/sysv.S     2005-09-20 16:09:55.027862200 -0700
133 @@ -41,6 +41,14 @@
134  #define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
135  #endif
136         
137 +/* Get the correct return instruction */
138 +#if defined(__ARM_ARCH_4T__) || defined(__ARM_ARCH_5__) \
139 +       || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__)
140 +#define RET bx r
141 +#else
142 +#define RET mov pc,
143 +#endif
144 +
145  .text
146  
147         # a1:   ffi_prep_args
148 @@ -66,7 +74,7 @@
149  
150         # And call
151         mov   lr, pc
152 -       mov   pc, ip
153 +       RET   ip
154  
155         # move first 4 parameters in registers
156         ldr   a1, [sp, #0]