summaryrefslogtreecommitdiff
path: root/glibc/glibc-2.2.5/dl-machine-arm.patch
blob: 7684b43b39c9fbe3e60f9bbcaeaafb0d5967921a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383

#
# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
#

--- glibc-2.2.5/sysdeps/arm/dl-machine.h~dl-machine-arm.patch	2004-09-03 19:00:33.000000000 -0500
+++ glibc-2.2.5/sysdeps/arm/dl-machine.h	2004-09-03 19:00:37.000000000 -0500
@@ -121,14 +121,15 @@
    and then redirect to the address it returns.  */
    // macro for handling PIC situation....
 #ifdef PIC
-#define CALL_ROUTINE(x) " ldr sl,0f
-	add 	sl, pc, sl
-1:	ldr	r2, 2f
-	mov	lr, pc
-	add	pc, sl, r2
-	b	3f
-0:	.word	_GLOBAL_OFFSET_TABLE_ - 1b - 4
-2:	.word " #x "(GOTOFF)
+#define CALL_ROUTINE(x) "\
+	ldr sl,0f\n\
+	add 	sl, pc, sl\n\
+1:	ldr	r2, 2f\n\
+	mov	lr, pc\n\
+	add	pc, sl, r2\n\
+	b	3f\n\
+0:	.word	_GLOBAL_OFFSET_TABLE_ - 1b - 4\n\
+2:	.word " #x "(GOTOFF)\n\
 3:	"
 #else
 #define CALL_ROUTINE(x) " bl " #x
@@ -136,114 +137,114 @@
 
 #ifndef PROF
 # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
-	.text
-	.globl _dl_runtime_resolve
-	.type _dl_runtime_resolve, #function
-	.align 2
-_dl_runtime_resolve:
-	@ we get called with
-	@ 	stack[0] contains the return address from this call
-	@	ip contains &GOT[n+3] (pointer to function)
-	@	lr points to &GOT[2]
-
-	@ save almost everything; lr is already on the stack
-	stmdb	sp!,{r0-r3,sl,fp}
-
-	@ prepare to call fixup()
-	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
-	sub	r1, ip, lr
-	sub	r1, r1, #4
-	add	r1, r1, r1
-
-	@ get pointer to linker struct
-	ldr	r0, [lr, #-4]
-
-	@ call fixup routine
-	" CALL_ROUTINE(fixup) "
-
-	@ save the return
-	mov	ip, r0
-
-	@ restore the stack
-	ldmia	sp!,{r0-r3,sl,fp,lr}
-
-	@ jump to the newly found address
-	mov	pc, ip
-
-	.size _dl_runtime_resolve, .-_dl_runtime_resolve
-
-	.globl _dl_runtime_profile
-	.type _dl_runtime_profile, #function
-	.align 2
-_dl_runtime_profile:
-	@ save almost everything; lr is already on the stack
-	stmdb	sp!,{r0-r3,sl,fp}
-
-	@ prepare to call fixup()
-	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
-	sub	r1, ip, lr
-	sub	r1, r1, #4
-	add	r1, r1, r1
-
-	@ get pointer to linker struct
-	ldr	r0, [lr, #-4]
-
-	@ call profiling fixup routine
-	" CALL_ROUTINE(profile_fixup) "
-
-	@ save the return
-	mov	ip, r0
-
-	@ restore the stack
-	ldmia	sp!,{r0-r3,sl,fp,lr}
-
-	@ jump to the newly found address
-	mov	pc, ip
-
-	.size _dl_runtime_resolve, .-_dl_runtime_resolve
-	.previous
+	.text\n\
+	.globl _dl_runtime_resolve\n\
+	.type _dl_runtime_resolve, #function\n\
+	.align 2\n\
+_dl_runtime_resolve:\n\
+	@ we get called with\n\
+	@ 	stack[0] contains the return address from this call\n\
+	@	ip contains &GOT[n+3] (pointer to function)\n\
+	@	lr points to &GOT[2]\n\
+\n\
+	@ save almost everything; lr is already on the stack\n\
+	stmdb	sp!,{r0-r3,sl,fp}\n\
+\n\
+	@ prepare to call fixup()\n\
+	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
+	sub	r1, ip, lr\n\
+	sub	r1, r1, #4\n\
+	add	r1, r1, r1\n\
+\n\
+	@ get pointer to linker struct\n\
+	ldr	r0, [lr, #-4]\n\
+\n\
+	@ call fixup routine\n\
+	" CALL_ROUTINE(fixup) "\n\
+\n\
+	@ save the return\n\
+	mov	ip, r0\n\
+\n\
+	@ restore the stack\n\
+	ldmia	sp!,{r0-r3,sl,fp,lr}\n\
+\n\
+	@ jump to the newly found address\n\
+	mov	pc, ip\n\
+\n\
+	.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
+\n\
+	.globl _dl_runtime_profile\n\
+	.type _dl_runtime_profile, #function\n\
+	.align 2\n\
+_dl_runtime_profile:\n\
+	@ save almost everything; lr is already on the stack\n\
+	stmdb	sp!,{r0-r3,sl,fp}\n\
+\n\
+	@ prepare to call fixup()\n\
+	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
+	sub	r1, ip, lr\n\
+	sub	r1, r1, #4\n\
+	add	r1, r1, r1\n\
+\n\
+	@ get pointer to linker struct\n\
+	ldr	r0, [lr, #-4]\n\
+\n\
+	@ call profiling fixup routine\n\
+	" CALL_ROUTINE(profile_fixup) "\n\
+\n\
+	@ save the return\n\
+	mov	ip, r0\n\
+\n\
+	@ restore the stack\n\
+	ldmia	sp!,{r0-r3,sl,fp,lr}\n\
+\n\
+	@ jump to the newly found address\n\
+	mov	pc, ip\n\
+\n\
+	.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
+	.previous\n\
 ");
 #else // PROF
 # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
-	.text
-	.globl _dl_runtime_resolve
-	.globl _dl_runtime_profile
-	.type _dl_runtime_resolve, #function
-	.type _dl_runtime_profile, #function
-	.align 2
-_dl_runtime_resolve:
-_dl_runtime_profile:
-	@ we get called with
-	@ 	stack[0] contains the return address from this call
-	@	ip contains &GOT[n+3] (pointer to function)
-	@	lr points to &GOT[2]
-
-	@ save almost everything; return add is already on the stack
-	stmdb	sp!,{r0-r3,sl,fp}
-
-	@ prepare to call fixup()
-	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
-	sub	r1, ip, lr
-	sub	r1, r1, #4
-	add	r1, r1, r1
-
-	@ get pointer to linker struct
-	ldr	r0, [lr, #-4]
-
-	@ call profiling fixup routine
-	" CALL_ROUTINE(fixup) "
-
-	@ save the return
-	mov	ip, r0
-
-	@ restore the stack
-	ldmia	sp!,{r0-r3,sl,fp,lr}
-
-	@ jump to the newly found address
-	mov	pc, ip
-
-	.size _dl_runtime_profile, .-_dl_runtime_profile
-	.previous
+	.text\n\
+	.globl _dl_runtime_resolve\n\
+	.globl _dl_runtime_profile\n\
+	.type _dl_runtime_resolve, #function\n\
+	.type _dl_runtime_profile, #function\n\
+	.align 2\n\
+_dl_runtime_resolve:\n\
+_dl_runtime_profile:\n\
+	@ we get called with\n\
+	@ 	stack[0] contains the return address from this call\n\
+	@	ip contains &GOT[n+3] (pointer to function)\n\
+	@	lr points to &GOT[2]\n\
+\n\
+	@ save almost everything; return add is already on the stack\n\
+	stmdb	sp!,{r0-r3,sl,fp}\n\
+\n\
+	@ prepare to call fixup()\n\
+	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
+	sub	r1, ip, lr\n\
+	sub	r1, r1, #4\n\
+	add	r1, r1, r1\n\
+\n\
+	@ get pointer to linker struct\n\
+	ldr	r0, [lr, #-4]\n\
+\n\
+	@ call profiling fixup routine\n\
+	" CALL_ROUTINE(fixup) "\n\
+\n\
+	@ save the return\n\
+	mov	ip, r0\n\
+\n\
+	@ restore the stack\n\
+	ldmia	sp!,{r0-r3,sl,fp,lr}\n\
+\n\
+	@ jump to the newly found address\n\
+	mov	pc, ip\n\
+\n\
+	.size _dl_runtime_profile, .-_dl_runtime_profile\n\
+	.previous\n\
 ");
 #endif //PROF
 
@@ -256,70 +257,70 @@
    its return value is the user program's entry point.  */
 
 #define RTLD_START asm ("\
-.text
-.globl _start
-.globl _dl_start_user
-_start:
-	@ at start time, all the args are on the stack
-	mov	r0, sp
-	bl	_dl_start
-	@ returns user entry point in r0
-_dl_start_user:
-	mov	r6, r0
-	@ we are PIC code, so get global offset table
-	ldr	sl, .L_GET_GOT
-	add	sl, pc, sl
-.L_GOT_GOT:
-	@ Store the highest stack address
-	ldr	r1, .L_STACK_END
-	ldr	r1, [sl, r1]
-	str	sp, [r1]
-	@ See if we were run as a command with the executable file
-	@ name as an extra leading argument.
-	ldr	r4, .L_SKIP_ARGS
-	ldr	r4, [sl, r4]
-	@ get the original arg count
-	ldr	r1, [sp]
-	@ subtract _dl_skip_args from it
-	sub	r1, r1, r4
-	@ adjust the stack pointer to skip them
-	add	sp, sp, r4, lsl #2
-	@ get the argv address
-	add	r2, sp, #4
-	@ store the new argc in the new stack location
-	str	r1, [sp]
-	@ compute envp
-	add	r3, r2, r1, lsl #2
-	add	r3, r3, #4
-
-	@ now we call _dl_init
-	ldr	r0, .L_LOADED
-	ldr	r0, [sl, r0]
-	ldr	r0, [r0]
-	@ call _dl_init
-	bl	_dl_init(PLT)
-	@ clear the startup flag
-	ldr	r2, .L_STARTUP_FLAG
-	ldr	r1, [sl, r2]
-	mov	r0, #0
-	str	r0, [r1]
-	@ load the finalizer function
-	ldr	r0, .L_FINI_PROC
-	ldr	r0, [sl, r0]
-	@ jump to the user_s entry point
-	mov	pc, r6
-.L_GET_GOT:
+.text\n\
+.globl _start\n\
+.globl _dl_start_user\n\
+_start:\n\
+	@ at start time, all the args are on the stack\n\
+	mov	r0, sp\n\
+	bl	_dl_start\n\
+	@ returns user entry point in r0\n\
+_dl_start_user:\n\
+	mov	r6, r0\n\
+	@ we are PIC code, so get global offset table\n\
+	ldr	sl, .L_GET_GOT\n\
+	add	sl, pc, sl\n\
+.L_GOT_GOT:\n\
+	@ Store the highest stack address\n\
+	ldr	r1, .L_STACK_END\n\
+	ldr	r1, [sl, r1]\n\
+	str	sp, [r1]\n\
+	@ See if we were run as a command with the executable file\n\
+	@ name as an extra leading argument.\n\
+	ldr	r4, .L_SKIP_ARGS\n\
+	ldr	r4, [sl, r4]\n\
+	@ get the original arg count\n\
+	ldr	r1, [sp]\n\
+	@ subtract _dl_skip_args from it\n\
+	sub	r1, r1, r4\n\
+	@ adjust the stack pointer to skip them\n\
+	add	sp, sp, r4, lsl #2\n\
+	@ get the argv address\n\
+	add	r2, sp, #4\n\
+	@ store the new argc in the new stack location\n\
+	str	r1, [sp]\n\
+	@ compute envp\n\
+	add	r3, r2, r1, lsl #2\n\
+	add	r3, r3, #4\n\
+\n\
+	@ now we call _dl_init\n\
+	ldr	r0, .L_LOADED\n\
+	ldr	r0, [sl, r0]\n\
+	ldr	r0, [r0]\n\
+	@ call _dl_init\n\
+	bl	_dl_init(PLT)\n\
+	@ clear the startup flag\n\
+	ldr	r2, .L_STARTUP_FLAG\n\
+	ldr	r1, [sl, r2]\n\
+	mov	r0, #0\n\
+	str	r0, [r1]\n\
+	@ load the finalizer function\n\
+	ldr	r0, .L_FINI_PROC\n\
+	ldr	r0, [sl, r0]\n\
+	@ jump to the user_s entry point\n\
+	mov	pc, r6\n\
+.L_GET_GOT:\n\
 	.word	_GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4	\n\
 .L_SKIP_ARGS:					\n\
 	.word	_dl_skip_args(GOTOFF)		\n\
-.L_STARTUP_FLAG:
-	.word	_dl_starting_up(GOT)
-.L_FINI_PROC:
-	.word	_dl_fini(GOT)
-.L_STACK_END:
-	.word	__libc_stack_end(GOT)
-.L_LOADED:
-	.word	_dl_loaded(GOT)
+.L_STARTUP_FLAG:\n\
+	.word	_dl_starting_up(GOT)\n\
+.L_FINI_PROC:\n\
+	.word	_dl_fini(GOT)\n\
+.L_STACK_END:\n\
+	.word	__libc_stack_end(GOT)\n\
+.L_LOADED:\n\
+	.word	_dl_loaded(GOT)\n\
 .previous\n\
 ");