Browse Source

Joseph S. Myers writes:
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).

Joakim Tjernlund 18 years ago
parent
commit
3850723af0
1 changed files with 7 additions and 0 deletions
  1. 7 0
      libc/sysdeps/linux/powerpc/crt1.S

+ 7 - 0
libc/sysdeps/linux/powerpc/crt1.S

@@ -57,6 +57,13 @@ _start:
 	bl	_GLOBAL_OFFSET_TABLE_-4@local
 	mflr	r31
 # endif
+#endif
+	/* Set up the small data pointer in r13.  */
+#ifdef __PIC__
+	lwz	r13,_SDA_BASE_@got(r31)
+#else
+	lis	r13,_SDA_BASE_@ha
+	addi	r13,r13,_SDA_BASE_@l
 #endif
 	/* Set up an initial stack frame, and clear the LR.  */
 	li	r0,0