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.
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).
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.
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
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
29 .type _init, %function
30 +#if defined __thumb__
35 - @ args = 0, pretend = 0, frame = 0
36 - @ frame_needed = 0, uses_anonymous_args = 0
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
52 + stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
59 .type _fini, %function
60 +#if defined __thumb__
65 - @ args = 0, pretend = 0, frame = 0
66 - @ frame_needed = 0, uses_anonymous_args = 0
77 + stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
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
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
100 +_call_via_\register:
103 + .size _call_via_\register, . - _call_via_\register
106 + @ and calls for the 15 general purpose registers (2 bytes each).
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
133 .type _init, %function
135 +#if defined __thumb__
138 + @ this will not work on ARMv4T, but lots of stuff
139 + @ in here won't work there anyway...
144 + ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
151 .type _fini, %function
153 +#if defined __thumb__
160 + ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
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
169 #define __set_errno(X) {(_dl_errno) = (X);}
170 #include "sys/syscall.h"
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).
176 +#if defined(__thumb__)
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"
183 + "_call_via_\\register:\n"
185 + " .size _call_via_\\register, . - _call_via_\\register\n"