Browse Source

Fix static apps on linux 2.6. Linux clobbers r7 in 2.6, so
use r3 instead to pass _dl_fini.

Joakim Tjernlund 18 years ago
parent
commit
813349ca63
2 changed files with 6 additions and 3 deletions
  1. 4 2
      ldso/ldso/powerpc/dl-startup.h
  2. 2 1
      libc/sysdeps/linux/powerpc/crt1.S

+ 4 - 2
ldso/ldso/powerpc/dl-startup.h

@@ -42,8 +42,10 @@ asm(
     "	bne	2b\n"
     "	addi	6,6,4\n"
 #endif
-    /* Pass a termination function pointer (in this case _dl_fini) in r7.  */
-    "	lwz	7,_dl_fini@got(31)\n"
+    /* Pass a termination function pointer (in this case _dl_fini) in r3. */
+    /* Paulus promized he would keep r3 zero in the exec ABI. */
+    "	lwz	3,_dl_fini@got(31)\n"
+    "	mr	7,3\n"		/* Pass _dl_fini in r7 to maintain compat */
     "	bctr\n" /* Jump to entry point */
     "	.size	_start,.-_start\n"
     "	.previous\n"

+ 2 - 1
libc/sysdeps/linux/powerpc/crt1.S

@@ -60,7 +60,8 @@ _start:
 	lwz	r4,0(r9)
 	/* find argv one word offset from the stack pointer */
 	addi	r5,r9,4
-	mr	r8,r7 /* Pass _dl_fini from ldso or NULL if statically linked */
+	mr	r8,r3 /* Pass _dl_fini from ldso or NULL if statically linked
+			Note:	 using r3 instead of r7, since linux 2.6 clobbers r7 */
 	/* Ok, now run uClibc's main() -- shouldn't return */
 #ifdef __PIC__
 	lwz	r6,_init@got(r31)