Set small data pointer on PowerPC

Joseph S. Myers joseph at codesourcery.com
Sun Mar 18 17:48:58 UTC 2007


On PowerPC, r13 is used for a small data pointer and needs to be set up 
from _SDA_BASE_ (defined by the linker) at startup.

This is needed for the GCC testcase gcc.target/powerpc/980827-1.c to work.  
This patch fixes that testcase (verified for both static and dynamic 
linking).

Index: libc/sysdeps/linux/powerpc/crt1.S
===================================================================
--- libc/sysdeps/linux/powerpc/crt1.S	(revision 18137)
+++ libc/sysdeps/linux/powerpc/crt1.S	(working copy)
@@ -58,6 +58,13 @@
 	mflr	r31
 # endif
 #endif
+	/* Set up the small data pointer in r13.  */
+#ifdef __PIC__
+	lwz	r13,_SDA_BASE_ at got(r31)
+#else
+	lis	r13,_SDA_BASE_ at ha
+	addi	r13,r13,_SDA_BASE_ at l
+#endif
 	/* Set up an initial stack frame, and clear the LR.  */
 	li	r0,0
 	stwu	r1,-16(r1)

-- 
Joseph S. Myers
joseph at codesourcery.com



More information about the uClibc mailing list