patches/glibc/2.2.5/dl-machine-arm.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
     1 Fixes error:
     2 In file included from dynamic-link.h:21,
     3                  from dl-load.c:32:
     4 ../sysdeps/arm/dl-machine.h:124:25: missing terminating " character
     5 ...
     6 make[2]: *** [/crosstool-0.22/build/arm-unknown-linux-gnu/gcc-3.3-glibc-2.2.5/build-glibc/elf/dl-load.o] Error 1
     7 
     8 The first two hunks of 
     9 http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/arm/dl-machine.h.diff?r1=1.39&r2=1.40&cvsroot=glibc
    10 applied cleanly, but the third hunk didn't, so I just added the \n\'s by hand for that section.
    11 
    12 --- glibc-2.2.5/sysdeps/arm/dl-machine.h.orig	Sat Sep  8 14:31:40 2001
    13 +++ glibc-2.2.5/sysdeps/arm/dl-machine.h	Wed Aug 27 10:55:26 2003
    14 @@ -121,14 +121,15 @@
    15     and then redirect to the address it returns.  */
    16     // macro for handling PIC situation....
    17  #ifdef PIC
    18 -#define CALL_ROUTINE(x) " ldr sl,0f
    19 -	add 	sl, pc, sl
    20 -1:	ldr	r2, 2f
    21 -	mov	lr, pc
    22 -	add	pc, sl, r2
    23 -	b	3f
    24 -0:	.word	_GLOBAL_OFFSET_TABLE_ - 1b - 4
    25 -2:	.word " #x "(GOTOFF)
    26 +#define CALL_ROUTINE(x) "\
    27 +	ldr sl,0f\n\
    28 +	add 	sl, pc, sl\n\
    29 +1:	ldr	r2, 2f\n\
    30 +	mov	lr, pc\n\
    31 +	add	pc, sl, r2\n\
    32 +	b	3f\n\
    33 +0:	.word	_GLOBAL_OFFSET_TABLE_ - 1b - 4\n\
    34 +2:	.word " #x "(GOTOFF)\n\
    35  3:	"
    36  #else
    37  #define CALL_ROUTINE(x) " bl " #x
    38 @@ -136,114 +137,114 @@
    39  
    40  #ifndef PROF
    41  # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
    42 -	.text
    43 -	.globl _dl_runtime_resolve
    44 -	.type _dl_runtime_resolve, #function
    45 -	.align 2
    46 -_dl_runtime_resolve:
    47 -	@ we get called with
    48 -	@ 	stack[0] contains the return address from this call
    49 -	@	ip contains &GOT[n+3] (pointer to function)
    50 -	@	lr points to &GOT[2]
    51 -
    52 -	@ save almost everything; lr is already on the stack
    53 -	stmdb	sp!,{r0-r3,sl,fp}
    54 -
    55 -	@ prepare to call fixup()
    56 -	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
    57 -	sub	r1, ip, lr
    58 -	sub	r1, r1, #4
    59 -	add	r1, r1, r1
    60 -
    61 -	@ get pointer to linker struct
    62 -	ldr	r0, [lr, #-4]
    63 -
    64 -	@ call fixup routine
    65 -	" CALL_ROUTINE(fixup) "
    66 -
    67 -	@ save the return
    68 -	mov	ip, r0
    69 -
    70 -	@ restore the stack
    71 -	ldmia	sp!,{r0-r3,sl,fp,lr}
    72 -
    73 -	@ jump to the newly found address
    74 -	mov	pc, ip
    75 -
    76 -	.size _dl_runtime_resolve, .-_dl_runtime_resolve
    77 -
    78 -	.globl _dl_runtime_profile
    79 -	.type _dl_runtime_profile, #function
    80 -	.align 2
    81 -_dl_runtime_profile:
    82 -	@ save almost everything; lr is already on the stack
    83 -	stmdb	sp!,{r0-r3,sl,fp}
    84 -
    85 -	@ prepare to call fixup()
    86 -	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
    87 -	sub	r1, ip, lr
    88 -	sub	r1, r1, #4
    89 -	add	r1, r1, r1
    90 -
    91 -	@ get pointer to linker struct
    92 -	ldr	r0, [lr, #-4]
    93 -
    94 -	@ call profiling fixup routine
    95 -	" CALL_ROUTINE(profile_fixup) "
    96 -
    97 -	@ save the return
    98 -	mov	ip, r0
    99 -
   100 -	@ restore the stack
   101 -	ldmia	sp!,{r0-r3,sl,fp,lr}
   102 -
   103 -	@ jump to the newly found address
   104 -	mov	pc, ip
   105 -
   106 -	.size _dl_runtime_resolve, .-_dl_runtime_resolve
   107 -	.previous
   108 +	.text\n\
   109 +	.globl _dl_runtime_resolve\n\
   110 +	.type _dl_runtime_resolve, #function\n\
   111 +	.align 2\n\
   112 +_dl_runtime_resolve:\n\
   113 +	@ we get called with\n\
   114 +	@ 	stack[0] contains the return address from this call\n\
   115 +	@	ip contains &GOT[n+3] (pointer to function)\n\
   116 +	@	lr points to &GOT[2]\n\
   117 +\n\
   118 +	@ save almost everything; lr is already on the stack\n\
   119 +	stmdb	sp!,{r0-r3,sl,fp}\n\
   120 +\n\
   121 +	@ prepare to call fixup()\n\
   122 +	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
   123 +	sub	r1, ip, lr\n\
   124 +	sub	r1, r1, #4\n\
   125 +	add	r1, r1, r1\n\
   126 +\n\
   127 +	@ get pointer to linker struct\n\
   128 +	ldr	r0, [lr, #-4]\n\
   129 +\n\
   130 +	@ call fixup routine\n\
   131 +	" CALL_ROUTINE(fixup) "\n\
   132 +\n\
   133 +	@ save the return\n\
   134 +	mov	ip, r0\n\
   135 +\n\
   136 +	@ restore the stack\n\
   137 +	ldmia	sp!,{r0-r3,sl,fp,lr}\n\
   138 +\n\
   139 +	@ jump to the newly found address\n\
   140 +	mov	pc, ip\n\
   141 +\n\
   142 +	.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
   143 +\n\
   144 +	.globl _dl_runtime_profile\n\
   145 +	.type _dl_runtime_profile, #function\n\
   146 +	.align 2\n\
   147 +_dl_runtime_profile:\n\
   148 +	@ save almost everything; lr is already on the stack\n\
   149 +	stmdb	sp!,{r0-r3,sl,fp}\n\
   150 +\n\
   151 +	@ prepare to call fixup()\n\
   152 +	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
   153 +	sub	r1, ip, lr\n\
   154 +	sub	r1, r1, #4\n\
   155 +	add	r1, r1, r1\n\
   156 +\n\
   157 +	@ get pointer to linker struct\n\
   158 +	ldr	r0, [lr, #-4]\n\
   159 +\n\
   160 +	@ call profiling fixup routine\n\
   161 +	" CALL_ROUTINE(profile_fixup) "\n\
   162 +\n\
   163 +	@ save the return\n\
   164 +	mov	ip, r0\n\
   165 +\n\
   166 +	@ restore the stack\n\
   167 +	ldmia	sp!,{r0-r3,sl,fp,lr}\n\
   168 +\n\
   169 +	@ jump to the newly found address\n\
   170 +	mov	pc, ip\n\
   171 +\n\
   172 +	.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
   173 +	.previous\n\
   174  ");
   175  #else // PROF
   176  # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
   177 -	.text
   178 -	.globl _dl_runtime_resolve
   179 -	.globl _dl_runtime_profile
   180 -	.type _dl_runtime_resolve, #function
   181 -	.type _dl_runtime_profile, #function
   182 -	.align 2
   183 -_dl_runtime_resolve:
   184 -_dl_runtime_profile:
   185 -	@ we get called with
   186 -	@ 	stack[0] contains the return address from this call
   187 -	@	ip contains &GOT[n+3] (pointer to function)
   188 -	@	lr points to &GOT[2]
   189 -
   190 -	@ save almost everything; return add is already on the stack
   191 -	stmdb	sp!,{r0-r3,sl,fp}
   192 -
   193 -	@ prepare to call fixup()
   194 -	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
   195 -	sub	r1, ip, lr
   196 -	sub	r1, r1, #4
   197 -	add	r1, r1, r1
   198 -
   199 -	@ get pointer to linker struct
   200 -	ldr	r0, [lr, #-4]
   201 -
   202 -	@ call profiling fixup routine
   203 -	" CALL_ROUTINE(fixup) "
   204 -
   205 -	@ save the return
   206 -	mov	ip, r0
   207 -
   208 -	@ restore the stack
   209 -	ldmia	sp!,{r0-r3,sl,fp,lr}
   210 -
   211 -	@ jump to the newly found address
   212 -	mov	pc, ip
   213 -
   214 -	.size _dl_runtime_profile, .-_dl_runtime_profile
   215 -	.previous
   216 +	.text\n\
   217 +	.globl _dl_runtime_resolve\n\
   218 +	.globl _dl_runtime_profile\n\
   219 +	.type _dl_runtime_resolve, #function\n\
   220 +	.type _dl_runtime_profile, #function\n\
   221 +	.align 2\n\
   222 +_dl_runtime_resolve:\n\
   223 +_dl_runtime_profile:\n\
   224 +	@ we get called with\n\
   225 +	@ 	stack[0] contains the return address from this call\n\
   226 +	@	ip contains &GOT[n+3] (pointer to function)\n\
   227 +	@	lr points to &GOT[2]\n\
   228 +\n\
   229 +	@ save almost everything; return add is already on the stack\n\
   230 +	stmdb	sp!,{r0-r3,sl,fp}\n\
   231 +\n\
   232 +	@ prepare to call fixup()\n\
   233 +	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
   234 +	sub	r1, ip, lr\n\
   235 +	sub	r1, r1, #4\n\
   236 +	add	r1, r1, r1\n\
   237 +\n\
   238 +	@ get pointer to linker struct\n\
   239 +	ldr	r0, [lr, #-4]\n\
   240 +\n\
   241 +	@ call profiling fixup routine\n\
   242 +	" CALL_ROUTINE(fixup) "\n\
   243 +\n\
   244 +	@ save the return\n\
   245 +	mov	ip, r0\n\
   246 +\n\
   247 +	@ restore the stack\n\
   248 +	ldmia	sp!,{r0-r3,sl,fp,lr}\n\
   249 +\n\
   250 +	@ jump to the newly found address\n\
   251 +	mov	pc, ip\n\
   252 +\n\
   253 +	.size _dl_runtime_profile, .-_dl_runtime_profile\n\
   254 +	.previous\n\
   255  ");
   256  #endif //PROF
   257  
   258 @@ -256,70 +257,70 @@
   259     its return value is the user program's entry point.  */
   260  
   261  #define RTLD_START asm ("\
   262 -.text
   263 -.globl _start
   264 -.globl _dl_start_user
   265 -_start:
   266 -	@ at start time, all the args are on the stack
   267 -	mov	r0, sp
   268 -	bl	_dl_start
   269 -	@ returns user entry point in r0
   270 -_dl_start_user:
   271 -	mov	r6, r0
   272 -	@ we are PIC code, so get global offset table
   273 -	ldr	sl, .L_GET_GOT
   274 -	add	sl, pc, sl
   275 -.L_GOT_GOT:
   276 -	@ Store the highest stack address
   277 -	ldr	r1, .L_STACK_END
   278 -	ldr	r1, [sl, r1]
   279 -	str	sp, [r1]
   280 -	@ See if we were run as a command with the executable file
   281 -	@ name as an extra leading argument.
   282 -	ldr	r4, .L_SKIP_ARGS
   283 -	ldr	r4, [sl, r4]
   284 -	@ get the original arg count
   285 -	ldr	r1, [sp]
   286 -	@ subtract _dl_skip_args from it
   287 -	sub	r1, r1, r4
   288 -	@ adjust the stack pointer to skip them
   289 -	add	sp, sp, r4, lsl #2
   290 -	@ get the argv address
   291 -	add	r2, sp, #4
   292 -	@ store the new argc in the new stack location
   293 -	str	r1, [sp]
   294 -	@ compute envp
   295 -	add	r3, r2, r1, lsl #2
   296 -	add	r3, r3, #4
   297 -
   298 -	@ now we call _dl_init
   299 -	ldr	r0, .L_LOADED
   300 -	ldr	r0, [sl, r0]
   301 -	ldr	r0, [r0]
   302 -	@ call _dl_init
   303 -	bl	_dl_init(PLT)
   304 -	@ clear the startup flag
   305 -	ldr	r2, .L_STARTUP_FLAG
   306 -	ldr	r1, [sl, r2]
   307 -	mov	r0, #0
   308 -	str	r0, [r1]
   309 -	@ load the finalizer function
   310 -	ldr	r0, .L_FINI_PROC
   311 -	ldr	r0, [sl, r0]
   312 -	@ jump to the user_s entry point
   313 -	mov	pc, r6
   314 -.L_GET_GOT:
   315 +.text\n\
   316 +.globl _start\n\
   317 +.globl _dl_start_user\n\
   318 +_start:\n\
   319 +	@ at start time, all the args are on the stack\n\
   320 +	mov	r0, sp\n\
   321 +	bl	_dl_start\n\
   322 +	@ returns user entry point in r0\n\
   323 +_dl_start_user:\n\
   324 +	mov	r6, r0\n\
   325 +	@ we are PIC code, so get global offset table\n\
   326 +	ldr	sl, .L_GET_GOT\n\
   327 +	add	sl, pc, sl\n\
   328 +.L_GOT_GOT:\n\
   329 +	@ Store the highest stack address\n\
   330 +	ldr	r1, .L_STACK_END\n\
   331 +	ldr	r1, [sl, r1]\n\
   332 +	str	sp, [r1]\n\
   333 +	@ See if we were run as a command with the executable file\n\
   334 +	@ name as an extra leading argument.\n\
   335 +	ldr	r4, .L_SKIP_ARGS\n\
   336 +	ldr	r4, [sl, r4]\n\
   337 +	@ get the original arg count\n\
   338 +	ldr	r1, [sp]\n\
   339 +	@ subtract _dl_skip_args from it\n\
   340 +	sub	r1, r1, r4\n\
   341 +	@ adjust the stack pointer to skip them\n\
   342 +	add	sp, sp, r4, lsl #2\n\
   343 +	@ get the argv address\n\
   344 +	add	r2, sp, #4\n\
   345 +	@ store the new argc in the new stack location\n\
   346 +	str	r1, [sp]\n\
   347 +	@ compute envp\n\
   348 +	add	r3, r2, r1, lsl #2\n\
   349 +	add	r3, r3, #4\n\
   350 +\n\
   351 +	@ now we call _dl_init\n\
   352 +	ldr	r0, .L_LOADED\n\
   353 +	ldr	r0, [sl, r0]\n\
   354 +	ldr	r0, [r0]\n\
   355 +	@ call _dl_init\n\
   356 +	bl	_dl_init(PLT)\n\
   357 +	@ clear the startup flag\n\
   358 +	ldr	r2, .L_STARTUP_FLAG\n\
   359 +	ldr	r1, [sl, r2]\n\
   360 +	mov	r0, #0\n\
   361 +	str	r0, [r1]\n\
   362 +	@ load the finalizer function\n\
   363 +	ldr	r0, .L_FINI_PROC\n\
   364 +	ldr	r0, [sl, r0]\n\
   365 +	@ jump to the user_s entry point\n\
   366 +	mov	pc, r6\n\
   367 +.L_GET_GOT:\n\
   368  	.word	_GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4	\n\
   369  .L_SKIP_ARGS:					\n\
   370  	.word	_dl_skip_args(GOTOFF)		\n\
   371 -.L_STARTUP_FLAG:
   372 -	.word	_dl_starting_up(GOT)
   373 -.L_FINI_PROC:
   374 -	.word	_dl_fini(GOT)
   375 -.L_STACK_END:
   376 -	.word	__libc_stack_end(GOT)
   377 -.L_LOADED:
   378 -	.word	_dl_loaded(GOT)
   379 +.L_STARTUP_FLAG:\n\
   380 +	.word	_dl_starting_up(GOT)\n\
   381 +.L_FINI_PROC:\n\
   382 +	.word	_dl_fini(GOT)\n\
   383 +.L_STACK_END:\n\
   384 +	.word	__libc_stack_end(GOT)\n\
   385 +.L_LOADED:\n\
   386 +	.word	_dl_loaded(GOT)\n\
   387  .previous\n\
   388  ");
   389