]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/uclibc/uclibc-0.9.28/thumb-call-via-rx.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-call-via-rx.patch
1 # Put the call_via_rx code into each executable - call_via_ip cannot
2 # possibly work if called through the PLT!  ldso requires this code
3 # too as it is not linked with the crt stuff and thumb ldso does
4 # make calls via a register.
5 #
6 # The patch puts the code into crti.S so that it is linked into
7 # every normally built application (if thumb or interworking is
8 # selected).  This is only 30 extra bytes and it works - the previous
9 # code did not because nothing both implemented and exported the
10 # APIs (they were in libgcc, but not in the version script).
11 #
12 # crti.S and crtn.S is also brought up to date with GCC 3.4.4 - this
13 # is essential for thumb support because the .init and .fini sections
14 # must use arm or thumb code to match the compilation of the libraries.
15 #
16 # Note that code which pushes stuff into .init or .fini must be
17 # compiled with or without -mthumb to match the uclibc compilation -
18 # and gcc itself (which does do this) must therefore be compiled to
19 # match.
20 #
21 --- uClibc-0.9.28/.pc/thumb-call-via-rx.patch/libc/sysdeps/linux/arm/crti.S     2005-08-17 15:49:41.000000000 -0700
22 +++ uClibc-0.9.28/libc/sysdeps/linux/arm/crti.S 2005-09-21 19:15:19.996721584 -0700
23 @@ -1,26 +1,86 @@
24         .file   "initfini.c"
25         
26         .section .init
27 -       .align  2
28         .global _init
29         .type   _init, %function
30 +#if defined __thumb__
31 +       .align  1
32 +       .thumb
33 +       .thumb_func
34  _init:
35 -       @ args = 0, pretend = 0, frame = 0
36 -       @ frame_needed = 0, uses_anonymous_args = 0
37 -       str     lr, [sp, #-4]!
38 -       
39 -       .align 2
40 -       
41 -       
42 -       .section .fini
43 +       push    {r4-r7, lr}
44 +#else
45         .align  2
46 +       .arm
47 +_init:
48 +       @ gcc 3.3.2 didn't create a stack frame, gcc 3.4.4 does -
49 +       @ presumably 3.4.4 can put stuff into .init which requires
50 +       @ the arguments to be saved.  This code is copied from 3.4.4
51 +       mov     ip, sp
52 +       stmdb   sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
53 +       sub     fp, ip, #4
54 +#endif
55 +
56 +
57 +       .section .fini
58         .global _fini
59         .type   _fini, %function
60 +#if defined __thumb__
61 +       .align  1
62 +       .thumb
63 +       .thumb_func
64  _fini:
65 -       @ args = 0, pretend = 0, frame = 0
66 -       @ frame_needed = 0, uses_anonymous_args = 0
67 -       str     lr, [sp, #-4]!
68 -       .align 2
69 -       
70 -       
71 +       push    {r4-r7, lr}
72 +#else
73 +       .align  2
74 +       .arm
75 +_fini:
76 +       mov     ip, sp
77 +       stmdb   sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
78 +       sub     fp, ip, #4
79 +#endif
80 +
81 +
82 +#if (defined __thumb__ || defined __THUMB_INTERWORK__) && (defined __ARM_ARCH_4T__ || defined __ARM_ARCH_5T__ || defined __ARM_ARCH_5TE__)
83 +       @ To support thumb code it is currently necessary to have the _call_via_rX
84 +       @ functions exposed to the linker for any program or shared library.  PLT
85 +       @ references are inadequate - the PLT zaps ip and therefore breaks _call_via_ip
86 +       @ (and the compiler does generate this).  It is simpler to put all the
87 +       @ required code in here - it only amounts to 60 bytes overhead.
88 +       @NOTE: it would be better to have the compiler generate this stuff as
89 +       @ required...
90 +       .section        ".text"
91 +       .align 0
92 +       .force_thumb
93 +
94 +.macro call_via register
95 +       .global _call_via_\register
96 +       .type   _call_via_\register, %function
97 +       .weak   _call_via_\register
98 +       .hidden _call_via_\register
99 +       .thumb_func
100 +_call_via_\register:
101 +       bx      \register
102 +       nop
103 +       .size   _call_via_\register, . - _call_via_\register
104 +.endm
105 +
106 +       @ and calls for the 15 general purpose registers (2 bytes each).
107 +       call_via r0
108 +       call_via r1
109 +       call_via r2
110 +       call_via r3
111 +       call_via r4
112 +       call_via r5
113 +       call_via r6
114 +       call_via r7
115 +       call_via r8
116 +       call_via r9
117 +       call_via sl
118 +       call_via fp
119 +       call_via ip
120 +       call_via sp
121 +       call_via lr
122 +#endif
123 +
124         .ident  "GCC: (GNU) 3.3.2 20031005 (Debian prerelease)"
125 --- uClibc-0.9.28/libc/sysdeps/linux/arm/crtn.S.orig    2005-09-20 16:39:20.010925582 -0700
126 +++ uClibc-0.9.28/libc/sysdeps/linux/arm/crtn.S 2005-09-20 17:00:51.700206464 -0700
127 @@ -1,17 +1,34 @@
128         .file   "initfini.c"
129         
130         .section .init
131 -       .align  2
132         .global _init
133         .type   _init, %function
134 -       ldr     pc, [sp], #4
135 +#if defined __thumb__
136 +       .align  1
137 +       .thumb
138 +       @ this will not work on ARMv4T, but lots of stuff
139 +       @ in here won't work there anyway...
140 +       pop     {r4-r7, pc}
141 +#else
142 +       .align  2
143 +       .arm
144 +       ldmdb   fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
145 +#endif
146         .size   _init, .-_init
147         
148         .section .fini
149 -       .align  2
150         .global _fini
151         .type   _fini, %function
152 -       ldr     pc, [sp], #4
153 +#if defined __thumb__
154 +       .align  1
155 +       .thumb
156 +       pop     {r4-r7, pc}
157 +#else
158 +       .align  2
159 +       .arm
160 +       ldmdb   fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
161 +#endif
162         .size   _fini, .-_fini
163         
164 +       @ In fact this is modified to 3.4.4
165         .ident  "GCC: (GNU) 3.3.2 20031005 (Debian prerelease)"
166 --- uClibc-0.9.28/.pc/thumb-call-via-rx.patch/ldso/ldso/arm/dl-syscalls.h       2005-08-17 15:49:41.000000000 -0700
167 +++ uClibc-0.9.28/ldso/ldso/arm/dl-syscalls.h   2005-09-21 19:17:01.143086323 -0700
168 @@ -4,3 +4,39 @@
169  #define __set_errno(X) {(_dl_errno) = (X);}
170  #include "sys/syscall.h"
171  
172 +/* _call_via_rX calls are used in thumb ldso because of calls via
173 + * function pointers, but ldso is not linked with anything which
174 + * provides them, so define them here (only required for thumb).
175 + */
176 +#if defined(__thumb__)
177 +asm(
178 +       ".macro call_via register\n"
179 +       "       .global _call_via_\\register\n"
180 +       "       .hidden _call_via_\\register\n"
181 +       "       .type   _call_via_\\register, %function\n"
182 +       "       .thumb_func\n"
183 +       "_call_via_\\register:\n"
184 +       "       bx      \\register\n"
185 +       "       .size   _call_via_\\register, . - _call_via_\\register\n"
186 +       ".endm\n"
187 +
188 +       ".text\n"
189 +       ".thumb\n"
190 +       ".align 1\n"
191 +       "       call_via r0\n"
192 +       "       call_via r1\n"
193 +       "       call_via r2\n"
194 +       "       call_via r3\n"
195 +       "       call_via r4\n"
196 +       "       call_via r5\n"
197 +       "       call_via r6\n"
198 +       "       call_via r7\n"
199 +       "       call_via r8\n"
200 +       "       call_via r9\n"
201 +       "       call_via r10\n"
202 +       "       call_via r11\n"
203 +       "       call_via r12\n"
204 +       "       call_via r13\n"
205 +       "       call_via r14\n"
206 +);
207 +#endif