[uClibc-cvs] uClibc/ldso/ldso/powerpc ld_sysdep.h,1.6,1.7

Erik Andersen andersen at uclibc.org
Wed Dec 3 23:38:49 UTC 2003


Update of /var/cvs/uClibc/ldso/ldso/powerpc
In directory winder:/tmp/cvs-serv30370

Modified Files:
	ld_sysdep.h 
Log Message:
Henrik Grindal Bakken writes:

The patch touches a minor (well, not that minor, but perhaps only
rarely encountered) bug in the powerpc dynamic linker.

The problem is that addi is called in inline assembly, but there is no
restriction on the second argument.  In powerpc assembler, if the
second argument to addi is r0, it is taken as the value 0, not the
contents of r0.  This happened to me, making the stack pointer 0 on
the invocation on the application.

The patch is against 0.9.22, but there didn't seem to be any changes
to the relevant section in 0.9.23.



Index: ld_sysdep.h
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/powerpc/ld_sysdep.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ld_sysdep.h	8 Nov 2003 20:41:24 -0000	1.6
+++ ld_sysdep.h	3 Dec 2003 23:38:43 -0000	1.7
@@ -99,13 +99,21 @@
  * is done.  This routine has to exit the current function, then 
  * call the _dl_elf_main function.
  */
+
+/* hgb at ifi.uio.no:
+ * Adding a clobber list consisting of r0 for %1.  addi on PowerPC
+ * takes a register as the second argument, but if the register is
+ * r0, the value 0 is used instead.  If r0 is used here, the stack
+ * pointer (r1) will be zeroed, and the dynamically linked
+ * application will seg.fault immediatly when receiving control.
+ */
 #define START()		\
 	__asm__ volatile ( \
 		    "addi 1,%1,0\n\t" \
 		    "mtlr %0\n\t" \
 		    "blrl\n\t"	\
-		    : :	"r" (_dl_elf_main), "r" (args))
-
+		    : : "r" (_dl_elf_main), "r" (args) \
+		    : "r0")
 
 
 /* Here we define the magic numbers that this dynamic loader should accept */




More information about the uClibc-cvs mailing list